[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 5994
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.14 2009/01/28 17:07:08 gage Exp $
5# 5#
6# This program is free software; you can redistribute it and/or modify it under 6# This program is free software; you can redistribute it and/or modify it under
7# the terms of either: (a) the GNU General Public License as published by the 7# the terms of either: (a) the GNU General Public License as published by the
8# Free Software Foundation; either version 2, or (at your option) any later 8# Free Software Foundation; either version 2, or (at your option) any later
9# version, or (b) the "Artistic License" which comes with this package. 9# version, or (b) the "Artistic License" which comes with this package.
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">
104
105 var flash;
106 function getFlashMovie(movieName) {
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
120 </script>
121
122END_HEADER_SCRIPT
123
124
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# width="550" height="400" id="$appletId" align="middle">
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 103
140=pod 104=pod
141 105
142The secret to making this applet work with IE in addition to normal browsers 106These functions are automatically defined for use for
143is the addition of the C(<form></form>) construct just before the object. 107any javaScript placed in the text of a PG question.
144 108
145For some reason IE has trouble locating a flash object which is contained 109 getApplet(appletName) -- finds the applet path in the DOM
146within a form. Adding this second blank form with the larger problemMainForm
147seems to solve the problem.
148 110
149This follows method2 of the advice given in url(http://kb.adobe.com/selfservice/viewContent.do?externalId=kb400730&sliceId=2) 111 submitAction() -- calls the submit action of the applets
150Method1 and methods involving SWFObject(Geoff Stearns) and SWFFormFix (Steve Kamerman) have yet to be fully investigated: 112
151http://devel.teratechnologies.net/swfformfix/swfobject_swfformfix_source.js 113 initializeWWquestion() -- calls the initialize action of the applets
152http://www.teratechnologies.net/stevekamerman/index.php?m=01&y=07&entry=entry070101-033933 114
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
119 getQuestionElement(name) -- long form of getQE(name)
120
121 listQuestionElements() -- for discovering the names of inputs in the
122 PG question. An alert dialog will list all
123 of the elements.
124 Usage: Place this at the END of the question, just before END_DOCUMENT():
125
126 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
141
142 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 object stores the text which places the applet on the html page
155
156 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 submitActionAlias -- (default: submitAction)the name of the javaScript subroutine called when the submit button of the
181 .pg question is pressed.
182 answerBox -- name of answer box to return answer to: default defaultAnswerBox
183 getAnswer -- (formerly sendData) get student answer from applet and place in answerBox
184 returnFieldName -- (deprecated) synonmym for answerBox
185
153 186
154=cut 187=cut
155 188
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 189
172 </object>
173END_OBJECT_TEXT
174 190
175 191
176sub new { 192sub new {
177 my $class = shift; 193 my $class = shift;
178 my $self = { 194 my $self = {
179 host =>'',
180 port => '',
181 path => '',
182 appletName =>'', 195 appletName =>'',
196 code=>'',
183 codebase=>'', 197 codebase=>'',
184 appletId =>'', 198# appletId =>'', #always use identical applet Id's and applet Names
185 params =>undef, 199 params =>undef,
186 base64_xmlString => 'foobar', 200 width => 550,
201 height => 400,
202 base64_state => undef, # this is an state to use for initializing the first occurence of the question.
203 base64_config => undef, # this is the initial (and final?) configuration
204 getStateAlias => 'getXML',
205 setStateAlias => 'setXML',
206 configAlias => 'config',
187 initializeActionAlias => 'setupProblem', 207 initializeActionAlias => 'setXML',
188 submitActionAlias => 'checkAnswer', 208 submitActionAlias => 'getXML',
189 returnFieldName => 'receivedField', 209 submitActionScript => '', # script executed on submitting the WW question
210 answerBox => 'answerBox',
190 headerText => DEFAULT_HEADER_TEXT(), 211 headerText => DEFAULT_HEADER_TEXT(),
191 objectText => DEFAULT_OBJECT_TEXT(), 212 objectText => '',
213 debug => 0,
192 @_, 214 @_,
193 }; 215 };
194 bless $self, $class; 216 bless $self, $class;
195 #$self -> _initialize(@_); 217 $self->state('<xml></xml>');
218 $self->config('<xml></xml>');
196 return $self; 219 return $self;
197} 220}
198 221
199sub header { 222sub header {
200 my $self = shift; 223 my $self = shift;
216} 239}
217sub params { 240sub params {
218 my $self = shift; 241 my $self = shift;
219 if (ref($_[0]) =~/HASH/) { 242 if (ref($_[0]) =~/HASH/) {
220 $self->{params} = shift; 243 $self->{params} = shift;
221 } elsif ( $_[0] =~ '') { 244 } elsif ( !defined($_[0]) or $_[0] =~ '') {
222 # do nothing (read) 245 # do nothing (read)
223 } else { 246 } else {
224 warn "You must enter a reference to a hash for the parameter list"; 247 warn "You must enter a reference to a hash for the parameter list";
225 } 248 }
226 $self->{params}; 249 $self->{params};
235sub submitActionAlias { 258sub submitActionAlias {
236 my $self = shift; 259 my $self = shift;
237 $self->{submitActionAlias} = shift ||$self->{submitActionAlias}; # replace the current contents if non-empty 260 $self->{submitActionAlias} = shift ||$self->{submitActionAlias}; # replace the current contents if non-empty
238 $self->{submitActionAlias}; 261 $self->{submitActionAlias};
239} 262}
263sub submitActionScript {
264 my $self = shift;
265 $self->{submitActionScript} = shift ||$self->{submitActionScript}; # replace the current contents if non-empty
266 $self->{submitActionScript};
267}
268sub getStateAlias {
269 my $self = shift;
270 $self->{getStateAlias} = shift ||$self->{getStateAlias}; # replace the current contents if non-empty
271 $self->{getStateAlias};
272}
273
274sub setStateAlias {
275 my $self = shift;
276 $self->{setStateAlias} = shift ||$self->{setStateAlias}; # replace the current contents if non-empty
277 $self->{setStateAlias};
278}
279sub configAlias {
280 my $self = shift;
281 $self->{configAlias} = shift ||$self->{configAlias}; # replace the current contents if non-empty
282 $self->{configAlias};
283}
240sub returnFieldName { 284sub returnFieldName {
241 my $self = shift; 285 my $self = shift;
242 $self->{returnFieldName} = shift ||$self->{returnFieldName}; # replace the current contents if non-empty 286 $self->{answerBox} = shift ||$self->{answerBox}; # replace the current contents if non-empty
243 $self->{returnFieldName}; 287 $self->{answerBox};
288}
289sub answerBox {
290 my $self = shift;
291 $self->{answerBox} = shift ||$self->{answerBox}; # replace the current contents if non-empty
292 $self->{answerBox};
244} 293}
245sub codebase { 294sub codebase {
246 my $self = shift; 295 my $self = shift;
247 $self->{codebase} = shift ||$self->{codebase}; # replace the current codebase if non-empty 296 $self->{codebase} = shift ||$self->{codebase}; # replace the current codebase if non-empty
248 $self->{codebase}; 297 $self->{codebase};
249} 298}
299sub code {
300 my $self = shift;
301 $self->{code} = shift ||$self->{code}; # replace the current code if non-empty
302 $self->{code};
303}
304sub height {
305 my $self = shift;
306 $self->{height} = shift ||$self->{height}; # replace the current height if non-empty
307 $self->{height};
308}
309sub width {
310 my $self = shift;
311 $self->{width} = shift ||$self->{width}; # replace the current width if non-empty
312 $self->{width};
313}
314sub archive {
315 my $self = shift;
316 $self->{archive} = shift ||$self->{archive}; # replace the current archive if non-empty
317 $self->{archive};
318}
250sub appletName { 319sub appletName {
251 my $self = shift; 320 my $self = shift;
252 $self->{appletName} = shift ||$self->{appletName}; # replace the current appletName if non-empty 321 $self->{appletName} = shift ||$self->{appletName}; # replace the current appletName if non-empty
253 $self->{appletName}; 322 $self->{appletName};
254} 323}
324sub debug {
325 my $self = shift;
326 my $new_flag = shift;
327 $self->{debug} = $new_flag if defined($new_flag);
328 $self->{debug};
329}
255sub appletId { 330sub appletId {
256 my $self = shift; 331 appletName(@_);
257 $self->{appletId} = shift ||$self->{appletId}; # replace the current appletName if non-empty
258 $self->{appletId};
259} 332}
260sub xmlString { 333sub state {
261 my $self = shift; 334 my $self = shift;
262 my $str = shift; 335 my $str = shift;
336 $self->{base64_state} = encode_base64($str) ||$self->{base64_state}; # replace the current string if non-empty
337 $self->{base64_state} =~ s/\n//g;
338 decode_base64($self->{base64_state});
339}
340
341sub base64_state{
342 my $self = shift;
343 $self->{base64_state} = shift ||$self->{base64_state}; # replace the current string if non-empty
344 $self->{base64_state};
345}
346sub config {
347 my $self = shift;
348 my $str = shift;
263 $self->{base64_xmlString} = encode_base64($str) ||$self->{base64_xmlString}; # replace the current string if non-empty 349 $self->{base64_config} = encode_base64($str) || $self->{base64_config}; # replace the current string if non-empty
264 $self->{base64_xmlString} =~ s/\n//g; 350 $self->{base64_config} =~ s/\n//g;
265 decode_base64($self->{base64_xmlString}); 351 decode_base64($self->{base64_config});
266} 352}
267 353sub base64_config {
268sub base64_xmlString{
269 my $self = shift; 354 my $self = shift;
270 $self->{base64_xmlString} = shift ||$self->{base64_xmlString}; # replace the current string if non-empty 355 $self->{base64_config} = shift ||$self->{base64_config}; # replace the current string if non-empty
356 $self->{base64_config} =$self->{base64_config};
271 $self->{base64_xmlString}; 357 $self->{base64_config};
272} 358}
273
274#FIXME 359#FIXME
275# need to be able to adjust header material 360# need to be able to adjust header material
276 361
277sub insertHeader { 362sub insertHeader {
278 my $self = shift; 363 my $self = shift;
279 my $codebase = $self->{codebase}; 364 my $codebase = $self->codebase;
280 my $appletId = $self->{appletId}; 365 my $appletId = $self->appletId;
281 my $appletName = $self->{appletName}; 366 my $appletName = $self->appletName;
282 my $base64_xmlString = $self->{base64_xmlString}; 367 my $base64_initialState = $self->base64_state;
283 my $initializeAction = $self->{initializeActionAlias}; 368 my $initializeAction = $self->initializeActionAlias;
284 my $submitAction = $self->{submitActionAlias}; 369 my $submitAction = $self->submitActionAlias;
370 my $submitActionScript = $self->submitActionScript;
371 my $setState = $self->setStateAlias;
372 my $getState = $self->getStateAlias;
373 my $config = $self->configAlias;
374 my $base64_config = $self->base64_config;
375 my $debugMode = ($self->debug) ? "1": "0";
285 my $returnFieldName= $self->{returnFieldName}; 376 my $returnFieldName = $self->{returnFieldName};
377 my $answerBox = $self->{answerBox};
286 my $headerText = $self->header(); 378 my $headerText = $self->header();
379
287 $headerText =~ s/(\$\w+)/$1/gee; # interpolate variables p17 of Cookbook 380 $headerText =~ s/(\$\w+)/$1/gee; # interpolate variables p17 of Cookbook
288 381
289 return $headerText; 382 return $headerText;
290 383
291 384
292} 385}
293 386
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 { 387sub insertObject {
324 my $self = shift; 388 my $self = shift;
389 my $code = $self->{code};
325 my $codebase = $self->{codebase}; 390 my $codebase = $self->{codebase};
326 my $appletId = $self->{appletId}; 391 my $appletId = $self->{appletName};
327 my $appletName = $self->{appletName}; 392 my $appletName = $self->{appletName};
328 $codebase = findAppletCodebase("$appletName.swf") unless $codebase; 393 my $archive = $self->{archive};
394 my $width = $self->{width};
395 my $height = $self->{height};
396 my $javaParameters = '';
397 my $flashParameters = '';
398 my %param_hash = %{$self->params()};
399 foreach my $key (keys %param_hash) {
400 $javaParameters .= qq!<param name ="$key" value = "$param_hash{$key}">\n!;
401 $flashParameters .= uri_escape($key).'='.uri_escape($param_hash{$key}).'&';
402 }
403 $flashParameters =~ s/\&$//; # trim last &
404
405
329 $objectText = $self->{objectText}; 406 $objectText = $self->{objectText};
330 $objectText =~ s/(\$\w+)/$1/gee; 407 $objectText =~ s/(\$\w+)/$1/gee;
331 return $objectText; 408 return $objectText;
332} 409}
333
334sub initialize { 410# sub initialize {
335 my $self = shift; 411# my $self = shift;
336 return q{ 412# return q{
337 <script> 413# <script>
338 initialize(); 414# initializeAllApplets();
339 // this should really be done in the <body> tag 415# // this should really be done in the <body> tag
340 </script> 416# </script>
341 }; 417# };
418#
419# }
420########################################################
421# HEADER material for one flash or java applet
422########################################################
342 423
424use constant DEFAULT_HEADER_TEXT =><<'END_HEADER_SCRIPT';
425 <script src="/webwork2_files/js/Base64.js" language="javascript">
426 </script>
427 <script src="/webwork2_files/js/ww_applet_support.js">
428 //upload functions stored in /opt/webwork/webwork2/htdocs/js ...
429 </script>
430 <script language="JavaScript">
431
432 // set debug mode for this applet
433 set_debug($debugMode);
434
435 //////////////////////////////////////////////////////////
436 //TEST code
437 //
438 //
439 //////////////////////////////////////////////////////////
440
441 ww_applet_list["$appletName"] = new ww_applet("$appletName");
442
443
444 ww_applet_list["$appletName"].code = "$code";
445 ww_applet_list["$appletName"].codebase = "$codebase";
446 ww_applet_list["$appletName"].appletID = "$appletID";
447 ww_applet_list["$appletName"].base64_state = "$base64_initializationState";
448 ww_applet_list["$appletName"].base64_config = "$base64_config";
449 ww_applet_list["$appletName"].getStateAlias = "$getState";
450 ww_applet_list["$appletName"].setStateAlias = "$setState";
451 ww_applet_list["$appletName"].configAlias = "$config";
452 ww_applet_list["$appletName"].initializeActionAlias = "$initializeAction";
453 ww_applet_list["$appletName"].submitActionAlias = "$submitAction";
454 ww_applet_list["$appletName"].submitActionScript = "$submitActionScript";
455 ww_applet_list["$appletName"].answerBox = "$answerBox";
456 ww_applet_list["$appletName"].debug = "$debugMode";
457
458
459 //////////////////////////////////////////////////////////
460 //CONFIGURATIONS
461 //
462 // configurations are "permanent"
463 //////////////////////////////////////////////////////////
464
465// applet_config_list["$appletName"] = function() {
466// debug_add("applet_config_list:\n attempt to configure $appletName . $config ( $base64_config ) if config function is defined: "
467// );
468// try {
469// if (( typeof(getApplet("$appletName").$config) == "function" ) ) {
470// debug_add("CONFIGURE $appletName");
471// getApplet("$appletName").$config(Base64.decode("$base64_config"));
472// }
473// } catch(e) {
474// alert("Error executing configuration command $config for $appletName: " + e );
475// }
476// }
477// ////////////////////////////////////////////////////////////
478// //
479// //STATE:
480// // state can vary as the applet is manipulated -- it is reset from the questions _state values
481// //
482// //////////////////////////////////////////////////////////
483//
484// applet_setState_list["$appletName"] = function(state) {
485// debug_add("Begin setState for applet $appletName");
486// debug_add("Obtain state from $appletName"+"_state");
487// state = state || getQE("$appletName"+"_state").value;
488// if ( base64Q(state) ) {
489// state=Base64.decode(state);
490// }
491// if (state.match(/<xml/i) || state.match(/<?xml/i) ) { // if state starts with <?xml
492//
493// debug_add("applet_setState_list: \n set (decoded) state for $appletName to " +
494// state +"\nfunction type is " +typeof(getApplet("$appletName").$setState)
495// );
496// try {
497// if (( typeof(getApplet("$appletName").$setState) =="function" ) ) {
498// debug_add("setState for $appletName");
499// getApplet("$appletName").$setState( state );
500// }
501// } catch(e) {
502// alert("Error in setting state of $appletName using command $setState : " + e );
503// }
504// } else if (debug) {
505// alert("new state was empty string or did not begin with <xml-- state was not reset");
506// }
507// };
508// applet_getState_list["$appletName"] = function () {
509// debug_add("get current state for applet $appletName and store it in $appletName"+"_state");
510// var applet = getApplet("$appletName");
511// try {
512// if (( typeof(applet.$getState) == "function" ) ) { // there may be no state function
513// state = applet.$getState(); // get state in xml format
514// debug_add("state has type " + typeof(state));
515// state = String(state); // geogebra returned an object type instead of a string type
516// debug_add("state converted to type " + typeof(state));
517// }
518//
519// if (!debug) {
520// state = Base64.encode(state);
521// }; // replace state by encoded version unless in debug mode
522//
523// debug_add("state is "+state); // this should still be in plain text
524// getQE("$appletName"+"_state").value = state; //place state in input item (debug: textarea, otherwise: hidden)
525// } catch (e) {
526// alert("Error in getting state for $appletName " + e );
527// }
528// };
529//
530// ////////////////////////////////////////////////////////////
531// //
532// //INITIALIZE
533// //
534// ////////////////////////////////////////////////////////////
535//
536//
537// applet_checkLoaded_list["$appletName"] = function() { // this function returns 0 unless:
538// // applet has already been flagged as ready in applet_isReady_list
539// // applet.config is defined (or alias for .config)
540// // applet.setState is defined
541// // applet.isActive is defined
542// // applet reported that it is loaded by calling loadQ()
543// var ready = 0;
544// var applet = getApplet("$appletName");
545// if (!debug && applet_isReady_list["$appletName"]) {return(1)}; // memorize readiness in non-debug mode
546// if ( typeof(applet.$config) == "function") {
547// debug_add( "applet.config is " + typeof(applet.$config) );
548// ready = 1;
549// }
550// if( typeof(applet.$getState) == "function") {
551// debug_add( "applet.getState is " + typeof(applet.$getState) );
552// ready =1;
553// }
554// if (typeof(applet.isActive) == "function" && applet.isActive ) {
555// debug_add( "applet.isActive is " + typeof(applet.isActive) );
556// ready =1;
557// }
558// if (typeof(applet_reportsLoaded_list["$appletName"]) !="undefined" && applet_reportsLoaded_list["$appletName"] != 0 ) {
559// debug_add( "applet reports that it is loaded " + applet_reportsLoaded_list["$appletName"] );
560// ready =1;
561// }
562// applet_isReady_list["$appletName"]= ready;
563// return(ready);
564// }
565//
566// applet_initializeAction_list["$appletName"] = function (state) {
567// applet_setState_list["$appletName"](state);
568// };
569//
570// applet_submitAction_list["$appletName"] = function () {
571// if (! applet_isReady_list["$appletName"] ) {
572// alert("$appletName is not ready");
573// }
574// applet_getState_list["$appletName"]();
575// $submitActionScript
576// //getQE("$answerBox").value = getApplet("$appletName").getAnswer(); //FIXME -- not needed in general?
577// };
578 </script>
579
580END_HEADER_SCRIPT
581
582package FlashApplet;
583@ISA = qw(Applet);
584
585
586=head2 Insertion HTML code for FlashApplet
587
588=pod
589
590The secret to making this applet work with IE in addition to normal browsers
591is the addition of the C(<form></form>) construct just before the object.
592
593For some reason IE has trouble locating a flash object which is contained
594within a form. Adding this second blank form with the larger problemMainForm
595seems to solve the problem.
596
597This follows method2 of the advice given in url(http://kb.adobe.com/selfservice/viewContent.do?externalId=kb400730&sliceId=2)
598Method1 and methods involving SWFObject(Geoff Stearns) and SWFFormFix (Steve Kamerman) have yet to be fully investigated:
599http://devel.teratechnologies.net/swfformfix/swfobject_swfformfix_source.js
600http://www.teratechnologies.net/stevekamerman/index.php?m=01&y=07&entry=entry070101-033933
601
602 use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
603 <form></form>
604 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
605 id="$appletName" width="500" height="375"
606 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
607 <param name="movie" value="$codebase/$appletName.swf" />
608 <param name="quality" value="high" />
609 <param name="bgcolor" value="#869ca7" />
610 <param name="allowScriptAccess" value="sameDomain" />
611 <embed src="$codebase/$appletName.swf" quality="high" bgcolor="#869ca7"
612 width="$width" height="$height" name="$appletName" align="middle" id="$appletName"
613 play="true" loop="false" quality="high" allowScriptAccess="sameDomain"
614 type="application/x-shockwave-flash"
615 pluginspage="http://www.macromedia.com/go/getflashplayer">
616 </embed>
617
618 </object>
619 END_OBJECT_TEXT
620
621
622=cut
623
624use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
625 <form></form>
626 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
627 id="$appletName" width="500" height="375"
628 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
629 <param name="movie" value="$codebase/$appletName.swf" />
630 <param name="quality" value="high" />
631 <param name="bgcolor" value="#869ca7" />
632 <param name="allowScriptAccess" value="sameDomain" />
633 <param name="FlashVars" value="$flashParameters"/>
634 <embed src="$codebase/$appletName.swf" quality="high" bgcolor="#869ca7"
635 width="$width" height="$height" name="$appletName" align="middle" id="$appletName"
636 play="true" loop="false" quality="high" allowScriptAccess="sameDomain"
637 type="application/x-shockwave-flash"
638 pluginspage="http://www.macromedia.com/go/getflashplayer"
639 FlashVars="$flashParameters">
640 </embed>
641
642 </object>
643END_OBJECT_TEXT
644
645sub new {
646 my $class = shift;
647 $class -> SUPER::new( objectText => DEFAULT_OBJECT_TEXT(),
648 @_
649 );
650
343} 651}
652
653
654package JavaApplet;
655@ISA = qw(Applet);
656
657=head2 Insertion HTML code for JavaApplet
658
659=pod
660
661The secret to making this applet work with IE in addition to normal browsers
662is the addition of the C(<form></form>) construct just before the object.
663
664For some reason IE has trouble locating a flash object which is contained
665within a form. Adding this second blank form with the larger problemMainForm
666seems to solve the problem.
667
668This follows method2 of the advice given in url(http://kb.adobe.com/selfservice/viewContent.do?externalId=kb400730&sliceId=2)
669Method1 and methods involving SWFObject(Geoff Stearns) and SWFFormFix (Steve Kamerman) have yet to be fully investigated:
670http://devel.teratechnologies.net/swfformfix/swfobject_swfformfix_source.js
671http://www.teratechnologies.net/stevekamerman/index.php?m=01&y=07&entry=entry070101-033933
672
673 use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
674 <form></form>
675 <applet
676 code = "$code"
677 codebase = "$codebase"
678 archive = "$archive"
679 name = "$appletName"
680 id = "$appletName"
681 width = "$width"
682 height = "$height"
683 MAYSCRIPT
684 >
685 $javaParameters
686 </applet>
687 END_OBJECT_TEXT
688
689=cut
690
691use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT';
692 <form></form>
693 <applet
694 code = "$code"
695 codebase = "$codebase"
696 archive = "$archive"
697 name = "$appletName"
698 id = "$appletName"
699 width = "$width"
700 height = "$height"
701 MAYSCRIPT
702 >
703 $javaParameters
704
705 Sorry, the Applet could not be started. Please make sure that
706Java 1.4.2 (or later) is installed and activated.
707(<a href="http://java.sun.com/getjava">click here to install Java now</a>)
708 </applet>
709END_OBJECT_TEXT
710
711sub new {
712 my $class = shift;
713 $class -> SUPER::new( objectText => DEFAULT_OBJECT_TEXT(),
714 @_
715 );
716
717}
718
719
344 720
3451; 7211;

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

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9