[system] / trunk / pg / lib / Applet.pm Repository:
ViewVC logotype

Diff of /trunk/pg/lib/Applet.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 5984 Revision 6023
1################################################################################ 1################################################################################
2# WeBWorK Online Homework Delivery System 2# WeBWorK Online Homework Delivery System
3# Copyright 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/ 3# Copyright 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
4# $CVSHeader: pg/lib/Applet.pm,v 1.13 2008/11/19 04:39:43 gage Exp $ 4# $CVSHeader: pg/lib/Applet.pm,v 1.18 2009/03/10 12:10:36 gage Exp $
5# 5#
6# This program is free software; you can redistribute it and/or modify it under 6# This program is free software; you can redistribute it and/or modify it under
7# the terms of either: (a) the GNU General Public License as published by the 7# the terms of either: (a) the GNU General Public License as published by the
8# Free Software Foundation; either version 2, or (at your option) any later 8# Free Software Foundation; either version 2, or (at your option) any later
9# version, or (b) the "Artistic License" which comes with this package. 9# version, or (b) the "Artistic License" which comes with this package.
108 108
109 getApplet(appletName) -- finds the applet path in the DOM 109 getApplet(appletName) -- finds the applet path in the DOM
110 110
111 submitAction() -- calls the submit action of the applets 111 submitAction() -- calls the submit action of the applets
112 112
113 initializeAction() -- calls the initialize action of the applets 113 initializeWWquestion() -- calls the initialize action of the applets
114 114
115 getQE(name) -- gets an HTML element of the question by name 115 getQE(name) -- gets an HTML element of the question by name
116 or by id. Be sure to keep all names and ids 116 or by id. Be sure to keep all names and ids
117 unique within a given PG question. 117 unique within a given PG question.
118 118
124 Usage: Place this at the END of the question, just before END_DOCUMENT(): 124 Usage: Place this at the END of the question, just before END_DOCUMENT():
125 125
126 TEXT(qq!<script> listQuestionElements() </script>!); 126 TEXT(qq!<script> listQuestionElements() </script>!);
127 ENDDOCUMENT(); 127 ENDDOCUMENT();
128 to obtain a list of all of the HTML elements in the question 128 to obtain a list of all of the HTML elements in the question
129 129
130 ----------------------------------------------------------------------------
131
132
130 List of accessor methods made available by the FlashApplet class: 133 List of accessor methods made available by the FlashApplet class:
131 Usage: $current_value = $applet->method(new_value or empty) 134 Usage: $current_value = $applet->method(new_value or empty)
132 These can also be set when creating the class -- for exampe: 135 These can also be set when creating the class -- for exampe:
133 $applet = new FlashApplet( 136 $applet = new FlashApplet(
134 # can be replaced by $applet =FlashApplet() when using AppletObjects.pl 137 # can be replaced by $applet =FlashApplet() when using AppletObjects.pl
158 config configuration are those customizable attributes of the applet which don't 161 config configuration are those customizable attributes of the applet which don't
159 change as it is used. When stored in hidden answer fields 162 change as it is used. When stored in hidden answer fields
160 it is usually stored in base64 encoded format. 163 it is usually stored in base64 encoded format.
161 base64_config base64 encode version of the contents of config 164 base64_config base64 encode version of the contents of config
162 165
163 configAlias (default: config ) names the applet command called with the contents of $self->config 166 configAlias (default: setConfig ) names the applet command called with the contents of $self->config
164 to configure the applet. The parameters are passed to the applet in plain text using <xml> 167 to configure the applet. The parameters are passed to the applet in plain text using <xml>
165 The outer tags must be <xml> ..... </xml> 168 The outer tags must be <xml> ..... </xml>
169 setConfigAlias (default: setConfig) -- a synonym for configAlias
170 getConfigAlias (default: getConfig) -- retrieves the configuration from the applet. This is used
171 mainly for debugging. In principal the configuration remains the same for a given instance
172 of the applet -- i.e. for the homework question for a single student. The state however
173 will change depending on the interactions between the student and the applet.
166 state state consists of those customizable attributes of the applet which change 174 initialState the state consists of those customizable attributes of the applet which change
167 as the applet is used. It is stored by the calling .pg question so that 175 as the applet is used by the student. It is stored by the calling .pg question so that
168 when revisiting the question the applet
169 will be restored to the same state it was left in when the question was last 176 when revisiting the question the applet will be restored to the same state it was left in when the question was last
170 viewed. 177 viewed.
171 178
172 getStateAlias (default: getState) alias for command called to read the current state of the applet. 179 getStateAlias (default: getState) alias for command called to read the current state of the applet.
173 The state is passed in plain text xml format with outer tags: <xml>....</xml> 180 The state is passed in plain text xml format with outer tags: <xml>....</xml>
174 setStateAlias (default: setState) alias for the command called to reset the state of the applet. 181 setStateAlias (default: setState) alias for the command called to reset the state of the applet.
177 base64_state returns the base64 encoded version of the state stored in the applet object. 184 base64_state returns the base64 encoded version of the state stored in the applet object.
178 185
179 initializeActionAlias -- (default: initializeAction) the name of the javaScript subroutine called to initialize the applet (some overlap with config/ and setState 186 initializeActionAlias -- (default: initializeAction) the name of the javaScript subroutine called to initialize the applet (some overlap with config/ and setState
180 submitActionAlias -- (default: submitAction)the name of the javaScript subroutine called when the submit button of the 187 submitActionAlias -- (default: submitAction)the name of the javaScript subroutine called when the submit button of the
181 .pg question is pressed. 188 .pg question is pressed.
182 189 answerBox -- name of answer box to return answer to: default defaultAnswerBox
183 returnFieldName 190 getAnswer -- (formerly sendData) get student answer from applet and place in answerBox
191 returnFieldName -- (deprecated) synonmym for answerBox
184 192
185 193
186=cut 194=cut
187 195
196=head4 More details
188 197
198There are three different "images" of the applet. The first is the java or flash applet itself. The object that actually does the work.
199The second is a perl image of the applet -- henceforth the perlApplet -- which is configured in the .pg file and allows a WeBWorK question
200to communicate with the applet. The third image is a javaScript image of the applet -- henceforth the jsApplet which is a mirror of the perlApplet
201but is available to the javaScript code setup and executed in the virtual HTML page defined by the .pg file of the WeBWorK question. One can think of
202the jsApplet as a runtime version of the perlApplet since it can be accessed and modified after the virtual HTML page has been created by
203the PG rendering process.
189 204
205The perlApplet is initialized by $newApplet = new flashApplet( appletName=>'myApplet',..... ); The jsApplet is automatically defined in
206ww_applet_list["myApplet"] by copying the instance variables of $newApplet to a corresponding javaScript object. So $newApplet->{appletName}
207corresponds to ww_applet_list["myApplet"].appletName. (This paragraph is not yet fully implemented :-().
208
209Currently all messages read by the applet are xml text. If some of the code needs to be printed in the HTML header than it is converted
210to a base64 constant and then converted back to text form when it is read by an javaScript subroutine.
211
212=cut
213
214=head4 Requirements for applets
215
216The following methods are desirable in an applet that preserves state in a WW question. None of them are required.
217
218 setState(str) (default: setXML)
219 -- set the current state of the applet from an xml string
220 -- should be able to accept an empty string or a string of
221 the form <XML>.....</XML> without creating errors
222 -- can be designed to receive other forms of input if it is
223 coordinated with the WW question.
224 getState() (default: getXML)
225 -- return the current state of the applet in an xml string.
226 -- an empty string or a string of the form <XML>.....</XML>
227 are the standard responses.
228 -- can be designed to return other strings if it is
229 coordinated with the WW question.
230 setConfig(str) (default: setConfig)
231 -- If the applet allows configuration this configures the applet
232 from an xml string
233 -- should be able to accept an empty string or a string of the
234 form <XML>.....</XML> without creating errors
235 -- can be designed to receive other forms of input if it is
236 coordinated with the WW question.
237 getConfig (default: getConfig)
238 -- This returns a string defining the configuration of the
239 applet in an xml string
240 -- an empty string or a string of the form <XML>.....</XML>
241 are the standard responses.
242 -- can be designed to return other strings if it is
243 coordinated with the WW question.
244 -- this method is used for debugging to ensure that
245 the configuration was set as expected.
246 getAnswer (default: getAnswer)
247 -- Returns a string (usually NOT xml) which is the
248 response that the student is submitting to answer
249 the WW question.
250
251
252=cut
190 253
191sub new { 254sub new {
192 my $class = shift; 255 my $class = shift;
193 my $self = { 256 my $self = {
194 appletName =>'', 257 appletName =>'',
196 codebase=>'', 259 codebase=>'',
197# appletId =>'', #always use identical applet Id's and applet Names 260# appletId =>'', #always use identical applet Id's and applet Names
198 params =>undef, 261 params =>undef,
199 width => 550, 262 width => 550,
200 height => 400, 263 height => 400,
264 bgcolor => "#869ca7",
201 base64_state => undef, # this is an state to use for initializing the first occurence of the question. 265 base64_state => undef, # this is a state to use for initializing the first occurence of the question.
202 base64_config => undef, # this is the initial (and final?) configuration 266 base64_config => undef, # this is the initial (and final?) configuration
267# configuration => '', # configuration defining the applet
268 initialState => '', # initial state. (I'm considering storing everything as ascii and converting on the fly to base64 when needed.)
203 getStateAlias => 'getXML', 269 getStateAlias => 'getXML',
204 setStateAlias => 'setXML', 270 setStateAlias => 'setXML',
271 configAlias => '', # deprecated
205 configAlias => 'config', 272 getConfigAlias => 'getConfig',
273 setConfigAlias => 'setConfig',
206 initializeActionAlias => 'setXML', 274 initializeActionAlias => 'setXML',
207 submitActionAlias => 'getXML', 275 submitActionAlias => 'getXML',
208 submitActionScript => '', # script executed on submitting the WW question 276 submitActionScript => '', # script executed on submitting the WW question
209 returnFieldName => 'receivedField', 277 answerBoxAlias => 'answerBox',
278 answerBox => '', # deprecated
279 returnFieldName => '', # deprecated
210 headerText => DEFAULT_HEADER_TEXT(), 280 headerText => DEFAULT_HEADER_TEXT(),
211 objectText => '', 281 objectText => '',
212 debug => 0, 282 debug => 0,
213 @_, 283 @_,
214 }; 284 };
215 bless $self, $class; 285 bless $self, $class;
216 $self->state('<xml></xml>'); 286 $self->initialState('<xml></xml>');
287 if ($self->{returnFieldName}) or $self->{answerBox} ) { # backward compatibility
288 warn "use answerBoxAlias instead of returnFieldName or answerBox";
289 $self->{answerBox}='';
290 $self->{returnFieldName}='';
291 }
292 if ($self->{configAlias}) { # backward compatibility
293 warn "use setConfigAlias instead of configAlias";
294 $self->{configAlias}='';
295 }
217 $self->config('<xml></xml>'); 296 $self->config('<xml></xml>');
218 return $self; 297 return $self;
219} 298}
220 299
221sub header { 300sub header {
275 $self->{setStateAlias} = shift ||$self->{setStateAlias}; # replace the current contents if non-empty 354 $self->{setStateAlias} = shift ||$self->{setStateAlias}; # replace the current contents if non-empty
276 $self->{setStateAlias}; 355 $self->{setStateAlias};
277} 356}
278sub configAlias { 357sub configAlias {
279 my $self = shift; 358 my $self = shift;
280 $self->{configAlias} = shift ||$self->{configAlias}; # replace the current contents if non-empty 359 $self->{setConfigAlias} = shift ||$self->{setConfigAlias}; # replace the current contents if non-empty
281 $self->{configAlias}; 360 $self->{setConfigAlias};
282} 361}
283sub returnFieldName { 362sub setConfigAlias {
284 my $self = shift; 363 my $self = shift;
285 $self->{returnFieldName} = shift ||$self->{returnFieldName}; # replace the current contents if non-empty 364 $self->{setConfigAlias} = shift ||$self->{setConfigAlias}; # replace the current contents if non-empty
286 $self->{returnFieldName}; 365 $self->{setConfigAlias};
366}
367sub getConfigAlias {
368 my $self = shift;
369 $self->{getConfigAlias} = shift ||$self->{getConfigAlias}; # replace the current contents if non-empty
370 $self->{getConfigAlias};
371}
372
373sub answerBoxName {
374 my $self = shift;
375 $self->{answerBox} = shift ||$self->{answerBox}; # replace the current contents if non-empty
376 $self->{answerBox};
287} 377}
288sub codebase { 378sub codebase {
289 my $self = shift; 379 my $self = shift;
290 $self->{codebase} = shift ||$self->{codebase}; # replace the current codebase if non-empty 380 $self->{codebase} = shift ||$self->{codebase}; # replace the current codebase if non-empty
291 $self->{codebase}; 381 $self->{codebase};
302} 392}
303sub width { 393sub width {
304 my $self = shift; 394 my $self = shift;
305 $self->{width} = shift ||$self->{width}; # replace the current width if non-empty 395 $self->{width} = shift ||$self->{width}; # replace the current width if non-empty
306 $self->{width}; 396 $self->{width};
397}
398sub bgcolor {
399 my $self = shift;
400 $self->{bgcolor} = shift ||$self->{bgcolor}; # replace the current background color if non-empty
401 $self->{bgcolor};
307} 402}
308sub archive { 403sub archive {
309 my $self = shift; 404 my $self = shift;
310 $self->{archive} = shift ||$self->{archive}; # replace the current archive if non-empty 405 $self->{archive} = shift ||$self->{archive}; # replace the current archive if non-empty
311 $self->{archive}; 406 $self->{archive};
322 $self->{debug}; 417 $self->{debug};
323} 418}
324sub appletId { 419sub appletId {
325 appletName(@_); 420 appletName(@_);
326} 421}
422
423sub initialState {
424 my $self = shift;
425 my $str = shift;
426 $self->{initialState} = $str ||$self->{initialState}; # replace the current string if non-empty
427 $self->{initialState};
428}
429
430sub config {
431 my $self = shift;
432 my $str = shift;
433 $self->{base64_config} = encode_base64($str) || $self->{base64_config}; # replace the current string if non-empty
434 $self->{base64_config} =~ s/\n//g;
435 decode_base64($self->{base64_config});
436}
437#######################
438# soon to be deprecated?
439#######################
327sub state { 440sub state {
328 my $self = shift; 441 my $self = shift;
329 my $str = shift; 442 my $str = shift;
330 $self->{base64_state} = encode_base64($str) ||$self->{base64_state}; # replace the current string if non-empty 443 $self->{base64_state} = encode_base64($str) ||$self->{base64_state}; # replace the current string if non-empty
331 $self->{base64_state} =~ s/\n//g; 444 $self->{base64_state} =~ s/\n//g;
332 decode_base64($self->{base64_state}); 445 decode_base64($self->{base64_state});
333} 446}
334
335sub base64_state{ 447sub base64_state{
336 my $self = shift; 448 my $self = shift;
337 $self->{base64_state} = shift ||$self->{base64_state}; # replace the current string if non-empty 449 $self->{base64_state} = shift ||$self->{base64_state}; # replace the current string if non-empty
338 $self->{base64_state}; 450 $self->{base64_state};
339} 451}
340sub config { 452
341 my $self = shift;
342 my $str = shift;
343 $self->{base64_config} = encode_base64($str) || $self->{base64_config}; # replace the current string if non-empty
344 $self->{base64_config} =~ s/\n//g;
345 decode_base64($self->{base64_config});
346}
347sub base64_config { 453sub base64_config {
348 my $self = shift; 454 my $self = shift;
349 $self->{base64_config} = shift ||$self->{base64_config}; # replace the current string if non-empty 455 $self->{base64_config} = shift ||$self->{base64_config}; # replace the current string if non-empty
350 $self->{base64_config} =$self->{base64_config}; 456 $self->{base64_config} =$self->{base64_config};
351 $self->{base64_config}; 457 $self->{base64_config};
352} 458}
459
460sub returnFieldName {
461 my $self = shift;
462 warn "use answerBoxName instead of returnFieldName";
463}
464sub answerBox {
465 my $self = shift;
466 warn "use answerBoxName instead of AnswerBox";
467}
468#########################
353#FIXME 469#FIXME
354# need to be able to adjust header material 470# need to be able to adjust header material
355 471
356sub insertHeader { 472sub insertHeader {
357 my $self = shift; 473 my $self = shift;
474
358 my $codebase = $self->codebase; 475 my $codebase = $self->codebase;
359 my $appletId = $self->appletId; 476 my $appletId = $self->appletId;
360 my $appletName = $self->appletName; 477 my $appletName = $self->appletName;
361 my $base64_initialState = $self->base64_state; 478 my $base64_initialState = $self->base64_state;
362 my $initializeAction = $self->initializeActionAlias; 479 my $initializeAction = $self->initializeActionAlias;
363 my $submitAction = $self->submitActionAlias; 480 my $submitActionAlias = $self->submitActionAlias;
364 my $submitActionScript = $self->submitActionScript; 481 my $submitActionScript = $self->submitActionScript;
365 my $setState = $self->setStateAlias; 482 my $setStateAlias = $self->setStateAlias;
366 my $getState = $self->getStateAlias; 483 my $getStateAlias = $self->getStateAlias;
484
367 my $config = $self->configAlias; 485 my $setConfigAlias = $self->setConfigAlias;
486 my $getConfigAlias = $self->getConfigAlias;
368 my $base64_config = $self->base64_config; 487 my $base64_config = $self->base64_config;
369 my $debugMode = ($self->debug) ? "1": "0"; 488 my $debugMode = ($self->debug) ? "1": "0";
370 my $returnFieldName = $self->{returnFieldName}; 489 my $returnFieldName = $self->{returnFieldName};
371# my $encodeStateQ = ($self->debug)?'' : "state = Base64.encode(state);"; # in debug mode base64 encoding is not used. 490 my $answerBox = $self->{answerBox};
372# my $decodeStateQ = "if (!state.match(/<XML>*/i) ) {state = Base64.decode(state)}"; # decode if <XML> is not present
373 my $headerText = $self->header(); 491 my $headerText = $self->header();
492
493
494 $submitActionScript =~ s/"/\\"/g; # escape quotes for ActionScript
495 # other variables should not have quotes.
496
497 $submitActionScript =~ s/\n/ /g; # replace returns with spaces -- returns in the wrong spot can cause trouble with javaScript
498 $submitActionScript =~ s/\r/ /g; # replace returns with spaces -- returns can cause trouble
374 499
375 $headerText =~ s/(\$\w+)/$1/gee; # interpolate variables p17 of Cookbook 500 $headerText =~ s/(\$\w+)/$1/gee; # interpolate variables p17 of Cookbook
376 501
377 return $headerText; 502 return $headerText;
378 503
386 my $appletId = $self->{appletName}; 511 my $appletId = $self->{appletName};
387 my $appletName = $self->{appletName}; 512 my $appletName = $self->{appletName};
388 my $archive = $self->{archive}; 513 my $archive = $self->{archive};
389 my $width = $self->{width}; 514 my $width = $self->{width};
390 my $height = $self->{height}; 515 my $height = $self->{height};
516 my $applet_bgcolor = $self->{bgcolor};
391 my $javaParameters = ''; 517 my $javaParameters = '';
392 my $flashParameters = ''; 518 my $flashParameters = '';
393 my %param_hash = %{$self->params()}; 519 my %param_hash = %{$self->params()};
394 foreach my $key (keys %param_hash) { 520 foreach my $key (keys %param_hash) {
395 $javaParameters .= qq!<param name ="$key" value = "$param_hash{$key}">\n!; 521 $javaParameters .= qq!<param name ="$key" value = "$param_hash{$key}">\n!;
400 526
401 $objectText = $self->{objectText}; 527 $objectText = $self->{objectText};
402 $objectText =~ s/(\$\w+)/$1/gee; 528 $objectText =~ s/(\$\w+)/$1/gee;
403 return $objectText; 529 return $objectText;
404} 530}
405sub initialize { 531# sub initialize {
406 my $self = shift; 532# my $self = shift;
407 return q{ 533# return q{
408 <script> 534# <script>
409 initializeAction(); 535# initializeAllApplets();
410 // this should really be done in the <body> tag 536# // this should really be done in the <body> tag
411 </script> 537# </script>
412 }; 538# };
413 539#
414} 540# }
415######################################################## 541########################################################
416# HEADER material for one flash or java applet 542# HEADER material for one flash or java applet
417######################################################## 543########################################################
418 544
419use constant DEFAULT_HEADER_TEXT =><<'END_HEADER_SCRIPT'; 545use constant DEFAULT_HEADER_TEXT =><<'END_HEADER_SCRIPT';
420 546 <script src="/webwork2_files/js/Base64.js" language="javascript">
547 </script>
548 <script src="/webwork2_files/js/ww_applet_support.js" language="javascript">
549 //upload functions stored in /opt/webwork/webwork2/htdocs/js ...
550
551 </script>
421 <script language="JavaScript"> 552 <script language="JavaScript">
422 553
423 // set debug mode for this applet 554 // set debug mode for this applet
424 set_debug($debugMode); 555 set_debug($debugMode);
425 556
426 ////////////////////////////////////////////////////////// 557 //////////////////////////////////////////////////////////
427 //CONFIGURATIONS 558 //TEST code
428 // 559 //
429 // configurations are "permanent" 560 //
430 ////////////////////////////////////////////////////////// 561 //////////////////////////////////////////////////////////
562
563 ww_applet_list["$appletName"] = new ww_applet("$appletName");
431 564
432 applet_config_list["$appletName"] = function() {
433 debug_add("applet_config_list:\n attempt to configure $appletName . $config ( $base64_config ) if config function is defined: "
434 );
435 try {
436 if (( typeof(getApplet("$appletName").$config) == "function" ) ) {
437 debug_add("CONFIGURE $appletName");
438 getApplet("$appletName").$config(Base64.decode("$base64_config"));
439 }
440 } catch(e) {
441 alert("Error executing configuration command $config for $appletName: " + e );
442 }
443 }
444 ////////////////////////////////////////////////////////////
445 //
446 //STATE:
447 // state can vary as the applet is manipulated -- it is reset from the questions _state values
448 //
449 //////////////////////////////////////////////////////////
450 565
451 applet_setState_list["$appletName"] = function(state) { 566 ww_applet_list["$appletName"].code = "$code";
452 debug_add("Begin setState for applet $appletName"); 567 ww_applet_list["$appletName"].codebase = "$codebase";
453 debug_add("Obtain state from $appletName"+"_state"); 568 ww_applet_list["$appletName"].appletID = "$appletID";
454 state = state || getQE("$appletName"+"_state").value; 569 ww_applet_list["$appletName"].base64_state = "$base64_initializationState";
455 if ( base64Q(state) ) { 570 ww_applet_list["$appletName"].base64_config = "$base64_config";
456 state=Base64.decode(state); 571 ww_applet_list["$appletName"].getStateAlias = "$getStateAlias";
457 } 572 ww_applet_list["$appletName"].setStateAlias = "$setStateAlias";
458 if (state.match(/<xml/i) || state.match(/<?xml/i) ) { // if state starts with <?xml 573 ww_applet_list["$appletName"].setConfigAlias = "$setConfigAlias";
459 574 ww_applet_list["$appletName"].getConfigAlias = "$getConfigAlias";
460 debug_add("applet_setState_list: \n set (decoded) state for $appletName to " + 575 ww_applet_list["$appletName"].initializeActionAlias = "$initializeAction";
461 state +"\nfunction type is " +typeof(getApplet("$appletName").$setState) 576 ww_applet_list["$appletName"].submitActionAlias = "$submitActionAlias";
462 ); 577 ww_applet_list["$appletName"].submitActionScript = "$submitActionScript";
463 try { 578 ww_applet_list["$appletName"].answerBox = "$answerBox";
464 if (( typeof(getApplet("$appletName").$setState) =="function" ) ) { 579 ww_applet_list["$appletName"].debug = "$debugMode";
465 debug_add("setState for $appletName");
466 getApplet("$appletName").$setState( state );
467 }
468 } catch(e) {
469 alert("Error in setting state of $appletName using command $setState : " + e );
470 }
471 } else if (debug) {
472 alert("new state was empty string or did not begin with <xml-- state was not reset");
473 }
474 };
475 applet_getState_list["$appletName"] = function () {
476 debug_add("get current state for applet $appletName and store it in $appletName"+"_state");
477 var applet = getApplet("$appletName");
478 try {
479 if (( typeof(applet.$getState) == "function" ) ) { // there may be no state function
480 state = applet.$getState(); // get state in xml format
481 debug_add("state has type " + typeof(state));
482 state = String(state); // geogebra returned an object type instead of a string type
483 debug_add("state converted to type " + typeof(state));
484 }
485
486 if (!debug) {
487 state = Base64.encode(state);
488 }; // replace state by encoded version unless in debug mode
489 580
490 debug_add("state is "+state); // this should still be in plain text
491 getQE("$appletName"+"_state").value = state; //place state in input item (debug: textarea, otherwise: hidden)
492 } catch (e) {
493 alert("Error in getting state for $appletName " + e );
494 }
495 };
496
497 ////////////////////////////////////////////////////////////
498 //
499 //INITIALIZE
500 //
501 ////////////////////////////////////////////////////////////
502
503
504 applet_checkLoaded_list["$appletName"] = function() { // this function returns 0 unless:
505 // applet has already been flagged as ready in applet_isReady_list
506 // applet.config is defined (or alias for .config)
507 // applet.setState is defined
508 // applet.isActive is defined
509 // applet reported that it is loaded by calling loadQ()
510 var ready = 0;
511 var applet = getApplet("$appletName");
512 if (!debug && applet_isReady_list["$appletName"]) {return(1)}; // memorize readiness in non-debug mode
513 if ( typeof(applet.$config) == "function") {
514 debug_add( "applet.config is " + typeof(applet.$config) );
515 ready = 1;
516 }
517 if( typeof(applet.$getState) == "function") {
518 debug_add( "applet.getState is " + typeof(applet.$getState) );
519 ready =1;
520 }
521 if (typeof(applet.isActive) == "function" && applet.isActive ) {
522 debug_add( "applet.isActive is " + typeof(applet.isActive) );
523 ready =1;
524 }
525 if (typeof(applet_reportsLoaded_list["$appletName"]) !="undefined" && applet_reportsLoaded_list["$appletName"] != 0 ) {
526 debug_add( "applet reports that it is loaded " + applet_reportsLoaded_list["$appletName"] );
527 ready =1;
528 }
529 applet_isReady_list["$appletName"]= ready;
530 return(ready);
531 }
532
533 applet_initializeAction_list["$appletName"] = function (state) {
534 applet_setState_list["$appletName"](state);
535 };
536
537 applet_submitAction_list["$appletName"] = function () {
538 if (! applet_isReady_list["$appletName"] ) {
539 alert("$appletName is not ready");
540 }
541 applet_getState_list["$appletName"]();
542 $submitActionScript
543 //getQE("$returnFieldName").value = getApplet("$appletName").sendData(); //FIXME -- not needed in general?
544 };
545 </script> 581 </script>
546 582
547END_HEADER_SCRIPT 583END_HEADER_SCRIPT
548 584
549package FlashApplet; 585package FlashApplet;
571 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 607 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
572 id="$appletName" width="500" height="375" 608 id="$appletName" width="500" height="375"
573 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"> 609 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
574 <param name="movie" value="$codebase/$appletName.swf" /> 610 <param name="movie" value="$codebase/$appletName.swf" />
575 <param name="quality" value="high" /> 611 <param name="quality" value="high" />
576 <param name="bgcolor" value="#869ca7" /> 612 <param name="bgcolor" value="$applet_bgcolor" />
577 <param name="allowScriptAccess" value="sameDomain" /> 613 <param name="allowScriptAccess" value="sameDomain" />
578 <embed src="$codebase/$appletName.swf" quality="high" bgcolor="#869ca7" 614 <embed src="$codebase/$appletName.swf" quality="high" bgcolor="$applet_bgcolor"
579 width="$width" height="$height" name="$appletName" align="middle" id="$appletName" 615 width="$width" height="$height" name="$appletName" align="middle" id="$appletName"
580 play="true" loop="false" quality="high" allowScriptAccess="sameDomain" 616 play="true" loop="false" quality="high" allowScriptAccess="sameDomain"
581 type="application/x-shockwave-flash" 617 type="application/x-shockwave-flash"
582 pluginspage="http://www.macromedia.com/go/getflashplayer"> 618 pluginspage="http://www.macromedia.com/go/getflashplayer">
583 </embed> 619 </embed>
593 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 629 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
594 id="$appletName" width="500" height="375" 630 id="$appletName" width="500" height="375"
595 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"> 631 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
596 <param name="movie" value="$codebase/$appletName.swf" /> 632 <param name="movie" value="$codebase/$appletName.swf" />
597 <param name="quality" value="high" /> 633 <param name="quality" value="high" />
598 <param name="bgcolor" value="#869ca7" /> 634 <param name="bgcolor" value="$applet_bgcolor" />
599 <param name="allowScriptAccess" value="sameDomain" /> 635 <param name="allowScriptAccess" value="sameDomain" />
600 <param name="FlashVars" value="$flashParameters"/> 636 <param name="FlashVars" value="$flashParameters"/>
601 <embed src="$codebase/$appletName.swf" quality="high" bgcolor="#869ca7" 637 <embed src="$codebase/$appletName.swf" quality="high" bgcolor="$applet_bgcolor"
602 width="$width" height="$height" name="$appletName" align="middle" id="$appletName" 638 width="$width" height="$height" name="$appletName" align="middle" id="$appletName"
603 play="true" loop="false" quality="high" allowScriptAccess="sameDomain" 639 play="true" loop="false" quality="high" allowScriptAccess="sameDomain"
604 type="application/x-shockwave-flash" 640 type="application/x-shockwave-flash"
605 pluginspage="http://www.macromedia.com/go/getflashplayer" 641 pluginspage="http://www.macromedia.com/go/getflashplayer"
606 FlashVars="$flashParameters"> 642 FlashVars="$flashParameters">
663 archive = "$archive" 699 archive = "$archive"
664 name = "$appletName" 700 name = "$appletName"
665 id = "$appletName" 701 id = "$appletName"
666 width = "$width" 702 width = "$width"
667 height = "$height" 703 height = "$height"
704 bgcolor = "$applet_bgcolor"
668 MAYSCRIPT 705 MAYSCRIPT
669 > 706 >
670 $javaParameters 707 $javaParameters
671 708
672 Sorry, the Applet could not be started. Please make sure that 709 Sorry, the Applet could not be started. Please make sure that

Legend:
Removed from v.5984  
changed lines
  Added in v.6023

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9