[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 5662 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.9 2008/05/05 16:44:11 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.
415 // 415 //
416 // configurations are "permanent" 416 // configurations are "permanent"
417 ////////////////////////////////////////////////////////// 417 //////////////////////////////////////////////////////////
418 418
419 applet_config_list["$appletName"] = function() { 419 applet_config_list["$appletName"] = function() {
420 debug_add("applet_config_list:\n configure $appletName . $config ( $base64_config )" 420 debug_add("applet_config_list:\n attempt to configure $appletName . $config ( $base64_config ) if config function is defined: "
421 + typeof(getApplet("$appletName").$config)
422 ); 421 );
423 try { 422 try {
424 if (( typeof(getApplet("$appletName").$config) == "function" ) ) { 423 if (( typeof(getApplet("$appletName").$config) == "function" ) ) {
425 debug_add("configure $appletName"); 424 debug_add("CONFIGURE $appletName");
426 getApplet("$appletName").$config(Base64.decode("$base64_config")); 425 getApplet("$appletName").$config(Base64.decode("$base64_config"));
427 } 426 }
428 } catch(e) { 427 } catch(e) {
429 alert("Error executing configuration command $config for $appletName: " + e ); 428 alert("Error executing configuration command $config for $appletName: " + e );
430 } 429 }
435 // state can vary as the applet is manipulated -- it is reset from the questions _state values 434 // state can vary as the applet is manipulated -- it is reset from the questions _state values
436 // 435 //
437 ////////////////////////////////////////////////////////// 436 //////////////////////////////////////////////////////////
438 437
439 applet_setState_list["$appletName"] = function(state) { 438 applet_setState_list["$appletName"] = function(state) {
440 debug_add("Begin setState"); 439 debug_add("Begin setState for applet $appletName");
440 debug_add("Obtain state from $appletName"+"_state");
441 state = state || getQE("$appletName"+"_state").value; 441 state = state || getQE("$appletName"+"_state").value;
442 if ( base64Q(state) ) { 442 if ( base64Q(state) ) {
443 state=Base64.decode(state); 443 state=Base64.decode(state);
444 } 444 }
445 if (state.match(/<xml/i) || state.match(/<?xml/i) ) { // if state starts with <?xml 445 if (state.match(/<xml/i) || state.match(/<?xml/i) ) { // if state starts with <?xml
458 } else if (debug) { 458 } else if (debug) {
459 alert("new state was empty string or did not begin with <xml-- state was not reset"); 459 alert("new state was empty string or did not begin with <xml-- state was not reset");
460 } 460 }
461 }; 461 };
462 applet_getState_list["$appletName"] = function () { 462 applet_getState_list["$appletName"] = function () {
463 if (debug) { alert("getState for applet $appletName");} 463 debug_add("get current state for applet $appletName and store it in $appletName"+"_state");
464 var applet = getApplet("$appletName"); 464 var applet = getApplet("$appletName");
465 try { 465 try {
466 if (( typeof(applet.$getState) == "function" ) ) { // there may be no state function 466 if (( typeof(applet.$getState) == "function" ) ) { // there may be no state function
467 state = applet.$getState(); // get state in xml format 467 state = applet.$getState(); // get state in xml format
468 } 468 }
469 if (debug) alert("state is " + state); 469
470 if (!debug) {state = Base64.encode(state) }; // replace state by encoded version unless in debug mode 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
471 getQE("$appletName"+"_state").value = state; //place in state htmlItem (debug: textarea, otherwise hidden) 472 getQE("$appletName"+"_state").value = state; //place state in input item (debug: textarea, otherwise: hidden)
472 } catch (e) { 473 } catch (e) {
473 alert("Error in getting state for $appletName " + e ); 474 alert("Error in getting state for $appletName " + e );
474 } 475 }
475 }; 476 };
476 477
504 } 505 }
505 if (typeof(applet_reportsLoaded_list["$appletName"]) !="undefined" && applet_reportsLoaded_list["$appletName"] != 0 ) { 506 if (typeof(applet_reportsLoaded_list["$appletName"]) !="undefined" && applet_reportsLoaded_list["$appletName"] != 0 ) {
506 debug_add( "applet reports that it is loaded " + applet_reportsLoaded_list["$appletName"] ); 507 debug_add( "applet reports that it is loaded " + applet_reportsLoaded_list["$appletName"] );
507 ready =1; 508 ready =1;
508 } 509 }
509 applet_isReady_list["$appletName"]=ready; 510 applet_isReady_list["$appletName"]= ready;
510 return(ready); 511 return(ready);
511 } 512 }
512 513
513 applet_initializeAction_list["$appletName"] = function (state) { 514 applet_initializeAction_list["$appletName"] = function (state) {
514 applet_setState_list["$appletName"](state); 515 applet_setState_list["$appletName"](state);
515 }; 516 };
516 517
517 applet_submitAction_list["$appletName"] = function () { 518 applet_submitAction_list["$appletName"] = function () {
519 if (! applet_isReady_list["$appletName"] ) {
520 alert("$appletName is not ready");
521 }
518 applet_getState_list["$appletName"](); 522 applet_getState_list["$appletName"]();
519 getQE("$returnFieldName").value = getApplet("$appletName").sendData(); //FIXME -- not needed in general? 523 //getQE("$returnFieldName").value = getApplet("$appletName").sendData(); //FIXME -- not needed in general?
520 }; 524 };
521 </script> 525 </script>
522 526
523END_HEADER_SCRIPT 527END_HEADER_SCRIPT
524 528
641 width = "$width" 645 width = "$width"
642 height = "$height" 646 height = "$height"
643 MAYSCRIPT 647 MAYSCRIPT
644 > 648 >
645 $javaParameters 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>)
646 </applet> 654 </applet>
647END_OBJECT_TEXT 655END_OBJECT_TEXT
648 656
649sub new { 657sub new {
650 my $class = shift; 658 my $class = shift;

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

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9