[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 5583 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.2 2007/11/05 16:45:33 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
140=pod 129 list of accessor methods format: current_value = $self->method(new_value or empty)
141 130
142The secret to making this applet work with IE in addition to normal browsers 131 appletId for simplicity and reliability appletId and appletName are always the same
143is the addition of the C(<form></form>) construct just before the object. 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>
144 167
145For some reason IE has trouble locating a flash object which is contained 168 base64_state returns the base64 encoded version of the state stored in the applet object.
146within a form. Adding this second blank form with the larger problemMainForm 169
147seems to solve the problem. 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.
148 173
149This follows method2 of the advice given in url(http://kb.adobe.com/selfservice/viewContent.do?externalId=kb400730&sliceId=2) 174 returnFieldName
150Method1 and methods involving SWFObject(Geoff Stearns) and SWFFormFix (Steve Kamerman) have yet to be fully investigated: 175
151http://devel.teratechnologies.net/swfformfix/swfobject_swfformfix_source.js 176
152http://www.teratechnologies.net/stevekamerman/index.php?m=01&y=07&entry=entry070101-033933 177
178
153 179
154=cut 180=cut
155 181
156use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
157 <form></form>
158 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
159 id="ExternalInterface" width="500" height="375"
160 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
161 <param name="movie" value="$codebase/$appletName.swf" />
162 <param name="quality" value="high" />
163 <param name="bgcolor" value="#869ca7" />
164 <param name="allowScriptAccess" value="sameDomain" />
165 <embed src="$codebase/$appletName.swf" quality="high" bgcolor="#869ca7"
166 width="550" height="400" name="$appletName" align="middle" id="$appletID"
167 play="true" loop="false" quality="high" allowScriptAccess="sameDomain"
168 type="application/x-shockwave-flash"
169 pluginspage="http://www.macromedia.com/go/getflashplayer">
170 </embed>
171 182
172 </object>
173END_OBJECT_TEXT
174 183
175 184
176sub new { 185sub new {
177 my $class = shift; 186 my $class = shift;
178 my $self = { 187 my $self = {
179 host =>'',
180 port => '',
181 path => '',
182 appletName =>'', 188 appletName =>'',
189 code=>'',
183 codebase=>'', 190 codebase=>'',
184 appletId =>'', 191# appletId =>'', #always use identical applet Id's and applet Names
185 params =>undef, 192 params =>undef,
186 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',
187 initializeActionAlias => 'setupProblem', 200 initializeActionAlias => 'setXML',
188 submitActionAlias => 'checkAnswer', 201 submitActionAlias => 'getXML',
189 returnFieldName => 'receivedField', 202 returnFieldName => 'receivedField',
190 headerText => DEFAULT_HEADER_TEXT(), 203 headerText => DEFAULT_HEADER_TEXT(),
191 objectText => DEFAULT_OBJECT_TEXT(), 204 objectText => '',
205 debug => 0,
192 @_, 206 @_,
193 }; 207 };
194 bless $self, $class; 208 bless $self, $class;
195 #$self -> _initialize(@_); 209 $self->state('<xml></xml>');
210 $self->config('<xml></xml>');
196 return $self; 211 return $self;
197} 212}
198 213
199sub header { 214sub header {
200 my $self = shift; 215 my $self = shift;
216} 231}
217sub params { 232sub params {
218 my $self = shift; 233 my $self = shift;
219 if (ref($_[0]) =~/HASH/) { 234 if (ref($_[0]) =~/HASH/) {
220 $self->{params} = shift; 235 $self->{params} = shift;
221 } elsif ( $_[0] =~ '') { 236 } elsif ( !defined($_[0]) or $_[0] =~ '') {
222 # do nothing (read) 237 # do nothing (read)
223 } else { 238 } else {
224 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";
225 } 240 }
226 $self->{params}; 241 $self->{params};
235sub submitActionAlias { 250sub submitActionAlias {
236 my $self = shift; 251 my $self = shift;
237 $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
238 $self->{submitActionAlias}; 253 $self->{submitActionAlias};
239} 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}
240sub returnFieldName { 271sub returnFieldName {
241 my $self = shift; 272 my $self = shift;
242 $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
243 $self->{returnFieldName}; 274 $self->{returnFieldName};
244} 275}
245sub codebase { 276sub codebase {
246 my $self = shift; 277 my $self = shift;
247 $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
248 $self->{codebase}; 279 $self->{codebase};
249} 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}
250sub appletName { 301sub appletName {
251 my $self = shift; 302 my $self = shift;
252 $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
253 $self->{appletName}; 304 $self->{appletName};
254} 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}
255sub appletId { 312sub appletId {
256 my $self = shift; 313 appletName(@_);
257 $self->{appletId} = shift ||$self->{appletId}; # replace the current appletName if non-empty
258 $self->{appletId};
259} 314}
260sub xmlString { 315sub state {
261 my $self = shift; 316 my $self = shift;
262 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;
263 $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
264 $self->{base64_xmlString} =~ s/\n//g; 332 $self->{base64_config} =~ s/\n//g;
265 decode_base64($self->{base64_xmlString}); 333 decode_base64($self->{base64_config});
266} 334}
267 335sub base64_config {
268sub base64_xmlString{
269 my $self = shift; 336 my $self = shift;
270 $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};
271 $self->{base64_xmlString}; 339 $self->{base64_config};
272} 340}
273
274#FIXME 341#FIXME
275# need to be able to adjust header material 342# need to be able to adjust header material
276 343
277sub insertHeader { 344sub insertHeader {
278 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};
279 my $codebase = $self->{codebase}; 372 my $codebase = $self->{codebase};
280 my $appletId = $self->{appletId}; 373 my $appletId = $self->{appletName};
281 my $appletName = $self->{appletName}; 374 my $appletName = $self->{appletName};
282 my $base64_xmlString = $self->{base64_xmlString}; 375 my $archive = $self->{archive};
283 my $initializeAction = $self->{initializeActionAlias}; 376 my $width = $self->{width};
284 my $submitAction = $self->{submitActionAlias}; 377 my $height = $self->{height};
285 my $returnFieldName= $self->{returnFieldName}; 378 my $javaParameters = '';
286 my $headerText = $self->header(); 379 my $flashParameters = '';
287 $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
288 387
289 return $headerText;
290
291
292}
293
294
295# <script language="javascript">
296# if (AC_FL_RunContent == 0) {
297# alert("This page requires AC_RunActiveContent.js.");
298# } else {
299# AC_FL_RunContent(
300# 'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
301# 'width', '100%',
302# 'height', '100%',
303# 'src', 'http://$codebase/$appletName',
304# 'quality', 'high',
305# 'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
306# 'align', 'middle',
307# 'play', 'true',
308# 'loop', 'true',
309# 'scale', 'showall',
310# 'wmode', 'window',
311# 'devicefont', 'false',
312# 'id', '$appletId',
313# 'bgcolor', '#ffffcc',
314# 'name', '$appletName',
315# 'menu', 'true',
316# 'allowFullScreen', 'false',
317# 'allowScriptAccess','sameDomain',
318# 'movie', '$appletName',
319# 'salign', ''
320# ); //end AC code
321# }
322# </script>
323sub insertObject {
324 my $self = shift;
325 my $codebase = $self->{codebase};
326 my $appletId = $self->{appletId};
327 my $appletName = $self->{appletName};
328 $codebase = findAppletCodebase("$appletName.swf") unless $codebase;
329 $objectText = $self->{objectText}; 388 $objectText = $self->{objectText};
330 $objectText =~ s/(\$\w+)/$1/gee; 389 $objectText =~ s/(\$\w+)/$1/gee;
331 return $objectText; 390 return $objectText;
332} 391}
333
334sub initialize { 392sub initialize {
335 my $self = shift; 393 my $self = shift;
336 return q{ 394 return q{
337 <script> 395 <script>
338 initialize(); 396 initializeAction();
339 // this should really be done in the <body> tag 397 // this should really be done in the <body> tag
340 </script> 398 </script>
341 }; 399 };
342 400
343} 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
344 666
3451; 6671;

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

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9