[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 5574 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/macros/PG.pl,v 1.34 2007/10/25 17:11:59 sh002i 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"></script>
100 101
101 <script type="text/javascript" src="http://hosted2.webwork.rochester.edu/webwork2_files/js/BrowserSniffer.js"> 102=head2 Default javaScript functions placed in header
102 </script>
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 function getBrowser() {
112 return new BrowserSniffer();
113 }
114
115 function initialize() {
116 getFlashMovie("$appletId").$initializeAction("$base64_xmlString");
117 }
118 function submitAction() {
119 document.problemMainForm.$returnFieldName.value = getFlashMovie("$appletId").$submitAction();
120 }
121 103
122 </script>, 104=pod
123
124END_HEADER_SCRIPT
125 105
106These functions are automatically defined for use for
107any javaScript placed in the text of a PG question.
126 108
127# <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" 109 getApplet(appletName) -- finds the applet path in the DOM
128# width="550" height="400" id="$appletId" align="middle">
129# <param name="allowScriptAccess" value="sameDomain" />
130# <param name="allowFullScreen" value="false" />
131# <param name="movie" value="$appletName.swf" />
132# <param name="quality" value="high" />
133# <param name="bgcolor" value="#ffffcc" />
134# <embed src="$codebase/$appletName.swf" quality="high" bgcolor="#ffffcc" width="550" height="400" name="$appletName"
135# align="middle" id="$appletId",
136# align="middle" allowScriptAccess="sameDomain"
137# allowFullScreen="false"
138# type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
139# <param name="quality" value="high" /><param name="bgcolor" value="#ffffcc" />
140# </object>
141 110
142use constant DEFAULT_OBJECT_TEXT =><<'END_OBJECT_TEXT'; 111 submitAction() -- calls the submit action of the applets
143 <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
144 id="ExternalInterface" width="500" height="375"
145 codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">
146 <param name="movie" value="$codebase/$appletName.swf" />
147 <param name="quality" value="high" />
148 <param name="bgcolor" value="#869ca7" />
149 <param name="allowScriptAccess" value="sameDomain" />
150 <embed src="$codebase/$appletName.swf" quality="high" bgcolor="#869ca7"
151 width="550" height="400" name="$appletName" align="middle" id="$appletID"
152 play="true" loop="false" quality="high" allowScriptAccess="sameDomain"
153 type="application/x-shockwave-flash"
154 pluginspage="http://www.macromedia.com/go/getflashplayer">
155 </embed>
156 112
157 </object> 113 initializeWWquestion() -- calls the initialize action of the applets
158END_OBJECT_TEXT 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
186
187=cut
188
189
159 190
160 191
161sub new { 192sub new {
162 my $class = shift; 193 my $class = shift;
163 my $self = { 194 my $self = {
164 host =>'',
165 port => '',
166 path => '',
167 appletName =>'', 195 appletName =>'',
196 code=>'',
168 codebase=>'', 197 codebase=>'',
169 appletId =>'', 198# appletId =>'', #always use identical applet Id's and applet Names
170 params =>undef, 199 params =>undef,
171 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',
172 initializeActionAlias => 'setupProblem', 207 initializeActionAlias => 'setXML',
173 submitActionAlias => 'checkAnswer', 208 submitActionAlias => 'getXML',
174 returnFieldName => 'receivedField', 209 submitActionScript => '', # script executed on submitting the WW question
210 answerBox => 'answerBox',
175 headerText => DEFAULT_HEADER_TEXT(), 211 headerText => DEFAULT_HEADER_TEXT(),
176 objectText => DEFAULT_OBJECT_TEXT(), 212 objectText => '',
213 debug => 0,
177 @_, 214 @_,
178 }; 215 };
179 bless $self, $class; 216 bless $self, $class;
180 #$self -> _initialize(@_); 217 $self->state('<xml></xml>');
218 $self->config('<xml></xml>');
181 return $self; 219 return $self;
182} 220}
183 221
184sub header { 222sub header {
185 my $self = shift; 223 my $self = shift;
201} 239}
202sub params { 240sub params {
203 my $self = shift; 241 my $self = shift;
204 if (ref($_[0]) =~/HASH/) { 242 if (ref($_[0]) =~/HASH/) {
205 $self->{params} = shift; 243 $self->{params} = shift;
206 } elsif ( $_[0] =~ '') { 244 } elsif ( !defined($_[0]) or $_[0] =~ '') {
207 # do nothing (read) 245 # do nothing (read)
208 } else { 246 } else {
209 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";
210 } 248 }
211 $self->{params}; 249 $self->{params};
220sub submitActionAlias { 258sub submitActionAlias {
221 my $self = shift; 259 my $self = shift;
222 $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
223 $self->{submitActionAlias}; 261 $self->{submitActionAlias};
224} 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}
225sub returnFieldName { 284sub returnFieldName {
226 my $self = shift; 285 my $self = shift;
227 $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
228 $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};
229} 293}
230sub codebase { 294sub codebase {
231 my $self = shift; 295 my $self = shift;
232 $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
233 $self->{codebase}; 297 $self->{codebase};
234} 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}
235sub appletName { 319sub appletName {
236 my $self = shift; 320 my $self = shift;
237 $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
238 $self->{appletName}; 322 $self->{appletName};
239} 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}
240sub appletId { 330sub appletId {
241 my $self = shift; 331 appletName(@_);
242 $self->{appletId} = shift ||$self->{appletId}; # replace the current appletName if non-empty
243 $self->{appletId};
244} 332}
245sub xmlString { 333sub state {
246 my $self = shift; 334 my $self = shift;
247 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;
248 $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
249 $self->{base64_xmlString} =~ s/\n//g; 350 $self->{base64_config} =~ s/\n//g;
250 decode_base64($self->{base64_xmlString}); 351 decode_base64($self->{base64_config});
251} 352}
252 353sub base64_config {
253sub base64_xmlString{
254 my $self = shift; 354 my $self = shift;
255 $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};
256 $self->{base64_xmlString}; 357 $self->{base64_config};
257} 358}
258
259#FIXME 359#FIXME
260# need to be able to adjust header material 360# need to be able to adjust header material
261 361
262sub insertHeader { 362sub insertHeader {
263 my $self = shift; 363 my $self = shift;
264 my $codebase = $self->{codebase}; 364 my $codebase = $self->codebase;
265 my $appletId = $self->{appletId}; 365 my $appletId = $self->appletId;
266 my $appletName = $self->{appletName}; 366 my $appletName = $self->appletName;
267 my $base64_xmlString = $self->{base64_xmlString}; 367 my $base64_initialState = $self->base64_state;
268 my $initializeAction = $self->{initializeActionAlias}; 368 my $initializeAction = $self->initializeActionAlias;
269 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";
270 my $returnFieldName= $self->{returnFieldName}; 376 my $returnFieldName = $self->{returnFieldName};
377 my $answerBox = $self->{answerBox};
271 my $headerText = $self->header(); 378 my $headerText = $self->header();
379
272 $headerText =~ s/(\$\w+)/$1/gee; # interpolate variables p17 of Cookbook 380 $headerText =~ s/(\$\w+)/$1/gee; # interpolate variables p17 of Cookbook
273 381
274 return $headerText; 382 return $headerText;
275 383
276 384
277} 385}
278 386
279
280# <script language="javascript">
281# if (AC_FL_RunContent == 0) {
282# alert("This page requires AC_RunActiveContent.js.");
283# } else {
284# AC_FL_RunContent(
285# 'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0',
286# 'width', '100%',
287# 'height', '100%',
288# 'src', 'http://$codebase/$appletName',
289# 'quality', 'high',
290# 'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
291# 'align', 'middle',
292# 'play', 'true',
293# 'loop', 'true',
294# 'scale', 'showall',
295# 'wmode', 'window',
296# 'devicefont', 'false',
297# 'id', '$appletId',
298# 'bgcolor', '#ffffcc',
299# 'name', '$appletName',
300# 'menu', 'true',
301# 'allowFullScreen', 'false',
302# 'allowScriptAccess','sameDomain',
303# 'movie', '$appletName',
304# 'salign', ''
305# ); //end AC code
306# }
307# </script>
308sub insertObject { 387sub insertObject {
309 my $self = shift; 388 my $self = shift;
389 my $code = $self->{code};
310 my $codebase = $self->{codebase}; 390 my $codebase = $self->{codebase};
311 my $appletId = $self->{appletId}; 391 my $appletId = $self->{appletName};
312 my $appletName = $self->{appletName}; 392 my $appletName = $self->{appletName};
313 $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
314 $objectText = $self->{objectText}; 406 $objectText = $self->{objectText};
315 $objectText =~ s/(\$\w+)/$1/gee; 407 $objectText =~ s/(\$\w+)/$1/gee;
316 return $objectText; 408 return $objectText;
317} 409}
318
319sub initialize { 410# sub initialize {
320 my $self = shift; 411# my $self = shift;
321 return q{ 412# return q{
322 <script> 413# <script>
323 initialize(); 414# initializeAllApplets();
324 // this should really be done in the <body> tag 415# // this should really be done in the <body> tag
325 </script> 416# </script>
326 }; 417# };
418#
419# }
420########################################################
421# HEADER material for one flash or java applet
422########################################################
327 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
328} 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
329 720
3301; 7211;

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

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9