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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6025 - (view) (download) (as text)

1 : gage 5574 ################################################################################
2 :     # WeBWorK Online Homework Delivery System
3 :     # Copyright 2000-2007 The WeBWorK Project, http://openwebwork.sf.net/
4 : gage 6025 # $CVSHeader: pg/lib/Applet.pm,v 1.19 2009/03/10 20:48:51 gage Exp $
5 : gage 5574 #
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
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.
10 :     #
11 :     # This program is distributed in the hope that it will be useful, but WITHOUT
12 :     # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 :     # FOR A PARTICULAR PURPOSE. See either the GNU General Public License or the
14 :     # Artistic License for more details.
15 :     ################################################################################
16 :    
17 :     =head1 NAME
18 :    
19 :     Applet.pl - Provides code for inserting FlashApplets and JavaApplets into webwork problems
20 :    
21 :     =head1 SYNPOSIS
22 :    
23 :     ###################################
24 :     # Create link to applet
25 :     ###################################
26 :     my $appletName = "LineThruPointsWW";
27 : gage 5594 $applet = new FlashApplet(
28 :     # can be replaced by $applet =FlashApplet() when using AppletObjects.pl
29 : gage 5574 codebase => findAppletCodebase("$appletName.swf"),
30 :     appletName => $appletName,
31 :     appletId => $appletName,
32 :     submitActionAlias => 'checkAnswer',
33 :     );
34 :    
35 :     ###################################
36 :     # Configure applet
37 :     ###################################
38 :    
39 :     #xml data to set up the problem-rac
40 : gage 5661 $applet->config(qq{<XML>
41 : gage 5574 <point xval='$xval_1' yval='$yval_1' />
42 :     <point xval='$xval_2' yval='$yval_2' />
43 :     </XML>});
44 :    
45 :    
46 :     ###################################
47 :     # insert applet header material
48 :     ###################################
49 :     HEADER_TEXT($applet->insertHeader );
50 :    
51 :     ###################################
52 :     # Text section
53 :     #
54 :    
55 :     ###################################
56 :     #insert applet into body
57 :     ###################################
58 :     TEXT( MODES(TeX=>'object code', HTML=>$applet->insertObject));
59 :    
60 :    
61 :     =head1 DESCRIPTION
62 :    
63 :     This file provides an object to store in one place
64 :     all of the information needed to call an applet.
65 :    
66 :     The object FlashApplet has defaults for inserting flash applets.
67 :    
68 :     =over
69 :    
70 :     =item *
71 :    
72 :     =item *
73 :    
74 :     =back
75 :    
76 :     (not yet completed)
77 :    
78 :     The module JavaApplet has defaults for inserting java applets.
79 :    
80 : gage 5619 The module Applet stores common code for the two types of applet.
81 : gage 5574
82 :     =head1 USAGE
83 :    
84 : gage 5619 These modules are activate by listing it in the modules section of global.conf and rebooting the server.
85 :     The companion file to this one is macros/AppletObjects.pl
86 : gage 5574
87 : gage 5619 qw(Applet FlashApplet JavaApplet)
88 :    
89 : gage 5574 =cut
90 :    
91 :    
92 :    
93 :     package Applet;
94 :    
95 : gage 5624 use URI::Escape;
96 : gage 5574
97 :    
98 :    
99 :     use MIME::Base64 qw( encode_base64 decode_base64);
100 :    
101 : gage 5594
102 :     =head2 Default javaScript functions placed in header
103 :    
104 : gage 5944 =pod
105 :    
106 : gage 5594 These functions are automatically defined for use for
107 :     any javaScript placed in the text of a PG question.
108 :    
109 : gage 5944 getApplet(appletName) -- finds the applet path in the DOM
110 : gage 5594
111 : gage 5944 submitAction() -- calls the submit action of the applets
112 :    
113 : gage 6021 initializeWWquestion() -- calls the initialize action of the applets
114 : gage 5594
115 :     getQE(name) -- gets an HTML element of the question by name
116 :     or by id. Be sure to keep all names and ids
117 :     unique within a given PG question.
118 : gage 5944
119 : gage 5594 getQuestionElement(name) -- long form of getQE(name)
120 : gage 5944
121 : gage 5594 listQuestionElements() -- for discovering the names of inputs in the
122 :     PG question. An alert dialog will list all
123 :     of the elements.
124 : gage 5944 Usage: Place this at the END of the question, just before END_DOCUMENT():
125 : gage 5594
126 : gage 5944 TEXT(qq!<script> listQuestionElements() </script>!);
127 :     ENDDOCUMENT();
128 :     to obtain a list of all of the HTML elements in the question
129 : gage 6021
130 :     ----------------------------------------------------------------------------
131 :    
132 :    
133 : gage 5944 List of accessor methods made available by the FlashApplet class:
134 :     Usage: $current_value = $applet->method(new_value or empty)
135 :     These can also be set when creating the class -- for exampe:
136 :     $applet = new FlashApplet(
137 :     # can be replaced by $applet =FlashApplet() when using AppletObjects.pl
138 :     codebase => findAppletCodebase("$appletName.swf"),
139 :     appletName => $appletName,
140 :     appletId => $appletName,
141 :     submitActionAlias => 'checkAnswer',
142 :     );
143 : gage 5594
144 :    
145 : gage 5944 appletId for simplicity and reliability appletId and appletName are always the same
146 :     appletName
147 :     archive the name of the .jar file containing the applet code
148 :     code the name of the applet code in the .jar archive
149 :     codebase a prefix url used to find the archive and the applet itself
150 :    
151 :     height rectangle alloted in the html page for displaying the applet
152 :    
153 :     params an anonymous array containing name/value pairs
154 :     to configure the applet [name =>'value, ...]
155 :    
156 :     header stores the text to be added to the header section of the html page
157 : gage 5619 object stores the text which places the applet on the html page
158 : gage 5594
159 : gage 5944 debug in debug mode several alerts mark progress through the procedure of calling the applet
160 :    
161 :     config configuration are those customizable attributes of the applet which don't
162 :     change as it is used. When stored in hidden answer fields
163 :     it is usually stored in base64 encoded format.
164 :     base64_config base64 encode version of the contents of config
165 :    
166 : gage 6021 configAlias (default: setConfig ) names the applet command called with the contents of $self->config
167 : gage 5944 to configure the applet. The parameters are passed to the applet in plain text using <xml>
168 :     The outer tags must be <xml> ..... </xml>
169 : gage 6021 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.
174 :     initialState the state consists of those customizable attributes of the applet which change
175 :     as the applet is used by the student. It is stored by the calling .pg question so that
176 :     when revisiting the question the applet will be restored to the same state it was left in when the question was last
177 : gage 5944 viewed.
178 :    
179 :     getStateAlias (default: getState) alias for command called to read the current state of the applet.
180 :     The state is passed in plain text xml format with outer tags: <xml>....</xml>
181 :     setStateAlias (default: setState) alias for the command called to reset the state of the applet.
182 :     The state is passed in plain text in xml format with outer tags: <xml>....</xml>
183 :    
184 :     base64_state returns the base64 encoded version of the state stored in the applet object.
185 :    
186 :     initializeActionAlias -- (default: initializeAction) the name of the javaScript subroutine called to initialize the applet (some overlap with config/ and setState
187 : gage 5619 submitActionAlias -- (default: submitAction)the name of the javaScript subroutine called when the submit button of the
188 :     .pg question is pressed.
189 : gage 5994 answerBox -- name of answer box to return answer to: default defaultAnswerBox
190 :     getAnswer -- (formerly sendData) get student answer from applet and place in answerBox
191 :     returnFieldName -- (deprecated) synonmym for answerBox
192 : gage 5594
193 : gage 5578
194 : gage 5583 =cut
195 :    
196 : gage 6021 =head4 More details
197 : gage 5574
198 : gage 6021 There are three different "images" of the applet. The first is the java or flash applet itself. The object that actually does the work.
199 :     The second is a perl image of the applet -- henceforth the perlApplet -- which is configured in the .pg file and allows a WeBWorK question
200 :     to communicate with the applet. The third image is a javaScript image of the applet -- henceforth the jsApplet which is a mirror of the perlApplet
201 :     but 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
202 :     the jsApplet as a runtime version of the perlApplet since it can be accessed and modified after the virtual HTML page has been created by
203 :     the PG rendering process.
204 : gage 5574
205 : gage 6021 The perlApplet is initialized by $newApplet = new flashApplet( appletName=>'myApplet',..... ); The jsApplet is automatically defined in
206 :     ww_applet_list["myApplet"] by copying the instance variables of $newApplet to a corresponding javaScript object. So $newApplet->{appletName}
207 :     corresponds to ww_applet_list["myApplet"].appletName. (This paragraph is not yet fully implemented :-().
208 : gage 5574
209 : gage 6021 Currently 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
210 :     to 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 :    
216 :     The 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
253 :    
254 : gage 5574 sub new {
255 :     my $class = shift;
256 :     my $self = {
257 :     appletName =>'',
258 : gage 5619 code=>'',
259 : gage 5574 codebase=>'',
260 : gage 5619 # appletId =>'', #always use identical applet Id's and applet Names
261 : gage 5574 params =>undef,
262 : gage 5619 width => 550,
263 :     height => 400,
264 : gage 6009 bgcolor => "#869ca7",
265 : gage 6021 base64_state => undef, # this is a state to use for initializing the first occurence of the question.
266 : gage 5661 base64_config => undef, # this is the initial (and final?) configuration
267 : gage 6021 # 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.)
269 : gage 5619 getStateAlias => 'getXML',
270 : gage 5625 setStateAlias => 'setXML',
271 : gage 6023 configAlias => '', # deprecated
272 : gage 6021 getConfigAlias => 'getConfig',
273 :     setConfigAlias => 'setConfig',
274 : gage 5619 initializeActionAlias => 'setXML',
275 :     submitActionAlias => 'getXML',
276 : gage 6023 submitActionScript => '', # script executed on submitting the WW question
277 :     answerBoxAlias => 'answerBox',
278 :     answerBox => '', # deprecated
279 :     returnFieldName => '', # deprecated
280 : gage 5619 headerText => DEFAULT_HEADER_TEXT(),
281 :     objectText => '',
282 :     debug => 0,
283 : gage 5574 @_,
284 :     };
285 :     bless $self, $class;
286 : gage 6021 $self->initialState('<xml></xml>');
287 : gage 6025 if ($self->{returnFieldName} or $self->{answerBox} ) { # backward compatibility
288 : gage 6023 warn "use answerBoxAlias instead of returnFieldName or answerBox";
289 :     $self->{answerBox}='';
290 :     $self->{returnFieldName}='';
291 :     }
292 : gage 6021 if ($self->{configAlias}) { # backward compatibility
293 :     warn "use setConfigAlias instead of configAlias";
294 :     $self->{configAlias}='';
295 :     }
296 : gage 5661 $self->config('<xml></xml>');
297 : gage 5574 return $self;
298 :     }
299 :    
300 :     sub header {
301 :     my $self = shift;
302 :     if ($_[0] eq "reset") { # $applet->header('reset'); erases default header text.
303 :     $self->{headerText}='';
304 :     } else {
305 :     $self->{headerText} .= join("",@_); # $applet->header(new_text); concatenates new_text to existing header.
306 :     }
307 :     $self->{headerText};
308 :     }
309 :     sub object {
310 :     my $self = shift;
311 :     if ($_[0] eq "reset") {
312 :     $self->{objectText}='';
313 :     } else {
314 :     $self->{objectText} .= join("",@_);
315 :     }
316 :     $self->{objectText};
317 :     }
318 :     sub params {
319 :     my $self = shift;
320 :     if (ref($_[0]) =~/HASH/) {
321 :     $self->{params} = shift;
322 : gage 5619 } elsif ( !defined($_[0]) or $_[0] =~ '') {
323 : gage 5574 # do nothing (read)
324 :     } else {
325 :     warn "You must enter a reference to a hash for the parameter list";
326 :     }
327 :     $self->{params};
328 :     }
329 :    
330 :     sub initializeActionAlias {
331 :     my $self = shift;
332 :     $self->{initializeActionAlias} = shift ||$self->{initializeActionAlias}; # replace the current contents if non-empty
333 :     $self->{initializeActionAlias};
334 :     }
335 :    
336 :     sub submitActionAlias {
337 :     my $self = shift;
338 :     $self->{submitActionAlias} = shift ||$self->{submitActionAlias}; # replace the current contents if non-empty
339 :     $self->{submitActionAlias};
340 :     }
341 : gage 5984 sub submitActionScript {
342 :     my $self = shift;
343 :     $self->{submitActionScript} = shift ||$self->{submitActionScript}; # replace the current contents if non-empty
344 :     $self->{submitActionScript};
345 :     }
346 : gage 5619 sub getStateAlias {
347 :     my $self = shift;
348 :     $self->{getStateAlias} = shift ||$self->{getStateAlias}; # replace the current contents if non-empty
349 :     $self->{getStateAlias};
350 :     }
351 :    
352 :     sub setStateAlias {
353 :     my $self = shift;
354 :     $self->{setStateAlias} = shift ||$self->{setStateAlias}; # replace the current contents if non-empty
355 :     $self->{setStateAlias};
356 :     }
357 :     sub configAlias {
358 :     my $self = shift;
359 : gage 6021 $self->{setConfigAlias} = shift ||$self->{setConfigAlias}; # replace the current contents if non-empty
360 :     $self->{setConfigAlias};
361 : gage 5619 }
362 : gage 6021 sub setConfigAlias {
363 : gage 5574 my $self = shift;
364 : gage 6021 $self->{setConfigAlias} = shift ||$self->{setConfigAlias}; # replace the current contents if non-empty
365 :     $self->{setConfigAlias};
366 : gage 5574 }
367 : gage 6021 sub getConfigAlias {
368 : gage 5994 my $self = shift;
369 : gage 6021 $self->{getConfigAlias} = shift ||$self->{getConfigAlias}; # replace the current contents if non-empty
370 :     $self->{getConfigAlias};
371 :     }
372 :    
373 :     sub answerBoxName {
374 :     my $self = shift;
375 : gage 5994 $self->{answerBox} = shift ||$self->{answerBox}; # replace the current contents if non-empty
376 :     $self->{answerBox};
377 :     }
378 : gage 5574 sub codebase {
379 :     my $self = shift;
380 :     $self->{codebase} = shift ||$self->{codebase}; # replace the current codebase if non-empty
381 :     $self->{codebase};
382 :     }
383 : gage 5619 sub code {
384 :     my $self = shift;
385 :     $self->{code} = shift ||$self->{code}; # replace the current code if non-empty
386 :     $self->{code};
387 :     }
388 :     sub height {
389 :     my $self = shift;
390 :     $self->{height} = shift ||$self->{height}; # replace the current height if non-empty
391 :     $self->{height};
392 :     }
393 :     sub width {
394 :     my $self = shift;
395 :     $self->{width} = shift ||$self->{width}; # replace the current width if non-empty
396 :     $self->{width};
397 :     }
398 : gage 6009 sub bgcolor {
399 :     my $self = shift;
400 :     $self->{bgcolor} = shift ||$self->{bgcolor}; # replace the current background color if non-empty
401 :     $self->{bgcolor};
402 :     }
403 : gage 5619 sub archive {
404 :     my $self = shift;
405 :     $self->{archive} = shift ||$self->{archive}; # replace the current archive if non-empty
406 :     $self->{archive};
407 :     }
408 : gage 5574 sub appletName {
409 :     my $self = shift;
410 :     $self->{appletName} = shift ||$self->{appletName}; # replace the current appletName if non-empty
411 :     $self->{appletName};
412 :     }
413 : gage 5619 sub debug {
414 : gage 5574 my $self = shift;
415 : gage 5619 my $new_flag = shift;
416 :     $self->{debug} = $new_flag if defined($new_flag);
417 :     $self->{debug};
418 : gage 5574 }
419 : gage 5619 sub appletId {
420 :     appletName(@_);
421 :     }
422 : gage 6021
423 :     sub 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 :    
430 :     sub 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 :     #######################
440 : gage 5619 sub state {
441 : gage 5574 my $self = shift;
442 :     my $str = shift;
443 : gage 5619 $self->{base64_state} = encode_base64($str) ||$self->{base64_state}; # replace the current string if non-empty
444 :     $self->{base64_state} =~ s/\n//g;
445 :     decode_base64($self->{base64_state});
446 : gage 5574 }
447 : gage 5619 sub base64_state{
448 : gage 5574 my $self = shift;
449 : gage 5619 $self->{base64_state} = shift ||$self->{base64_state}; # replace the current string if non-empty
450 :     $self->{base64_state};
451 : gage 5574 }
452 : gage 6021
453 : gage 5619 sub base64_config {
454 :     my $self = shift;
455 :     $self->{base64_config} = shift ||$self->{base64_config}; # replace the current string if non-empty
456 :     $self->{base64_config} =$self->{base64_config};
457 :     $self->{base64_config};
458 :     }
459 : gage 6021
460 :     sub returnFieldName {
461 :     my $self = shift;
462 :     warn "use answerBoxName instead of returnFieldName";
463 :     }
464 :     sub answerBox {
465 :     my $self = shift;
466 :     warn "use answerBoxName instead of AnswerBox";
467 :     }
468 :     #########################
469 : gage 5574 #FIXME
470 :     # need to be able to adjust header material
471 :    
472 :     sub insertHeader {
473 :     my $self = shift;
474 : gage 6013
475 : gage 6009 my $codebase = $self->codebase;
476 :     my $appletId = $self->appletId;
477 :     my $appletName = $self->appletName;
478 :     my $base64_initialState = $self->base64_state;
479 :     my $initializeAction = $self->initializeActionAlias;
480 :     my $submitActionAlias = $self->submitActionAlias;
481 :     my $submitActionScript = $self->submitActionScript;
482 :     my $setStateAlias = $self->setStateAlias;
483 :     my $getStateAlias = $self->getStateAlias;
484 : gage 6021
485 :     my $setConfigAlias = $self->setConfigAlias;
486 :     my $getConfigAlias = $self->getConfigAlias;
487 : gage 6009 my $base64_config = $self->base64_config;
488 :     my $debugMode = ($self->debug) ? "1": "0";
489 :     my $returnFieldName = $self->{returnFieldName};
490 :     my $answerBox = $self->{answerBox};
491 :     my $headerText = $self->header();
492 : gage 5622
493 : gage 6009
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
499 :    
500 : gage 5574 $headerText =~ s/(\$\w+)/$1/gee; # interpolate variables p17 of Cookbook
501 :    
502 :     return $headerText;
503 :    
504 :    
505 :     }
506 :    
507 :     sub insertObject {
508 : gage 5619 my $self = shift;
509 :     my $code = $self->{code};
510 :     my $codebase = $self->{codebase};
511 :     my $appletId = $self->{appletName};
512 : gage 5574 my $appletName = $self->{appletName};
513 : gage 5619 my $archive = $self->{archive};
514 :     my $width = $self->{width};
515 :     my $height = $self->{height};
516 : gage 6009 my $applet_bgcolor = $self->{bgcolor};
517 : gage 5624 my $javaParameters = '';
518 :     my $flashParameters = '';
519 : gage 5619 my %param_hash = %{$self->params()};
520 :     foreach my $key (keys %param_hash) {
521 : gage 5624 $javaParameters .= qq!<param name ="$key" value = "$param_hash{$key}">\n!;
522 :     $flashParameters .= uri_escape($key).'='.uri_escape($param_hash{$key}).'&';
523 : gage 5619 }
524 : gage 5624 $flashParameters =~ s/\&$//; # trim last &
525 : gage 5619
526 : gage 5624
527 : gage 5574 $objectText = $self->{objectText};
528 :     $objectText =~ s/(\$\w+)/$1/gee;
529 :     return $objectText;
530 :     }
531 : gage 5994 # sub initialize {
532 :     # my $self = shift;
533 :     # return q{
534 :     # <script>
535 :     # initializeAllApplets();
536 :     # // this should really be done in the <body> tag
537 :     # </script>
538 :     # };
539 :     #
540 :     # }
541 : gage 5661 ########################################################
542 :     # HEADER material for one flash or java applet
543 :     ########################################################
544 : gage 5574
545 : gage 5619 use constant DEFAULT_HEADER_TEXT =><<'END_HEADER_SCRIPT';
546 : gage 5994 <script src="/webwork2_files/js/Base64.js" language="javascript">
547 :     </script>
548 : gage 6009 <script src="/webwork2_files/js/ww_applet_support.js" language="javascript">
549 : gage 5994 //upload functions stored in /opt/webwork/webwork2/htdocs/js ...
550 : gage 6021
551 : gage 5994 </script>
552 : gage 5619 <script language="JavaScript">
553 : gage 5661
554 : gage 5662 // set debug mode for this applet
555 :     set_debug($debugMode);
556 : gage 5994
557 :     //////////////////////////////////////////////////////////
558 :     //TEST code
559 :     //
560 :     //
561 :     //////////////////////////////////////////////////////////
562 :    
563 :     ww_applet_list["$appletName"] = new ww_applet("$appletName");
564 :    
565 :    
566 :     ww_applet_list["$appletName"].code = "$code";
567 :     ww_applet_list["$appletName"].codebase = "$codebase";
568 :     ww_applet_list["$appletName"].appletID = "$appletID";
569 :     ww_applet_list["$appletName"].base64_state = "$base64_initializationState";
570 :     ww_applet_list["$appletName"].base64_config = "$base64_config";
571 : gage 6009 ww_applet_list["$appletName"].getStateAlias = "$getStateAlias";
572 :     ww_applet_list["$appletName"].setStateAlias = "$setStateAlias";
573 : gage 6021 ww_applet_list["$appletName"].setConfigAlias = "$setConfigAlias";
574 :     ww_applet_list["$appletName"].getConfigAlias = "$getConfigAlias";
575 : gage 5994 ww_applet_list["$appletName"].initializeActionAlias = "$initializeAction";
576 : gage 6009 ww_applet_list["$appletName"].submitActionAlias = "$submitActionAlias";
577 : gage 5994 ww_applet_list["$appletName"].submitActionScript = "$submitActionScript";
578 :     ww_applet_list["$appletName"].answerBox = "$answerBox";
579 :     ww_applet_list["$appletName"].debug = "$debugMode";
580 :    
581 : gage 5619 </script>
582 :    
583 :     END_HEADER_SCRIPT
584 :    
585 :     package FlashApplet;
586 :     @ISA = qw(Applet);
587 :    
588 :    
589 : gage 5944 =head2 Insertion HTML code for FlashApplet
590 : gage 5619
591 :     =pod
592 :    
593 :     The secret to making this applet work with IE in addition to normal browsers
594 :     is the addition of the C(<form></form>) construct just before the object.
595 :    
596 :     For some reason IE has trouble locating a flash object which is contained
597 :     within a form. Adding this second blank form with the larger problemMainForm
598 :     seems to solve the problem.
599 :    
600 :     This follows method2 of the advice given in url(http://kb.adobe.com/selfservice/viewContent.do?externalId=kb400730&sliceId=2)
601 :     Method1 and methods involving SWFObject(Geoff Stearns) and SWFFormFix (Steve Kamerman) have yet to be fully investigated:
602 :     http://devel.teratechnologies.net/swfformfix/swfobject_swfformfix_source.js
603 :     http://www.teratechnologies.net/stevekamerman/index.php?m=01&y=07&entry=entry070101-033933
604 :    
605 :     use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
606 :     <form></form>
607 :     <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
608 :     id="$appletName" width="500" height="375"
609 :     codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
610 :     <param name="movie" value="$codebase/$appletName.swf" />
611 :     <param name="quality" value="high" />
612 : gage 6009 <param name="bgcolor" value="$applet_bgcolor" />
613 : gage 5619 <param name="allowScriptAccess" value="sameDomain" />
614 : gage 6009 <embed src="$codebase/$appletName.swf" quality="high" bgcolor="$applet_bgcolor"
615 : gage 5619 width="$width" height="$height" name="$appletName" align="middle" id="$appletName"
616 :     play="true" loop="false" quality="high" allowScriptAccess="sameDomain"
617 :     type="application/x-shockwave-flash"
618 :     pluginspage="http://www.macromedia.com/go/getflashplayer">
619 :     </embed>
620 :    
621 :     </object>
622 :     END_OBJECT_TEXT
623 :    
624 :    
625 :     =cut
626 :    
627 :     use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
628 :     <form></form>
629 :     <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
630 :     id="$appletName" width="500" height="375"
631 :     codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
632 :     <param name="movie" value="$codebase/$appletName.swf" />
633 :     <param name="quality" value="high" />
634 : gage 6009 <param name="bgcolor" value="$applet_bgcolor" />
635 : gage 5619 <param name="allowScriptAccess" value="sameDomain" />
636 : gage 5624 <param name="FlashVars" value="$flashParameters"/>
637 : gage 6009 <embed src="$codebase/$appletName.swf" quality="high" bgcolor="$applet_bgcolor"
638 : gage 5619 width="$width" height="$height" name="$appletName" align="middle" id="$appletName"
639 :     play="true" loop="false" quality="high" allowScriptAccess="sameDomain"
640 :     type="application/x-shockwave-flash"
641 : gage 5624 pluginspage="http://www.macromedia.com/go/getflashplayer"
642 :     FlashVars="$flashParameters">
643 : gage 5619 </embed>
644 :    
645 :     </object>
646 :     END_OBJECT_TEXT
647 :    
648 :     sub new {
649 :     my $class = shift;
650 :     $class -> SUPER::new( objectText => DEFAULT_OBJECT_TEXT(),
651 :     @_
652 :     );
653 :    
654 :     }
655 :    
656 :    
657 :     package JavaApplet;
658 :     @ISA = qw(Applet);
659 :    
660 : gage 5944 =head2 Insertion HTML code for JavaApplet
661 : gage 5619
662 :     =pod
663 :    
664 :     The secret to making this applet work with IE in addition to normal browsers
665 :     is the addition of the C(<form></form>) construct just before the object.
666 :    
667 :     For some reason IE has trouble locating a flash object which is contained
668 :     within a form. Adding this second blank form with the larger problemMainForm
669 :     seems to solve the problem.
670 :    
671 :     This follows method2 of the advice given in url(http://kb.adobe.com/selfservice/viewContent.do?externalId=kb400730&sliceId=2)
672 :     Method1 and methods involving SWFObject(Geoff Stearns) and SWFFormFix (Steve Kamerman) have yet to be fully investigated:
673 :     http://devel.teratechnologies.net/swfformfix/swfobject_swfformfix_source.js
674 :     http://www.teratechnologies.net/stevekamerman/index.php?m=01&y=07&entry=entry070101-033933
675 :    
676 :     use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
677 :     <form></form>
678 :     <applet
679 :     code = "$code"
680 :     codebase = "$codebase"
681 :     archive = "$archive"
682 :     name = "$appletName"
683 :     id = "$appletName"
684 :     width = "$width"
685 :     height = "$height"
686 :     MAYSCRIPT
687 :     >
688 : gage 5624 $javaParameters
689 : gage 5619 </applet>
690 :     END_OBJECT_TEXT
691 :    
692 :     =cut
693 :    
694 :     use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
695 :     <form></form>
696 :     <applet
697 :     code = "$code"
698 :     codebase = "$codebase"
699 :     archive = "$archive"
700 :     name = "$appletName"
701 :     id = "$appletName"
702 :     width = "$width"
703 :     height = "$height"
704 : gage 6009 bgcolor = "$applet_bgcolor"
705 : gage 5619 MAYSCRIPT
706 :     >
707 : gage 5624 $javaParameters
708 : gage 5667
709 :     Sorry, the Applet could not be started. Please make sure that
710 :     Java 1.4.2 (or later) is installed and activated.
711 :     (<a href="http://java.sun.com/getjava">click here to install Java now</a>)
712 : gage 5619 </applet>
713 :     END_OBJECT_TEXT
714 :    
715 :     sub new {
716 :     my $class = shift;
717 :     $class -> SUPER::new( objectText => DEFAULT_OBJECT_TEXT(),
718 :     @_
719 :     );
720 :    
721 :     }
722 :    
723 :    
724 :    
725 : gage 5574 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9