[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 5984 - (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 5984 # $CVSHeader: pg/lib/Applet.pm,v 1.13 2008/11/19 04:39:43 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 5619 initializeAction() -- 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 :    
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 :     );
140 : gage 5594
141 :    
142 : gage 5944 appletId for simplicity and reliability appletId and appletName are always the same
143 :     appletName
144 :     archive the name of the .jar file containing the applet code
145 :     code the name of the applet code in the .jar archive
146 :     codebase a prefix url used to find the archive and the applet itself
147 :    
148 :     height rectangle alloted in the html page for displaying the applet
149 :    
150 :     params an anonymous array containing name/value pairs
151 :     to configure the applet [name =>'value, ...]
152 :    
153 :     header stores the text to be added to the header section of the html page
154 : gage 5619 object stores the text which places the applet on the html page
155 : gage 5594
156 : gage 5944 debug in debug mode several alerts mark progress through the procedure of calling the applet
157 :    
158 :     config configuration are those customizable attributes of the applet which don't
159 :     change as it is used. When stored in hidden answer fields
160 :     it is usually stored in base64 encoded format.
161 :     base64_config base64 encode version of the contents of config
162 :    
163 :     configAlias (default: config ) 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>
165 :     The outer tags must be <xml> ..... </xml>
166 :     state 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
168 :     when revisiting the question the applet
169 :     will be restored to the same state it was left in when the question was last
170 :     viewed.
171 :    
172 :     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>
174 :     setStateAlias (default: setState) alias for the command called to reset the state of the applet.
175 :     The state is passed in plain text in xml format with outer tags: <xml>....</xml>
176 :    
177 :     base64_state returns the base64 encoded version of the state stored in the applet object.
178 :    
179 :     initializeActionAlias -- (default: initializeAction) the name of the javaScript subroutine called to initialize the applet (some overlap with config/ and setState
180 : gage 5619 submitActionAlias -- (default: submitAction)the name of the javaScript subroutine called when the submit button of the
181 :     .pg question is pressed.
182 : gage 5594
183 : gage 5944 returnFieldName
184 : gage 5578
185 : gage 5574
186 : gage 5583 =cut
187 :    
188 : gage 5574
189 :    
190 :    
191 :     sub new {
192 :     my $class = shift;
193 :     my $self = {
194 :     appletName =>'',
195 : gage 5619 code=>'',
196 : gage 5574 codebase=>'',
197 : gage 5619 # appletId =>'', #always use identical applet Id's and applet Names
198 : gage 5574 params =>undef,
199 : gage 5619 width => 550,
200 :     height => 400,
201 : gage 5661 base64_state => undef, # this is an state to use for initializing the first occurence of the question.
202 :     base64_config => undef, # this is the initial (and final?) configuration
203 : gage 5619 getStateAlias => 'getXML',
204 : gage 5625 setStateAlias => 'setXML',
205 : gage 5619 configAlias => 'config',
206 :     initializeActionAlias => 'setXML',
207 :     submitActionAlias => 'getXML',
208 : gage 5984 submitActionScript => '', # script executed on submitting the WW question
209 : gage 5619 returnFieldName => 'receivedField',
210 :     headerText => DEFAULT_HEADER_TEXT(),
211 :     objectText => '',
212 :     debug => 0,
213 : gage 5574 @_,
214 :     };
215 :     bless $self, $class;
216 : gage 5661 $self->state('<xml></xml>');
217 :     $self->config('<xml></xml>');
218 : gage 5574 return $self;
219 :     }
220 :    
221 :     sub header {
222 :     my $self = shift;
223 :     if ($_[0] eq "reset") { # $applet->header('reset'); erases default header text.
224 :     $self->{headerText}='';
225 :     } else {
226 :     $self->{headerText} .= join("",@_); # $applet->header(new_text); concatenates new_text to existing header.
227 :     }
228 :     $self->{headerText};
229 :     }
230 :     sub object {
231 :     my $self = shift;
232 :     if ($_[0] eq "reset") {
233 :     $self->{objectText}='';
234 :     } else {
235 :     $self->{objectText} .= join("",@_);
236 :     }
237 :     $self->{objectText};
238 :     }
239 :     sub params {
240 :     my $self = shift;
241 :     if (ref($_[0]) =~/HASH/) {
242 :     $self->{params} = shift;
243 : gage 5619 } elsif ( !defined($_[0]) or $_[0] =~ '') {
244 : gage 5574 # do nothing (read)
245 :     } else {
246 :     warn "You must enter a reference to a hash for the parameter list";
247 :     }
248 :     $self->{params};
249 :     }
250 :    
251 :     sub initializeActionAlias {
252 :     my $self = shift;
253 :     $self->{initializeActionAlias} = shift ||$self->{initializeActionAlias}; # replace the current contents if non-empty
254 :     $self->{initializeActionAlias};
255 :     }
256 :    
257 :     sub submitActionAlias {
258 :     my $self = shift;
259 :     $self->{submitActionAlias} = shift ||$self->{submitActionAlias}; # replace the current contents if non-empty
260 :     $self->{submitActionAlias};
261 :     }
262 : gage 5984 sub submitActionScript {
263 :     my $self = shift;
264 :     $self->{submitActionScript} = shift ||$self->{submitActionScript}; # replace the current contents if non-empty
265 :     $self->{submitActionScript};
266 :     }
267 : gage 5619 sub getStateAlias {
268 :     my $self = shift;
269 :     $self->{getStateAlias} = shift ||$self->{getStateAlias}; # replace the current contents if non-empty
270 :     $self->{getStateAlias};
271 :     }
272 :    
273 :     sub setStateAlias {
274 :     my $self = shift;
275 :     $self->{setStateAlias} = shift ||$self->{setStateAlias}; # replace the current contents if non-empty
276 :     $self->{setStateAlias};
277 :     }
278 :     sub configAlias {
279 :     my $self = shift;
280 :     $self->{configAlias} = shift ||$self->{configAlias}; # replace the current contents if non-empty
281 :     $self->{configAlias};
282 :     }
283 : gage 5574 sub returnFieldName {
284 :     my $self = shift;
285 :     $self->{returnFieldName} = shift ||$self->{returnFieldName}; # replace the current contents if non-empty
286 :     $self->{returnFieldName};
287 :     }
288 :     sub codebase {
289 :     my $self = shift;
290 :     $self->{codebase} = shift ||$self->{codebase}; # replace the current codebase if non-empty
291 :     $self->{codebase};
292 :     }
293 : gage 5619 sub code {
294 :     my $self = shift;
295 :     $self->{code} = shift ||$self->{code}; # replace the current code if non-empty
296 :     $self->{code};
297 :     }
298 :     sub height {
299 :     my $self = shift;
300 :     $self->{height} = shift ||$self->{height}; # replace the current height if non-empty
301 :     $self->{height};
302 :     }
303 :     sub width {
304 :     my $self = shift;
305 :     $self->{width} = shift ||$self->{width}; # replace the current width if non-empty
306 :     $self->{width};
307 :     }
308 :     sub archive {
309 :     my $self = shift;
310 :     $self->{archive} = shift ||$self->{archive}; # replace the current archive if non-empty
311 :     $self->{archive};
312 :     }
313 : gage 5574 sub appletName {
314 :     my $self = shift;
315 :     $self->{appletName} = shift ||$self->{appletName}; # replace the current appletName if non-empty
316 :     $self->{appletName};
317 :     }
318 : gage 5619 sub debug {
319 : gage 5574 my $self = shift;
320 : gage 5619 my $new_flag = shift;
321 :     $self->{debug} = $new_flag if defined($new_flag);
322 :     $self->{debug};
323 : gage 5574 }
324 : gage 5619 sub appletId {
325 :     appletName(@_);
326 :     }
327 :     sub state {
328 : gage 5574 my $self = shift;
329 :     my $str = shift;
330 : gage 5619 $self->{base64_state} = encode_base64($str) ||$self->{base64_state}; # replace the current string if non-empty
331 :     $self->{base64_state} =~ s/\n//g;
332 :     decode_base64($self->{base64_state});
333 : gage 5574 }
334 :    
335 : gage 5619 sub base64_state{
336 : gage 5574 my $self = shift;
337 : gage 5619 $self->{base64_state} = shift ||$self->{base64_state}; # replace the current string if non-empty
338 :     $self->{base64_state};
339 : gage 5574 }
340 : gage 5619 sub config {
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 :     }
347 :     sub base64_config {
348 :     my $self = shift;
349 :     $self->{base64_config} = shift ||$self->{base64_config}; # replace the current string if non-empty
350 :     $self->{base64_config} =$self->{base64_config};
351 :     $self->{base64_config};
352 :     }
353 : gage 5574 #FIXME
354 :     # need to be able to adjust header material
355 :    
356 :     sub insertHeader {
357 :     my $self = shift;
358 : gage 5622 my $codebase = $self->codebase;
359 :     my $appletId = $self->appletId;
360 :     my $appletName = $self->appletName;
361 : gage 5619 my $base64_initialState = $self->base64_state;
362 : gage 5622 my $initializeAction = $self->initializeActionAlias;
363 :     my $submitAction = $self->submitActionAlias;
364 : gage 5984 my $submitActionScript = $self->submitActionScript;
365 : gage 5619 my $setState = $self->setStateAlias;
366 :     my $getState = $self->getStateAlias;
367 :     my $config = $self->configAlias;
368 :     my $base64_config = $self->base64_config;
369 :     my $debugMode = ($self->debug) ? "1": "0";
370 : gage 5622 my $returnFieldName = $self->{returnFieldName};
371 :     # my $encodeStateQ = ($self->debug)?'' : "state = Base64.encode(state);"; # in debug mode base64 encoding is not used.
372 :     # my $decodeStateQ = "if (!state.match(/<XML>*/i) ) {state = Base64.decode(state)}"; # decode if <XML> is not present
373 :     my $headerText = $self->header();
374 :    
375 : gage 5574 $headerText =~ s/(\$\w+)/$1/gee; # interpolate variables p17 of Cookbook
376 :    
377 :     return $headerText;
378 :    
379 :    
380 :     }
381 :    
382 :     sub insertObject {
383 : gage 5619 my $self = shift;
384 :     my $code = $self->{code};
385 :     my $codebase = $self->{codebase};
386 :     my $appletId = $self->{appletName};
387 : gage 5574 my $appletName = $self->{appletName};
388 : gage 5619 my $archive = $self->{archive};
389 :     my $width = $self->{width};
390 :     my $height = $self->{height};
391 : gage 5624 my $javaParameters = '';
392 :     my $flashParameters = '';
393 : gage 5619 my %param_hash = %{$self->params()};
394 :     foreach my $key (keys %param_hash) {
395 : gage 5624 $javaParameters .= qq!<param name ="$key" value = "$param_hash{$key}">\n!;
396 :     $flashParameters .= uri_escape($key).'='.uri_escape($param_hash{$key}).'&';
397 : gage 5619 }
398 : gage 5624 $flashParameters =~ s/\&$//; # trim last &
399 : gage 5619
400 : gage 5624
401 : gage 5574 $objectText = $self->{objectText};
402 :     $objectText =~ s/(\$\w+)/$1/gee;
403 :     return $objectText;
404 :     }
405 :     sub initialize {
406 :     my $self = shift;
407 :     return q{
408 :     <script>
409 : gage 5619 initializeAction();
410 : gage 5574 // this should really be done in the <body> tag
411 :     </script>
412 :     };
413 :    
414 :     }
415 : gage 5661 ########################################################
416 :     # HEADER material for one flash or java applet
417 :     ########################################################
418 : gage 5574
419 : gage 5619 use constant DEFAULT_HEADER_TEXT =><<'END_HEADER_SCRIPT';
420 :    
421 :     <script language="JavaScript">
422 : gage 5661
423 : gage 5662 // set debug mode for this applet
424 :     set_debug($debugMode);
425 :    
426 : gage 5661 //////////////////////////////////////////////////////////
427 : gage 5619 //CONFIGURATIONS
428 :     //
429 :     // configurations are "permanent"
430 : gage 5661 //////////////////////////////////////////////////////////
431 :    
432 : gage 5619 applet_config_list["$appletName"] = function() {
433 : gage 5667 debug_add("applet_config_list:\n attempt to configure $appletName . $config ( $base64_config ) if config function is defined: "
434 : gage 5661 );
435 : gage 5619 try {
436 : gage 5661 if (( typeof(getApplet("$appletName").$config) == "function" ) ) {
437 : gage 5667 debug_add("CONFIGURE $appletName");
438 : gage 5619 getApplet("$appletName").$config(Base64.decode("$base64_config"));
439 :     }
440 :     } catch(e) {
441 : gage 5661 alert("Error executing configuration command $config for $appletName: " + e );
442 : gage 5619 }
443 :     }
444 : gage 5661 ////////////////////////////////////////////////////////////
445 : gage 5619 //
446 : gage 5661 //STATE:
447 :     // state can vary as the applet is manipulated -- it is reset from the questions _state values
448 : gage 5619 //
449 : gage 5661 //////////////////////////////////////////////////////////
450 :    
451 :     applet_setState_list["$appletName"] = function(state) {
452 : gage 5667 debug_add("Begin setState for applet $appletName");
453 :     debug_add("Obtain state from $appletName"+"_state");
454 : gage 5661 state = state || getQE("$appletName"+"_state").value;
455 :     if ( base64Q(state) ) {
456 :     state=Base64.decode(state);
457 :     }
458 :     if (state.match(/<xml/i) || state.match(/<?xml/i) ) { // if state starts with <?xml
459 :    
460 :     debug_add("applet_setState_list: \n set (decoded) state for $appletName to " +
461 :     state +"\nfunction type is " +typeof(getApplet("$appletName").$setState)
462 :     );
463 :     try {
464 :     if (( typeof(getApplet("$appletName").$setState) =="function" ) ) {
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 : gage 5619 };
475 :     applet_getState_list["$appletName"] = function () {
476 : gage 5667 debug_add("get current state for applet $appletName and store it in $appletName"+"_state");
477 : gage 5661 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 : gage 5676 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 : gage 5661 }
485 : gage 5667
486 : gage 5676 if (!debug) {
487 :     state = Base64.encode(state);
488 :     }; // replace state by encoded version unless in debug mode
489 :    
490 : gage 5667 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 : gage 5661 } catch (e) {
493 :     alert("Error in getting state for $appletName " + e );
494 :     }
495 : gage 5619 };
496 : gage 5661
497 :     ////////////////////////////////////////////////////////////
498 : gage 5619 //
499 :     //INITIALIZE
500 :     //
501 : gage 5661 ////////////////////////////////////////////////////////////
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 : gage 5667 applet_isReady_list["$appletName"]= ready;
530 : gage 5661 return(ready);
531 :     }
532 :    
533 :     applet_initializeAction_list["$appletName"] = function (state) {
534 :     applet_setState_list["$appletName"](state);
535 : gage 5619 };
536 :    
537 :     applet_submitAction_list["$appletName"] = function () {
538 : gage 5667 if (! applet_isReady_list["$appletName"] ) {
539 :     alert("$appletName is not ready");
540 :     }
541 : gage 5619 applet_getState_list["$appletName"]();
542 : gage 5984 $submitActionScript
543 : gage 5667 //getQE("$returnFieldName").value = getApplet("$appletName").sendData(); //FIXME -- not needed in general?
544 : gage 5619 };
545 :     </script>
546 :    
547 :     END_HEADER_SCRIPT
548 :    
549 :     package FlashApplet;
550 :     @ISA = qw(Applet);
551 :    
552 :    
553 : gage 5944 =head2 Insertion HTML code for FlashApplet
554 : gage 5619
555 :     =pod
556 :    
557 :     The secret to making this applet work with IE in addition to normal browsers
558 :     is the addition of the C(<form></form>) construct just before the object.
559 :    
560 :     For some reason IE has trouble locating a flash object which is contained
561 :     within a form. Adding this second blank form with the larger problemMainForm
562 :     seems to solve the problem.
563 :    
564 :     This follows method2 of the advice given in url(http://kb.adobe.com/selfservice/viewContent.do?externalId=kb400730&sliceId=2)
565 :     Method1 and methods involving SWFObject(Geoff Stearns) and SWFFormFix (Steve Kamerman) have yet to be fully investigated:
566 :     http://devel.teratechnologies.net/swfformfix/swfobject_swfformfix_source.js
567 :     http://www.teratechnologies.net/stevekamerman/index.php?m=01&y=07&entry=entry070101-033933
568 :    
569 :     use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
570 :     <form></form>
571 :     <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
572 :     id="$appletName" width="500" height="375"
573 :     codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
574 :     <param name="movie" value="$codebase/$appletName.swf" />
575 :     <param name="quality" value="high" />
576 :     <param name="bgcolor" value="#869ca7" />
577 :     <param name="allowScriptAccess" value="sameDomain" />
578 :     <embed src="$codebase/$appletName.swf" quality="high" bgcolor="#869ca7"
579 :     width="$width" height="$height" name="$appletName" align="middle" id="$appletName"
580 :     play="true" loop="false" quality="high" allowScriptAccess="sameDomain"
581 :     type="application/x-shockwave-flash"
582 :     pluginspage="http://www.macromedia.com/go/getflashplayer">
583 :     </embed>
584 :    
585 :     </object>
586 :     END_OBJECT_TEXT
587 :    
588 :    
589 :     =cut
590 :    
591 :     use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
592 :     <form></form>
593 :     <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
594 :     id="$appletName" width="500" height="375"
595 :     codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
596 :     <param name="movie" value="$codebase/$appletName.swf" />
597 :     <param name="quality" value="high" />
598 :     <param name="bgcolor" value="#869ca7" />
599 :     <param name="allowScriptAccess" value="sameDomain" />
600 : gage 5624 <param name="FlashVars" value="$flashParameters"/>
601 : gage 5619 <embed src="$codebase/$appletName.swf" quality="high" bgcolor="#869ca7"
602 :     width="$width" height="$height" name="$appletName" align="middle" id="$appletName"
603 :     play="true" loop="false" quality="high" allowScriptAccess="sameDomain"
604 :     type="application/x-shockwave-flash"
605 : gage 5624 pluginspage="http://www.macromedia.com/go/getflashplayer"
606 :     FlashVars="$flashParameters">
607 : gage 5619 </embed>
608 :    
609 :     </object>
610 :     END_OBJECT_TEXT
611 :    
612 :     sub new {
613 :     my $class = shift;
614 :     $class -> SUPER::new( objectText => DEFAULT_OBJECT_TEXT(),
615 :     @_
616 :     );
617 :    
618 :     }
619 :    
620 :    
621 :     package JavaApplet;
622 :     @ISA = qw(Applet);
623 :    
624 : gage 5944 =head2 Insertion HTML code for JavaApplet
625 : gage 5619
626 :     =pod
627 :    
628 :     The secret to making this applet work with IE in addition to normal browsers
629 :     is the addition of the C(<form></form>) construct just before the object.
630 :    
631 :     For some reason IE has trouble locating a flash object which is contained
632 :     within a form. Adding this second blank form with the larger problemMainForm
633 :     seems to solve the problem.
634 :    
635 :     This follows method2 of the advice given in url(http://kb.adobe.com/selfservice/viewContent.do?externalId=kb400730&sliceId=2)
636 :     Method1 and methods involving SWFObject(Geoff Stearns) and SWFFormFix (Steve Kamerman) have yet to be fully investigated:
637 :     http://devel.teratechnologies.net/swfformfix/swfobject_swfformfix_source.js
638 :     http://www.teratechnologies.net/stevekamerman/index.php?m=01&y=07&entry=entry070101-033933
639 :    
640 :     use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
641 :     <form></form>
642 :     <applet
643 :     code = "$code"
644 :     codebase = "$codebase"
645 :     archive = "$archive"
646 :     name = "$appletName"
647 :     id = "$appletName"
648 :     width = "$width"
649 :     height = "$height"
650 :     MAYSCRIPT
651 :     >
652 : gage 5624 $javaParameters
653 : gage 5619 </applet>
654 :     END_OBJECT_TEXT
655 :    
656 :     =cut
657 :    
658 :     use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
659 :     <form></form>
660 :     <applet
661 :     code = "$code"
662 :     codebase = "$codebase"
663 :     archive = "$archive"
664 :     name = "$appletName"
665 :     id = "$appletName"
666 :     width = "$width"
667 :     height = "$height"
668 :     MAYSCRIPT
669 :     >
670 : gage 5624 $javaParameters
671 : gage 5667
672 :     Sorry, the Applet could not be started. Please make sure that
673 :     Java 1.4.2 (or later) is installed and activated.
674 :     (<a href="http://java.sun.com/getjava">click here to install Java now</a>)
675 : gage 5619 </applet>
676 :     END_OBJECT_TEXT
677 :    
678 :     sub new {
679 :     my $class = shift;
680 :     $class -> SUPER::new( objectText => DEFAULT_OBJECT_TEXT(),
681 :     @_
682 :     );
683 :    
684 :     }
685 :    
686 :    
687 :    
688 : gage 5574 1;

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9