[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 5578 Revision 5667
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.1 2007/10/30 15:57:04 gage Exp $ 4# $CVSHeader: pg/lib/Applet.pm,v 1.10 2008/05/05 17:24:31 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.
22 22
23 ################################### 23 ###################################
24 # Create link to applet 24 # Create link to applet
25 ################################### 25 ###################################
26 my $appletName = "LineThruPointsWW"; 26 my $appletName = "LineThruPointsWW";
27 $applet = new FlashApplet( 27 $applet = new FlashApplet(
28 # can be replaced by $applet =FlashApplet() when using AppletObjects.pl
28 codebase => findAppletCodebase("$appletName.swf"), 29 codebase => findAppletCodebase("$appletName.swf"),
29 appletName => $appletName, 30 appletName => $appletName,
30 appletId => $appletName, 31 appletId => $appletName,
31 submitActionAlias => 'checkAnswer', 32 submitActionAlias => 'checkAnswer',
32 ); 33 );
34 ################################### 35 ###################################
35 # Configure applet 36 # Configure applet
36 ################################### 37 ###################################
37 38
38 #xml data to set up the problem-rac 39 #xml data to set up the problem-rac
39 $applet->xmlString(qq{<XML> 40 $applet->config(qq{<XML>
40 <point xval='$xval_1' yval='$yval_1' /> 41 <point xval='$xval_1' yval='$yval_1' />
41 <point xval='$xval_2' yval='$yval_2' /> 42 <point xval='$xval_2' yval='$yval_2' />
42 </XML>}); 43 </XML>});
43 44
44 45
74 75
75(not yet completed) 76(not yet completed)
76 77
77The module JavaApplet has defaults for inserting java applets. 78The module JavaApplet has defaults for inserting java applets.
78 79
79The module Applet will store common code for the two types of applet. 80The module Applet stores common code for the two types of applet.
80 81
81=head1 USAGE 82=head1 USAGE
82 83
83This file is included by listing it in the modules section of global.conf. 84These modules are activate by listing it in the modules section of global.conf and rebooting the server.
85The companion file to this one is macros/AppletObjects.pl
86
87qw(Applet FlashApplet JavaApplet)
84 88
85=cut 89=cut
86 90
87 91
88 92
89package Applet; 93package Applet;
90 94
95use URI::Escape;
91 96
92package FlashApplet;
93 97
94 98
95use MIME::Base64 qw( encode_base64 decode_base64); 99use MIME::Base64 qw( encode_base64 decode_base64);
96 100
97use constant DEFAULT_HEADER_TEXT =><<'END_HEADER_SCRIPT';
98 <script language="javascript">AC_FL_RunContent = 0;</script>
99 <script src="http://hosted2.webwork.rochester.edu/webwork2_files/applets/AC_RunActiveContent.js" language="javascript">
100 </script>
101 101
102 102=head2 Default javaScript functions placed in header
103 <script language="JavaScript"> 103
104These functions are automatically defined for use for
105any javaScript placed in the text of a PG question.
106
107 getApplet(appletName) -- finds the applet path in the DOM
104 108
105 var flash; 109 submitAction() -- calls the submit action of the applets
106 function getFlashMovie(movieName) { 110
107 var isIE = navigator.appName.indexOf("Microsoft") != -1;
108 return (isIE) ? window[movieName] : window.document[movieName];
109 //return window.document[movieName];
110 }
111
112
113 function initialize() {
114 getFlashMovie("$appletId").$initializeAction("$base64_xmlString");
115 }
116 function submitAction() {
117 document.problemMainForm.$returnFieldName.value = getFlashMovie("$appletId").$submitAction();
118 }
119 111
120 </script> 112 initializeAction() -- calls the initialize action of the applets
121
122END_HEADER_SCRIPT
123 113
114 getQE(name) -- gets an HTML element of the question by name
115 or by id. Be sure to keep all names and ids
116 unique within a given PG question.
117
118 getQuestionElement(name) -- long form of getQE(name)
119
120 listQuestionElements() -- for discovering the names of inputs in the
121 PG question. An alert dialog will list all
122 of the elements.
123 Usage: Place this at the END of the question,
124 just before END_DOCUMENT():
124 125
125# <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" 126 TEXT(qq!<script> listQuestionElements() </script>!);
126# width="550" height="400" id="$appletId" align="middle"> 127 ENDDOCUMENT();
127# <param name="allowScriptAccess" value="sameDomain" />
128# <param name="allowFullScreen" value="false" />
129# <param name="movie" value="$appletName.swf" />
130# <param name="quality" value="high" />
131# <param name="bgcolor" value="#ffffcc" />
132# <embed src="$codebase/$appletName.swf" quality="high" bgcolor="#ffffcc" width="550" height="400" name="$appletName"
133# align="middle" id="$appletId",
134# align="middle" allowScriptAccess="sameDomain"
135# allowFullScreen="false"
136# type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
137# <param name="quality" value="high" /><param name="bgcolor" value="#ffffcc" />
138# </object>
139 128
140use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT'; 129 list of accessor methods format: current_value = $self->method(new_value or empty)
141 <form></form>
142 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
143 id="ExternalInterface" width="500" height="375"
144 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
145 <param name="movie" value="$codebase/$appletName.swf" />
146 <param name="quality" value="high" />
147 <param name="bgcolor" value="#869ca7" />
148 <param name="allowScriptAccess" value="sameDomain" />
149 <embed src="$codebase/$appletName.swf" quality="high" bgcolor="#869ca7"
150 width="550" height="400" name="$appletName" align="middle" id="$appletID"
151 play="true" loop="false" quality="high" allowScriptAccess="sameDomain"
152 type="application/x-shockwave-flash"
153 pluginspage="http://www.macromedia.com/go/getflashplayer">
154 </embed>
155 130
156 </object> 131 appletId for simplicity and reliability appletId and appletName are always the same
157END_OBJECT_TEXT 132 appletName
133
134 archive the name of the .jar file containing the applet code
135 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
137
138 height rectangle alloted in the html page for displaying the applet
139 width
140
141 params an anonymous array containing name/value pairs
142 to configure the applet [name =>'value, ...]
143
144 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
146
147 debug in debug mode several alerts mark progress through the procedure of calling the applet
148
149 config configuration are those customizable attributes of the applet which don't
150 change as it is used. When stored in hidden answer fields
151 it is usually stored in base64 encoded format.
152 base64_config base64 encode version of the contents of config
153
154 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>
156 The outer tags must be <xml> ..... </xml>
157 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
159 when revisiting the question the applet
160 will be restored to the same state it was left in when the question was last
161 viewed.
162
163 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>
165 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>
167
168 base64_state returns the base64 encoded version of the state stored in the applet object.
169
170 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
172 .pg question is pressed.
173
174 returnFieldName
175
176
177
178
179
180=cut
181
182
158 183
159 184
160sub new { 185sub new {
161 my $class = shift; 186 my $class = shift;
162 my $self = { 187 my $self = {
163 host =>'',
164 port => '',
165 path => '',
166 appletName =>'', 188 appletName =>'',
189 code=>'',
167 codebase=>'', 190 codebase=>'',
168 appletId =>'', 191# appletId =>'', #always use identical applet Id's and applet Names
169 params =>undef, 192 params =>undef,
170 base64_xmlString => 'foobar', 193 width => 550,
194 height => 400,
195 base64_state => undef, # this is an state to use for initializing the first occurence of the question.
196 base64_config => undef, # this is the initial (and final?) configuration
197 getStateAlias => 'getXML',
198 setStateAlias => 'setXML',
199 configAlias => 'config',
171 initializeActionAlias => 'setupProblem', 200 initializeActionAlias => 'setXML',
172 submitActionAlias => 'checkAnswer', 201 submitActionAlias => 'getXML',
173 returnFieldName => 'receivedField', 202 returnFieldName => 'receivedField',
174 headerText => DEFAULT_HEADER_TEXT(), 203 headerText => DEFAULT_HEADER_TEXT(),
175 objectText => DEFAULT_OBJECT_TEXT(), 204 objectText => '',
205 debug => 0,
176 @_, 206 @_,
177 }; 207 };
178 bless $self, $class; 208 bless $self, $class;
179 #$self -> _initialize(@_); 209 $self->state('<xml></xml>');
210 $self->config('<xml></xml>');
180 return $self; 211 return $self;
181} 212}
182 213
183sub header { 214sub header {
184 my $self = shift; 215 my $self = shift;
200} 231}
201sub params { 232sub params {
202 my $self = shift; 233 my $self = shift;
203 if (ref($_[0]) =~/HASH/) { 234 if (ref($_[0]) =~/HASH/) {
204 $self->{params} = shift; 235 $self->{params} = shift;
205 } elsif ( $_[0] =~ '') { 236 } elsif ( !defined($_[0]) or $_[0] =~ '') {
206 # do nothing (read) 237 # do nothing (read)
207 } else { 238 } else {
208 warn "You must enter a reference to a hash for the parameter list"; 239 warn "You must enter a reference to a hash for the parameter list";
209 } 240 }
210 $self->{params}; 241 $self->{params};
219sub submitActionAlias { 250sub submitActionAlias {
220 my $self = shift; 251 my $self = shift;
221 $self->{submitActionAlias} = shift ||$self->{submitActionAlias}; # replace the current contents if non-empty 252 $self->{submitActionAlias} = shift ||$self->{submitActionAlias}; # replace the current contents if non-empty
222 $self->{submitActionAlias}; 253 $self->{submitActionAlias};
223} 254}
255sub getStateAlias {
256 my $self = shift;
257 $self->{getStateAlias} = shift ||$self->{getStateAlias}; # replace the current contents if non-empty
258 $self->{getStateAlias};
259}
260
261sub setStateAlias {
262 my $self = shift;
263 $self->{setStateAlias} = shift ||$self->{setStateAlias}; # replace the current contents if non-empty
264 $self->{setStateAlias};
265}
266sub configAlias {
267 my $self = shift;
268 $self->{configAlias} = shift ||$self->{configAlias}; # replace the current contents if non-empty
269 $self->{configAlias};
270}
224sub returnFieldName { 271sub returnFieldName {
225 my $self = shift; 272 my $self = shift;
226 $self->{returnFieldName} = shift ||$self->{returnFieldName}; # replace the current contents if non-empty 273 $self->{returnFieldName} = shift ||$self->{returnFieldName}; # replace the current contents if non-empty
227 $self->{returnFieldName}; 274 $self->{returnFieldName};
228} 275}
229sub codebase { 276sub codebase {
230 my $self = shift; 277 my $self = shift;
231 $self->{codebase} = shift ||$self->{codebase}; # replace the current codebase if non-empty 278 $self->{codebase} = shift ||$self->{codebase}; # replace the current codebase if non-empty
232 $self->{codebase}; 279 $self->{codebase};
233} 280}
281sub code {
282 my $self = shift;
283 $self->{code} = shift ||$self->{code}; # replace the current code if non-empty
284 $self->{code};
285}
286sub height {
287 my $self = shift;
288 $self->{height} = shift ||$self->{height}; # replace the current height if non-empty
289 $self->{height};
290}
291sub width {
292 my $self = shift;
293 $self->{width} = shift ||$self->{width}; # replace the current width if non-empty
294 $self->{width};
295}
296sub archive {
297 my $self = shift;
298 $self->{archive} = shift ||$self->{archive}; # replace the current archive if non-empty
299 $self->{archive};
300}
234sub appletName { 301sub appletName {
235 my $self = shift; 302 my $self = shift;
236 $self->{appletName} = shift ||$self->{appletName}; # replace the current appletName if non-empty 303 $self->{appletName} = shift ||$self->{appletName}; # replace the current appletName if non-empty
237 $self->{appletName}; 304 $self->{appletName};
238} 305}
306sub debug {
307 my $self = shift;
308 my $new_flag = shift;
309 $self->{debug} = $new_flag if defined($new_flag);
310 $self->{debug};
311}
239sub appletId { 312sub appletId {
240 my $self = shift; 313 appletName(@_);
241 $self->{appletId} = shift ||$self->{appletId}; # replace the current appletName if non-empty
242 $self->{appletId};
243} 314}
244sub xmlString { 315sub state {
245 my $self = shift; 316 my $self = shift;
246 my $str = shift; 317 my $str = shift;
318 $self->{base64_state} = encode_base64($str) ||$self->{base64_state}; # replace the current string if non-empty
319 $self->{base64_state} =~ s/\n//g;
320 decode_base64($self->{base64_state});
321}
322
323sub base64_state{
324 my $self = shift;
325 $self->{base64_state} = shift ||$self->{base64_state}; # replace the current string if non-empty
326 $self->{base64_state};
327}
328sub config {
329 my $self = shift;
330 my $str = shift;
247 $self->{base64_xmlString} = encode_base64($str) ||$self->{base64_xmlString}; # replace the current string if non-empty 331 $self->{base64_config} = encode_base64($str) || $self->{base64_config}; # replace the current string if non-empty
248 $self->{base64_xmlString} =~ s/\n//g; 332 $self->{base64_config} =~ s/\n//g;
249 decode_base64($self->{base64_xmlString}); 333 decode_base64($self->{base64_config});
250} 334}
251 335sub base64_config {
252sub base64_xmlString{
253 my $self = shift; 336 my $self = shift;
254 $self->{base64_xmlString} = shift ||$self->{base64_xmlString}; # replace the current string if non-empty 337 $self->{base64_config} = shift ||$self->{base64_config}; # replace the current string if non-empty
338 $self->{base64_config} =$self->{base64_config};
255 $self->{base64_xmlString}; 339 $self->{base64_config};
256} 340}
257
258#FIXME 341#FIXME
259# need to be able to adjust header material 342# need to be able to adjust header material
260 343
261sub insertHeader { 344sub insertHeader {
262 my $self = shift; 345 my $self = shift;
346 my $codebase = $self->codebase;
347 my $appletId = $self->appletId;
348 my $appletName = $self->appletName;
349 my $base64_initialState = $self->base64_state;
350 my $initializeAction = $self->initializeActionAlias;
351 my $submitAction = $self->submitActionAlias;
352 my $setState = $self->setStateAlias;
353 my $getState = $self->getStateAlias;
354 my $config = $self->configAlias;
355 my $base64_config = $self->base64_config;
356 my $debugMode = ($self->debug) ? "1": "0";
357 my $returnFieldName = $self->{returnFieldName};
358# my $encodeStateQ = ($self->debug)?'' : "state = Base64.encode(state);"; # in debug mode base64 encoding is not used.
359# my $decodeStateQ = "if (!state.match(/<XML>*/i) ) {state = Base64.decode(state)}"; # decode if <XML> is not present
360 my $headerText = $self->header();
361
362 $headerText =~ s/(\$\w+)/$1/gee; # interpolate variables p17 of Cookbook
363
364 return $headerText;
365
366
367}
368
369sub insertObject {
370 my $self = shift;
371 my $code = $self->{code};
263 my $codebase = $self->{codebase}; 372 my $codebase = $self->{codebase};
264 my $appletId = $self->{appletId}; 373 my $appletId = $self->{appletName};
265 my $appletName = $self->{appletName}; 374 my $appletName = $self->{appletName};
266 my $base64_xmlString = $self->{base64_xmlString}; 375 my $archive = $self->{archive};
267 my $initializeAction = $self->{initializeActionAlias}; 376 my $width = $self->{width};
268 my $submitAction = $self->{submitActionAlias}; 377 my $height = $self->{height};
269 my $returnFieldName= $self->{returnFieldName}; 378 my $javaParameters = '';
270 my $headerText = $self->header(); 379 my $flashParameters = '';
271 $headerText =~ s/(\$\w+)/$1/gee; # interpolate variables p17 of Cookbook 380 my %param_hash = %{$self->params()};
381 foreach my $key (keys %param_hash) {
382 $javaParameters .= qq!<param name ="$key" value = "$param_hash{$key}">\n!;
383 $flashParameters .= uri_escape($key).'='.uri_escape($param_hash{$key}).'&';
384 }
385 $flashParameters =~ s/\&$//; # trim last &
386
272 387
273 return $headerText;
274
275
276}
277
278
279# <script language="javascript">
280# if (AC_FL_RunContent == 0) {
281# alert("This page requires AC_RunActiveContent.js.");
282# } else {
283# AC_FL_RunContent(
284# 'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
285# 'width', '100%',
286# 'height', '100%',
287# 'src', 'http://$codebase/$appletName',
288# 'quality', 'high',
289# 'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
290# 'align', 'middle',
291# 'play', 'true',
292# 'loop', 'true',
293# 'scale', 'showall',
294# 'wmode', 'window',
295# 'devicefont', 'false',
296# 'id', '$appletId',
297# 'bgcolor', '#ffffcc',
298# 'name', '$appletName',
299# 'menu', 'true',
300# 'allowFullScreen', 'false',
301# 'allowScriptAccess','sameDomain',
302# 'movie', '$appletName',
303# 'salign', ''
304# ); //end AC code
305# }
306# </script>
307sub insertObject {
308 my $self = shift;
309 my $codebase = $self->{codebase};
310 my $appletId = $self->{appletId};
311 my $appletName = $self->{appletName};
312 $codebase = findAppletCodebase("$appletName.swf") unless $codebase;
313 $objectText = $self->{objectText}; 388 $objectText = $self->{objectText};
314 $objectText =~ s/(\$\w+)/$1/gee; 389 $objectText =~ s/(\$\w+)/$1/gee;
315 return $objectText; 390 return $objectText;
316} 391}
317
318sub initialize { 392sub initialize {
319 my $self = shift; 393 my $self = shift;
320 return q{ 394 return q{
321 <script> 395 <script>
322 initialize(); 396 initializeAction();
323 // this should really be done in the <body> tag 397 // this should really be done in the <body> tag
324 </script> 398 </script>
325 }; 399 };
326 400
327} 401}
402########################################################
403# HEADER material for one flash or java applet
404########################################################
405
406use constant DEFAULT_HEADER_TEXT =><<'END_HEADER_SCRIPT';
407
408 <script language="JavaScript">
409
410 // set debug mode for this applet
411 set_debug($debugMode);
412
413 //////////////////////////////////////////////////////////
414 //CONFIGURATIONS
415 //
416 // configurations are "permanent"
417 //////////////////////////////////////////////////////////
418
419 applet_config_list["$appletName"] = function() {
420 debug_add("applet_config_list:\n attempt to configure $appletName . $config ( $base64_config ) if config function is defined: "
421 );
422 try {
423 if (( typeof(getApplet("$appletName").$config) == "function" ) ) {
424 debug_add("CONFIGURE $appletName");
425 getApplet("$appletName").$config(Base64.decode("$base64_config"));
426 }
427 } catch(e) {
428 alert("Error executing configuration command $config for $appletName: " + e );
429 }
430 }
431 ////////////////////////////////////////////////////////////
432 //
433 //STATE:
434 // state can vary as the applet is manipulated -- it is reset from the questions _state values
435 //
436 //////////////////////////////////////////////////////////
437
438 applet_setState_list["$appletName"] = function(state) {
439 debug_add("Begin setState for applet $appletName");
440 debug_add("Obtain state from $appletName"+"_state");
441 state = state || getQE("$appletName"+"_state").value;
442 if ( base64Q(state) ) {
443 state=Base64.decode(state);
444 }
445 if (state.match(/<xml/i) || state.match(/<?xml/i) ) { // if state starts with <?xml
446
447 debug_add("applet_setState_list: \n set (decoded) state for $appletName to " +
448 state +"\nfunction type is " +typeof(getApplet("$appletName").$setState)
449 );
450 try {
451 if (( typeof(getApplet("$appletName").$setState) =="function" ) ) {
452 debug_add("setState for $appletName");
453 getApplet("$appletName").$setState( state );
454 }
455 } catch(e) {
456 alert("Error in setting state of $appletName using command $setState : " + e );
457 }
458 } else if (debug) {
459 alert("new state was empty string or did not begin with <xml-- state was not reset");
460 }
461 };
462 applet_getState_list["$appletName"] = function () {
463 debug_add("get current state for applet $appletName and store it in $appletName"+"_state");
464 var applet = getApplet("$appletName");
465 try {
466 if (( typeof(applet.$getState) == "function" ) ) { // there may be no state function
467 state = applet.$getState(); // get state in xml format
468 }
469
470 if (!debug) {state = Base64.encode(state) }; // replace state by encoded version unless in debug mode
471 debug_add("state is "+state); // this should still be in plain text
472 getQE("$appletName"+"_state").value = state; //place state in input item (debug: textarea, otherwise: hidden)
473 } catch (e) {
474 alert("Error in getting state for $appletName " + e );
475 }
476 };
477
478 ////////////////////////////////////////////////////////////
479 //
480 //INITIALIZE
481 //
482 ////////////////////////////////////////////////////////////
483
484
485 applet_checkLoaded_list["$appletName"] = function() { // this function returns 0 unless:
486 // applet has already been flagged as ready in applet_isReady_list
487 // applet.config is defined (or alias for .config)
488 // applet.setState is defined
489 // applet.isActive is defined
490 // applet reported that it is loaded by calling loadQ()
491 var ready = 0;
492 var applet = getApplet("$appletName");
493 if (!debug && applet_isReady_list["$appletName"]) {return(1)}; // memorize readiness in non-debug mode
494 if ( typeof(applet.$config) == "function") {
495 debug_add( "applet.config is " + typeof(applet.$config) );
496 ready = 1;
497 }
498 if( typeof(applet.$getState) == "function") {
499 debug_add( "applet.getState is " + typeof(applet.$getState) );
500 ready =1;
501 }
502 if (typeof(applet.isActive) == "function" && applet.isActive ) {
503 debug_add( "applet.isActive is " + typeof(applet.isActive) );
504 ready =1;
505 }
506 if (typeof(applet_reportsLoaded_list["$appletName"]) !="undefined" && applet_reportsLoaded_list["$appletName"] != 0 ) {
507 debug_add( "applet reports that it is loaded " + applet_reportsLoaded_list["$appletName"] );
508 ready =1;
509 }
510 applet_isReady_list["$appletName"]= ready;
511 return(ready);
512 }
513
514 applet_initializeAction_list["$appletName"] = function (state) {
515 applet_setState_list["$appletName"](state);
516 };
517
518 applet_submitAction_list["$appletName"] = function () {
519 if (! applet_isReady_list["$appletName"] ) {
520 alert("$appletName is not ready");
521 }
522 applet_getState_list["$appletName"]();
523 //getQE("$returnFieldName").value = getApplet("$appletName").sendData(); //FIXME -- not needed in general?
524 };
525 </script>
526
527END_HEADER_SCRIPT
528
529package FlashApplet;
530@ISA = qw(Applet);
531
532
533
534=pod
535
536The secret to making this applet work with IE in addition to normal browsers
537is the addition of the C(<form></form>) construct just before the object.
538
539For some reason IE has trouble locating a flash object which is contained
540within a form. Adding this second blank form with the larger problemMainForm
541seems to solve the problem.
542
543This follows method2 of the advice given in url(http://kb.adobe.com/selfservice/viewContent.do?externalId=kb400730&sliceId=2)
544Method1 and methods involving SWFObject(Geoff Stearns) and SWFFormFix (Steve Kamerman) have yet to be fully investigated:
545http://devel.teratechnologies.net/swfformfix/swfobject_swfformfix_source.js
546http://www.teratechnologies.net/stevekamerman/index.php?m=01&y=07&entry=entry070101-033933
547
548 use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
549 <form></form>
550 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
551 id="$appletName" width="500" height="375"
552 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
553 <param name="movie" value="$codebase/$appletName.swf" />
554 <param name="quality" value="high" />
555 <param name="bgcolor" value="#869ca7" />
556 <param name="allowScriptAccess" value="sameDomain" />
557 <embed src="$codebase/$appletName.swf" quality="high" bgcolor="#869ca7"
558 width="$width" height="$height" name="$appletName" align="middle" id="$appletName"
559 play="true" loop="false" quality="high" allowScriptAccess="sameDomain"
560 type="application/x-shockwave-flash"
561 pluginspage="http://www.macromedia.com/go/getflashplayer">
562 </embed>
563
564 </object>
565 END_OBJECT_TEXT
566
567
568=cut
569
570use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
571 <form></form>
572 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
573 id="$appletName" width="500" height="375"
574 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
575 <param name="movie" value="$codebase/$appletName.swf" />
576 <param name="quality" value="high" />
577 <param name="bgcolor" value="#869ca7" />
578 <param name="allowScriptAccess" value="sameDomain" />
579 <param name="FlashVars" value="$flashParameters"/>
580 <embed src="$codebase/$appletName.swf" quality="high" bgcolor="#869ca7"
581 width="$width" height="$height" name="$appletName" align="middle" id="$appletName"
582 play="true" loop="false" quality="high" allowScriptAccess="sameDomain"
583 type="application/x-shockwave-flash"
584 pluginspage="http://www.macromedia.com/go/getflashplayer"
585 FlashVars="$flashParameters">
586 </embed>
587
588 </object>
589END_OBJECT_TEXT
590
591sub new {
592 my $class = shift;
593 $class -> SUPER::new( objectText => DEFAULT_OBJECT_TEXT(),
594 @_
595 );
596
597}
598
599
600package JavaApplet;
601@ISA = qw(Applet);
602
603
604
605=pod
606
607The secret to making this applet work with IE in addition to normal browsers
608is the addition of the C(<form></form>) construct just before the object.
609
610For some reason IE has trouble locating a flash object which is contained
611within a form. Adding this second blank form with the larger problemMainForm
612seems to solve the problem.
613
614This follows method2 of the advice given in url(http://kb.adobe.com/selfservice/viewContent.do?externalId=kb400730&sliceId=2)
615Method1 and methods involving SWFObject(Geoff Stearns) and SWFFormFix (Steve Kamerman) have yet to be fully investigated:
616http://devel.teratechnologies.net/swfformfix/swfobject_swfformfix_source.js
617http://www.teratechnologies.net/stevekamerman/index.php?m=01&y=07&entry=entry070101-033933
618
619 use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
620 <form></form>
621 <applet
622 code = "$code"
623 codebase = "$codebase"
624 archive = "$archive"
625 name = "$appletName"
626 id = "$appletName"
627 width = "$width"
628 height = "$height"
629 MAYSCRIPT
630 >
631 $javaParameters
632 </applet>
633 END_OBJECT_TEXT
634
635=cut
636
637use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
638 <form></form>
639 <applet
640 code = "$code"
641 codebase = "$codebase"
642 archive = "$archive"
643 name = "$appletName"
644 id = "$appletName"
645 width = "$width"
646 height = "$height"
647 MAYSCRIPT
648 >
649 $javaParameters
650
651 Sorry, the Applet could not be started. Please make sure that
652Java 1.4.2 (or later) is installed and activated.
653(<a href="http://java.sun.com/getjava">click here to install Java now</a>)
654 </applet>
655END_OBJECT_TEXT
656
657sub new {
658 my $class = shift;
659 $class -> SUPER::new( objectText => DEFAULT_OBJECT_TEXT(),
660 @_
661 );
662
663}
664
665
328 666
3291; 6671;

Legend:
Removed from v.5578  
changed lines
  Added in v.5667

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9