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.6 2008/03/25 21:59:06 gage Exp $ |
4 | # $CVSHeader: pg/lib/Applet.pm,v 1.14 2009/01/28 17:07:08 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. |
… | |
… | |
35 | ################################### |
35 | ################################### |
36 | # Configure applet |
36 | # Configure applet |
37 | ################################### |
37 | ################################### |
38 | |
38 | |
39 | #xml data to set up the problem-rac |
39 | #xml data to set up the problem-rac |
40 | $applet->state(qq{<XML> |
40 | $applet->config(qq{<XML> |
41 | <point xval='$xval_1' yval='$yval_1' /> |
41 | <point xval='$xval_1' yval='$yval_1' /> |
42 | <point xval='$xval_2' yval='$yval_2' /> |
42 | <point xval='$xval_2' yval='$yval_2' /> |
43 | </XML>}); |
43 | </XML>}); |
44 | |
44 | |
45 | |
45 | |
… | |
… | |
99 | use MIME::Base64 qw( encode_base64 decode_base64); |
99 | use MIME::Base64 qw( encode_base64 decode_base64); |
100 | |
100 | |
101 | |
101 | |
102 | =head2 Default javaScript functions placed in header |
102 | =head2 Default javaScript functions placed in header |
103 | |
103 | |
|
|
104 | =pod |
|
|
105 | |
104 | These functions are automatically defined for use for |
106 | These functions are automatically defined for use for |
105 | any javaScript placed in the text of a PG question. |
107 | any javaScript placed in the text of a PG question. |
106 | |
108 | |
107 | getApplet(appletName) -- finds the applet path in the DOM |
109 | getApplet(appletName) -- finds the applet path in the DOM |
108 | |
110 | |
109 | submitAction() -- calls the submit action of the applets |
111 | submitAction() -- calls the submit action of the applets |
110 | |
|
|
111 | |
112 | |
112 | initializeAction() -- calls the initialize action of the applets |
113 | initializeWWquestion() -- calls the initialize action of the applets |
113 | |
114 | |
114 | getQE(name) -- gets an HTML element of the question by name |
115 | getQE(name) -- gets an HTML element of the question by name |
115 | or by id. Be sure to keep all names and ids |
116 | or by id. Be sure to keep all names and ids |
116 | unique within a given PG question. |
117 | unique within a given PG question. |
117 | |
118 | |
118 | getQuestionElement(name) -- long form of getQE(name) |
119 | getQuestionElement(name) -- long form of getQE(name) |
119 | |
120 | |
120 | listQuestionElements() -- for discovering the names of inputs in the |
121 | listQuestionElements() -- for discovering the names of inputs in the |
121 | PG question. An alert dialog will list all |
122 | PG question. An alert dialog will list all |
122 | of the elements. |
123 | of the elements. |
123 | Usage: Place this at the END of the question, |
124 | Usage: Place this at the END of the question, just before END_DOCUMENT(): |
124 | 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 |
|
|
129 | |
|
|
130 | List of accessor methods made available by the FlashApplet class: |
|
|
131 | Usage: $current_value = $applet->method(new_value or empty) |
|
|
132 | These can also be set when creating the class -- for exampe: |
|
|
133 | $applet = new FlashApplet( |
|
|
134 | # can be replaced by $applet =FlashApplet() when using AppletObjects.pl |
|
|
135 | codebase => findAppletCodebase("$appletName.swf"), |
|
|
136 | appletName => $appletName, |
|
|
137 | appletId => $appletName, |
|
|
138 | submitActionAlias => 'checkAnswer', |
|
|
139 | ); |
128 | |
140 | |
129 | list of accessor methods format: current_value = $self->method(new_value or empty) |
|
|
130 | |
141 | |
131 | appletId for simplicity and reliability appletId and appletName are always the same |
142 | appletId for simplicity and reliability appletId and appletName are always the same |
132 | appletName |
143 | appletName |
133 | |
|
|
134 | archive the name of the .jar file containing the applet code |
144 | archive the name of the .jar file containing the applet code |
135 | code the name of the applet code in the .jar archive |
145 | code the name of the applet code in the .jar archive |
136 | codebase a prefix url used to find the archive and the applet itself |
146 | codebase a prefix url used to find the archive and the applet itself |
137 | |
147 | |
138 | height rectangle alloted in the html page for displaying the applet |
148 | height rectangle alloted in the html page for displaying the applet |
139 | width |
149 | |
140 | |
|
|
141 | params an anonymous array containing name/value pairs |
150 | params an anonymous array containing name/value pairs |
142 | to configure the applet [name =>'value, ...] |
151 | to configure the applet [name =>'value, ...] |
143 | |
152 | |
144 | header stores the text to be added to the header section of the html page |
153 | header stores the text to be added to the header section of the html page |
145 | object stores the text which places the applet on the html page |
154 | object stores the text which places the applet on the html page |
146 | |
155 | |
147 | debug in debug mode several alerts mark progress through the procedure of calling the applet |
156 | debug in debug mode several alerts mark progress through the procedure of calling the applet |
148 | |
157 | |
149 | config configuration are those customizable attributes of the applet which don't |
158 | config configuration are those customizable attributes of the applet which don't |
150 | change as it is used. When stored in hidden answer fields |
159 | change as it is used. When stored in hidden answer fields |
151 | it is usually stored in base64 encoded format. |
160 | it is usually stored in base64 encoded format. |
152 | base64_config base64 encode version of the contents of config |
161 | base64_config base64 encode version of the contents of config |
153 | |
162 | |
154 | configAlias (default: config ) names the applet command called with the contents of $self->config |
163 | configAlias (default: config ) names the applet command called with the contents of $self->config |
155 | to configure the applet. The parameters are passed to the applet in plain text using <xml> |
164 | to configure the applet. The parameters are passed to the applet in plain text using <xml> |
156 | The outer tags must be <xml> ..... </xml> |
165 | The outer tags must be <xml> ..... </xml> |
157 | state state consists of those customizable attributes of the applet which change |
166 | state state consists of those customizable attributes of the applet which change |
158 | as the applet is used. It is stored by the calling .pg question so that |
167 | as the applet is used. It is stored by the calling .pg question so that |
159 | when revisiting the question the applet |
168 | when revisiting the question the applet |
160 | will be restored to the same state it was left in when the question was last |
169 | will be restored to the same state it was left in when the question was last |
161 | viewed. |
170 | viewed. |
162 | |
171 | |
163 | getStateAlias (default: getState) alias for command called to read the current state of the applet. |
172 | getStateAlias (default: getState) alias for command called to read the current state of the applet. |
164 | The state is passed in plain text xml format with outer tags: <xml>....</xml> |
173 | The state is passed in plain text xml format with outer tags: <xml>....</xml> |
165 | setStateAlias (default: setState) alias for the command called to reset the state of the applet. |
174 | setStateAlias (default: setState) alias for the command called to reset the state of the applet. |
166 | The state is passed in plain text in xml format with outer tags: <xml>....</xml> |
175 | The state is passed in plain text in xml format with outer tags: <xml>....</xml> |
167 | |
176 | |
168 | base64_state returns the base64 encoded version of the state stored in the applet object. |
177 | base64_state returns the base64 encoded version of the state stored in the applet object. |
169 | |
178 | |
170 | initializeActionAlias -- (default: initializeAction) the name of the javaScript subroutine called to initialize the applet (some overlap with config/ and setState |
179 | initializeActionAlias -- (default: initializeAction) the name of the javaScript subroutine called to initialize the applet (some overlap with config/ and setState |
171 | submitActionAlias -- (default: submitAction)the name of the javaScript subroutine called when the submit button of the |
180 | submitActionAlias -- (default: submitAction)the name of the javaScript subroutine called when the submit button of the |
172 | .pg question is pressed. |
181 | .pg question is pressed. |
|
|
182 | answerBox -- name of answer box to return answer to: default defaultAnswerBox |
|
|
183 | getAnswer -- (formerly sendData) get student answer from applet and place in answerBox |
|
|
184 | returnFieldName -- (deprecated) synonmym for answerBox |
173 | |
185 | |
174 | returnFieldName |
|
|
175 | |
|
|
176 | |
|
|
177 | |
|
|
178 | |
|
|
179 | |
186 | |
180 | =cut |
187 | =cut |
181 | |
188 | |
182 | |
189 | |
183 | |
190 | |
… | |
… | |
190 | codebase=>'', |
197 | codebase=>'', |
191 | # appletId =>'', #always use identical applet Id's and applet Names |
198 | # appletId =>'', #always use identical applet Id's and applet Names |
192 | params =>undef, |
199 | params =>undef, |
193 | width => 550, |
200 | width => 550, |
194 | height => 400, |
201 | height => 400, |
195 | base64_state => '', |
202 | base64_state => undef, # this is an state to use for initializing the first occurence of the question. |
196 | base64_config => '', |
203 | base64_config => undef, # this is the initial (and final?) configuration |
197 | getStateAlias => 'getXML', |
204 | getStateAlias => 'getXML', |
198 | setStateAlias => 'setState', |
205 | setStateAlias => 'setXML', |
199 | configAlias => 'config', |
206 | configAlias => 'config', |
200 | initializeActionAlias => 'setXML', |
207 | initializeActionAlias => 'setXML', |
201 | submitActionAlias => 'getXML', |
208 | submitActionAlias => 'getXML', |
202 | returnFieldName => 'receivedField', |
209 | submitActionScript => '', # script executed on submitting the WW question |
|
|
210 | answerBox => 'answerBox', |
203 | headerText => DEFAULT_HEADER_TEXT(), |
211 | headerText => DEFAULT_HEADER_TEXT(), |
204 | objectText => '', |
212 | objectText => '', |
205 | debug => 0, |
213 | debug => 0, |
206 | @_, |
214 | @_, |
207 | }; |
215 | }; |
208 | bless $self, $class; |
216 | bless $self, $class; |
|
|
217 | $self->state('<xml></xml>'); |
|
|
218 | $self->config('<xml></xml>'); |
209 | return $self; |
219 | return $self; |
210 | } |
220 | } |
211 | |
221 | |
212 | sub header { |
222 | sub header { |
213 | my $self = shift; |
223 | my $self = shift; |
… | |
… | |
248 | sub submitActionAlias { |
258 | sub submitActionAlias { |
249 | my $self = shift; |
259 | my $self = shift; |
250 | $self->{submitActionAlias} = shift ||$self->{submitActionAlias}; # replace the current contents if non-empty |
260 | $self->{submitActionAlias} = shift ||$self->{submitActionAlias}; # replace the current contents if non-empty |
251 | $self->{submitActionAlias}; |
261 | $self->{submitActionAlias}; |
252 | } |
262 | } |
|
|
263 | sub submitActionScript { |
|
|
264 | my $self = shift; |
|
|
265 | $self->{submitActionScript} = shift ||$self->{submitActionScript}; # replace the current contents if non-empty |
|
|
266 | $self->{submitActionScript}; |
|
|
267 | } |
253 | sub getStateAlias { |
268 | sub getStateAlias { |
254 | my $self = shift; |
269 | my $self = shift; |
255 | $self->{getStateAlias} = shift ||$self->{getStateAlias}; # replace the current contents if non-empty |
270 | $self->{getStateAlias} = shift ||$self->{getStateAlias}; # replace the current contents if non-empty |
256 | $self->{getStateAlias}; |
271 | $self->{getStateAlias}; |
257 | } |
272 | } |
… | |
… | |
266 | $self->{configAlias} = shift ||$self->{configAlias}; # replace the current contents if non-empty |
281 | $self->{configAlias} = shift ||$self->{configAlias}; # replace the current contents if non-empty |
267 | $self->{configAlias}; |
282 | $self->{configAlias}; |
268 | } |
283 | } |
269 | sub returnFieldName { |
284 | sub returnFieldName { |
270 | my $self = shift; |
285 | my $self = shift; |
271 | $self->{returnFieldName} = shift ||$self->{returnFieldName}; # replace the current contents if non-empty |
286 | $self->{answerBox} = shift ||$self->{answerBox}; # replace the current contents if non-empty |
272 | $self->{returnFieldName}; |
287 | $self->{answerBox}; |
|
|
288 | } |
|
|
289 | sub answerBox { |
|
|
290 | my $self = shift; |
|
|
291 | $self->{answerBox} = shift ||$self->{answerBox}; # replace the current contents if non-empty |
|
|
292 | $self->{answerBox}; |
273 | } |
293 | } |
274 | sub codebase { |
294 | sub codebase { |
275 | my $self = shift; |
295 | my $self = shift; |
276 | $self->{codebase} = shift ||$self->{codebase}; # replace the current codebase if non-empty |
296 | $self->{codebase} = shift ||$self->{codebase}; # replace the current codebase if non-empty |
277 | $self->{codebase}; |
297 | $self->{codebase}; |
… | |
… | |
345 | my $appletId = $self->appletId; |
365 | my $appletId = $self->appletId; |
346 | my $appletName = $self->appletName; |
366 | my $appletName = $self->appletName; |
347 | my $base64_initialState = $self->base64_state; |
367 | my $base64_initialState = $self->base64_state; |
348 | my $initializeAction = $self->initializeActionAlias; |
368 | my $initializeAction = $self->initializeActionAlias; |
349 | my $submitAction = $self->submitActionAlias; |
369 | my $submitAction = $self->submitActionAlias; |
|
|
370 | my $submitActionScript = $self->submitActionScript; |
350 | my $setState = $self->setStateAlias; |
371 | my $setState = $self->setStateAlias; |
351 | my $getState = $self->getStateAlias; |
372 | my $getState = $self->getStateAlias; |
352 | my $config = $self->configAlias; |
373 | my $config = $self->configAlias; |
353 | my $base64_config = $self->base64_config; |
374 | my $base64_config = $self->base64_config; |
354 | my $debugMode = ($self->debug) ? "1": "0"; |
375 | my $debugMode = ($self->debug) ? "1": "0"; |
355 | my $returnFieldName = $self->{returnFieldName}; |
376 | my $returnFieldName = $self->{returnFieldName}; |
356 | # my $encodeStateQ = ($self->debug)?'' : "state = Base64.encode(state);"; # in debug mode base64 encoding is not used. |
377 | my $answerBox = $self->{answerBox}; |
357 | # my $decodeStateQ = "if (!state.match(/<XML>*/i) ) {state = Base64.decode(state)}"; # decode if <XML> is not present |
|
|
358 | my $headerText = $self->header(); |
378 | my $headerText = $self->header(); |
359 | |
379 | |
360 | $headerText =~ s/(\$\w+)/$1/gee; # interpolate variables p17 of Cookbook |
380 | $headerText =~ s/(\$\w+)/$1/gee; # interpolate variables p17 of Cookbook |
361 | |
381 | |
362 | return $headerText; |
382 | return $headerText; |
… | |
… | |
385 | |
405 | |
386 | $objectText = $self->{objectText}; |
406 | $objectText = $self->{objectText}; |
387 | $objectText =~ s/(\$\w+)/$1/gee; |
407 | $objectText =~ s/(\$\w+)/$1/gee; |
388 | return $objectText; |
408 | return $objectText; |
389 | } |
409 | } |
390 | sub initialize { |
410 | # sub initialize { |
391 | my $self = shift; |
411 | # my $self = shift; |
392 | return q{ |
412 | # return q{ |
393 | <script> |
413 | # <script> |
394 | initializeAction(); |
414 | # initializeAllApplets(); |
395 | // this should really be done in the <body> tag |
415 | # // this should really be done in the <body> tag |
396 | </script> |
416 | # </script> |
397 | }; |
417 | # }; |
398 | |
418 | # |
399 | } |
419 | # } |
400 | |
420 | ######################################################## |
|
|
421 | # HEADER material for one flash or java applet |
|
|
422 | ######################################################## |
401 | |
423 | |
402 | use constant DEFAULT_HEADER_TEXT =><<'END_HEADER_SCRIPT'; |
424 | use constant DEFAULT_HEADER_TEXT =><<'END_HEADER_SCRIPT'; |
403 | |
425 | <script src="/webwork2_files/js/Base64.js" language="javascript"> |
|
|
426 | </script> |
|
|
427 | <script src="/webwork2_files/js/ww_applet_support.js"> |
|
|
428 | //upload functions stored in /opt/webwork/webwork2/htdocs/js ... |
|
|
429 | </script> |
404 | <script language="JavaScript"> |
430 | <script language="JavaScript"> |
405 | var debug = $debugMode; |
431 | |
|
|
432 | // set debug mode for this applet |
|
|
433 | set_debug($debugMode); |
|
|
434 | |
|
|
435 | ////////////////////////////////////////////////////////// |
|
|
436 | //TEST code |
406 | // |
437 | // |
|
|
438 | // |
|
|
439 | ////////////////////////////////////////////////////////// |
|
|
440 | |
|
|
441 | ww_applet_list["$appletName"] = new ww_applet("$appletName"); |
|
|
442 | |
|
|
443 | |
|
|
444 | ww_applet_list["$appletName"].code = "$code"; |
|
|
445 | ww_applet_list["$appletName"].codebase = "$codebase"; |
|
|
446 | ww_applet_list["$appletName"].appletID = "$appletID"; |
|
|
447 | ww_applet_list["$appletName"].base64_state = "$base64_initializationState"; |
|
|
448 | ww_applet_list["$appletName"].base64_config = "$base64_config"; |
|
|
449 | ww_applet_list["$appletName"].getStateAlias = "$getState"; |
|
|
450 | ww_applet_list["$appletName"].setStateAlias = "$setState"; |
|
|
451 | ww_applet_list["$appletName"].configAlias = "$config"; |
|
|
452 | ww_applet_list["$appletName"].initializeActionAlias = "$initializeAction"; |
|
|
453 | ww_applet_list["$appletName"].submitActionAlias = "$submitAction"; |
|
|
454 | ww_applet_list["$appletName"].submitActionScript = "$submitActionScript"; |
|
|
455 | ww_applet_list["$appletName"].answerBox = "$answerBox"; |
|
|
456 | ww_applet_list["$appletName"].debug = "$debugMode"; |
|
|
457 | |
|
|
458 | |
|
|
459 | ////////////////////////////////////////////////////////// |
407 | //CONFIGURATIONS |
460 | //CONFIGURATIONS |
408 | // |
461 | // |
409 | // configurations are "permanent" |
462 | // configurations are "permanent" |
|
|
463 | ////////////////////////////////////////////////////////// |
|
|
464 | |
410 | applet_config_list["$appletName"] = function() { |
465 | // applet_config_list["$appletName"] = function() { |
411 | if (debug) { alert("configure $appletName . $config ( $base64_config )");} |
466 | // debug_add("applet_config_list:\n attempt to configure $appletName . $config ( $base64_config ) if config function is defined: " |
|
|
467 | // ); |
412 | try { |
468 | // try { |
413 | if (debug || !( typeof(getApplet("$appletName").$config) == "undefined" ) ) { |
469 | // if (( typeof(getApplet("$appletName").$config) == "function" ) ) { |
414 | |
470 | // debug_add("CONFIGURE $appletName"); |
415 | getApplet("$appletName").$config(Base64.decode("$base64_config")); |
471 | // getApplet("$appletName").$config(Base64.decode("$base64_config")); |
416 | } |
472 | // } |
417 | } catch(e) { |
473 | // } catch(e) { |
418 | alert("error executing configuration command $config for $appletName: " + e ); |
474 | // alert("Error executing configuration command $config for $appletName: " + e ); |
419 | } |
475 | // } |
420 | } |
476 | // } |
421 | // |
477 | // //////////////////////////////////////////////////////////// |
|
|
478 | // // |
422 | //STATE |
479 | // //STATE: |
423 | // |
480 | // // state can vary as the applet is manipulated -- it is reset from the questions _state values |
424 | // state can vary as the applet is manipulated. |
481 | // // |
|
|
482 | // ////////////////////////////////////////////////////////// |
|
|
483 | // |
425 | applet_setState_list["$appletName"] = function(state) { |
484 | // applet_setState_list["$appletName"] = function(state) { |
|
|
485 | // debug_add("Begin setState for applet $appletName"); |
|
|
486 | // debug_add("Obtain state from $appletName"+"_state"); |
426 | state = state || getQE("$appletName"+"_state").value |
487 | // state = state || getQE("$appletName"+"_state").value; |
427 | if (state.match("\S") ) { // if state is not all white space |
|
|
428 | if ( base64Q(state) ) { |
488 | // if ( base64Q(state) ) { |
429 | state=Base64.decode(state); |
489 | // state=Base64.decode(state); |
430 | } |
490 | // } |
431 | if (debug) { alert("set state for $appletName to " + state);} |
491 | // if (state.match(/<xml/i) || state.match(/<?xml/i) ) { // if state starts with <?xml |
432 | try { |
492 | // |
|
|
493 | // debug_add("applet_setState_list: \n set (decoded) state for $appletName to " + |
|
|
494 | // state +"\nfunction type is " +typeof(getApplet("$appletName").$setState) |
|
|
495 | // ); |
|
|
496 | // try { |
433 | if (debug || !( typeof(getApplet("$appletName").$setState) =="undefined" ) ) { |
497 | // if (( typeof(getApplet("$appletName").$setState) =="function" ) ) { |
|
|
498 | // debug_add("setState for $appletName"); |
434 | getApplet("$appletName").$setState( state ); |
499 | // getApplet("$appletName").$setState( state ); |
435 | } |
500 | // } |
436 | } catch(e) { |
501 | // } catch(e) { |
437 | alert("Error in setting state of $appletName using command $setState : " + e ); |
502 | // alert("Error in setting state of $appletName using command $setState : " + e ); |
438 | } |
503 | // } |
439 | } |
504 | // } else if (debug) { |
440 | }; |
505 | // alert("new state was empty string or did not begin with <xml-- state was not reset"); |
|
|
506 | // } |
|
|
507 | // }; |
441 | applet_getState_list["$appletName"] = function () { |
508 | // applet_getState_list["$appletName"] = function () { |
442 | if (debug) { alert("getState for applet $appletName");} |
509 | // debug_add("get current state for applet $appletName and store it in $appletName"+"_state"); |
443 | try { |
|
|
444 | var applet = getApplet("$appletName"); |
510 | // var applet = getApplet("$appletName"); |
445 | var state; |
511 | // try { |
446 | if (!( typeof(getApplet("$appletName").$getState) =="undefined" ) ) { |
512 | // if (( typeof(applet.$getState) == "function" ) ) { // there may be no state function |
447 | state = applet.$getState(); // get state in xml format |
513 | // state = applet.$getState(); // get state in xml format |
448 | } |
514 | // debug_add("state has type " + typeof(state)); |
449 | if (!debug) {state = Base64.encode(state) }; // replace state by encoded version |
515 | // state = String(state); // geogebra returned an object type instead of a string type |
|
|
516 | // debug_add("state converted to type " + typeof(state)); |
|
|
517 | // } |
|
|
518 | // |
|
|
519 | // if (!debug) { |
|
|
520 | // state = Base64.encode(state); |
|
|
521 | // }; // replace state by encoded version unless in debug mode |
|
|
522 | // |
|
|
523 | // debug_add("state is "+state); // this should still be in plain text |
450 | getQE("$appletName"+"_state").value = state; //place in state htmlItem (debug: textarea, otherwise hidden) |
524 | // getQE("$appletName"+"_state").value = state; //place state in input item (debug: textarea, otherwise: hidden) |
451 | } catch (e) { |
525 | // } catch (e) { |
452 | alert("Error in getting state for $appletName " + e ); |
526 | // alert("Error in getting state for $appletName " + e ); |
453 | } |
527 | // } |
454 | }; |
528 | // }; |
455 | // |
529 | // |
|
|
530 | // //////////////////////////////////////////////////////////// |
|
|
531 | // // |
456 | //INITIALIZE |
532 | // //INITIALIZE |
457 | // |
533 | // // |
|
|
534 | // //////////////////////////////////////////////////////////// |
|
|
535 | // |
|
|
536 | // |
|
|
537 | // applet_checkLoaded_list["$appletName"] = function() { // this function returns 0 unless: |
|
|
538 | // // applet has already been flagged as ready in applet_isReady_list |
|
|
539 | // // applet.config is defined (or alias for .config) |
|
|
540 | // // applet.setState is defined |
|
|
541 | // // applet.isActive is defined |
|
|
542 | // // applet reported that it is loaded by calling loadQ() |
|
|
543 | // var ready = 0; |
|
|
544 | // var applet = getApplet("$appletName"); |
|
|
545 | // if (!debug && applet_isReady_list["$appletName"]) {return(1)}; // memorize readiness in non-debug mode |
|
|
546 | // if ( typeof(applet.$config) == "function") { |
|
|
547 | // debug_add( "applet.config is " + typeof(applet.$config) ); |
|
|
548 | // ready = 1; |
|
|
549 | // } |
|
|
550 | // if( typeof(applet.$getState) == "function") { |
|
|
551 | // debug_add( "applet.getState is " + typeof(applet.$getState) ); |
|
|
552 | // ready =1; |
|
|
553 | // } |
|
|
554 | // if (typeof(applet.isActive) == "function" && applet.isActive ) { |
|
|
555 | // debug_add( "applet.isActive is " + typeof(applet.isActive) ); |
|
|
556 | // ready =1; |
|
|
557 | // } |
|
|
558 | // if (typeof(applet_reportsLoaded_list["$appletName"]) !="undefined" && applet_reportsLoaded_list["$appletName"] != 0 ) { |
|
|
559 | // debug_add( "applet reports that it is loaded " + applet_reportsLoaded_list["$appletName"] ); |
|
|
560 | // ready =1; |
|
|
561 | // } |
|
|
562 | // applet_isReady_list["$appletName"]= ready; |
|
|
563 | // return(ready); |
|
|
564 | // } |
|
|
565 | // |
458 | applet_initializeAction_list["$appletName"] = function () { |
566 | // applet_initializeAction_list["$appletName"] = function (state) { |
459 | applet_setState_list["$appletName"](); |
567 | // applet_setState_list["$appletName"](state); |
460 | }; |
568 | // }; |
461 | |
569 | // |
462 | applet_submitAction_list["$appletName"] = function () { |
570 | // applet_submitAction_list["$appletName"] = function () { |
|
|
571 | // if (! applet_isReady_list["$appletName"] ) { |
|
|
572 | // alert("$appletName is not ready"); |
|
|
573 | // } |
463 | applet_getState_list["$appletName"](); |
574 | // applet_getState_list["$appletName"](); |
464 | getQE("$returnFieldName").value = getApplet("$appletName").sendData(); |
575 | // $submitActionScript |
|
|
576 | // //getQE("$answerBox").value = getApplet("$appletName").getAnswer(); //FIXME -- not needed in general? |
465 | }; |
577 | // }; |
466 | </script> |
578 | </script> |
467 | |
579 | |
468 | END_HEADER_SCRIPT |
580 | END_HEADER_SCRIPT |
469 | |
581 | |
470 | package FlashApplet; |
582 | package FlashApplet; |
471 | @ISA = qw(Applet); |
583 | @ISA = qw(Applet); |
472 | |
584 | |
473 | |
585 | |
|
|
586 | =head2 Insertion HTML code for FlashApplet |
474 | |
587 | |
475 | =pod |
588 | =pod |
476 | |
589 | |
477 | The secret to making this applet work with IE in addition to normal browsers |
590 | The secret to making this applet work with IE in addition to normal browsers |
478 | is the addition of the C(<form></form>) construct just before the object. |
591 | is the addition of the C(<form></form>) construct just before the object. |
… | |
… | |
539 | |
652 | |
540 | |
653 | |
541 | package JavaApplet; |
654 | package JavaApplet; |
542 | @ISA = qw(Applet); |
655 | @ISA = qw(Applet); |
543 | |
656 | |
544 | |
657 | =head2 Insertion HTML code for JavaApplet |
545 | |
658 | |
546 | =pod |
659 | =pod |
547 | |
660 | |
548 | The secret to making this applet work with IE in addition to normal browsers |
661 | The secret to making this applet work with IE in addition to normal browsers |
549 | is the addition of the C(<form></form>) construct just before the object. |
662 | is the addition of the C(<form></form>) construct just before the object. |
… | |
… | |
586 | width = "$width" |
699 | width = "$width" |
587 | height = "$height" |
700 | height = "$height" |
588 | MAYSCRIPT |
701 | MAYSCRIPT |
589 | > |
702 | > |
590 | $javaParameters |
703 | $javaParameters |
|
|
704 | |
|
|
705 | Sorry, the Applet could not be started. Please make sure that |
|
|
706 | Java 1.4.2 (or later) is installed and activated. |
|
|
707 | (<a href="http://java.sun.com/getjava">click here to install Java now</a>) |
591 | </applet> |
708 | </applet> |
592 | END_OBJECT_TEXT |
709 | END_OBJECT_TEXT |
593 | |
710 | |
594 | sub new { |
711 | sub new { |
595 | my $class = shift; |
712 | my $class = shift; |