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.6 2008/03/25 21:59:06 gage Exp $ |
4 | # $CVSHeader: pg/lib/Applet.pm,v 1.7 2008/03/26 01:25:52 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. |
… | |
… | |
193 | width => 550, |
193 | width => 550, |
194 | height => 400, |
194 | height => 400, |
195 | base64_state => '', |
195 | base64_state => '', |
196 | base64_config => '', |
196 | base64_config => '', |
197 | getStateAlias => 'getXML', |
197 | getStateAlias => 'getXML', |
198 | setStateAlias => 'setState', |
198 | setStateAlias => 'setXML', |
199 | configAlias => 'config', |
199 | configAlias => 'config', |
200 | initializeActionAlias => 'setXML', |
200 | initializeActionAlias => 'setXML', |
201 | submitActionAlias => 'getXML', |
201 | submitActionAlias => 'getXML', |
202 | returnFieldName => 'receivedField', |
202 | returnFieldName => 'receivedField', |
203 | headerText => DEFAULT_HEADER_TEXT(), |
203 | headerText => DEFAULT_HEADER_TEXT(), |
… | |
… | |
420 | } |
420 | } |
421 | // |
421 | // |
422 | //STATE |
422 | //STATE |
423 | // |
423 | // |
424 | // state can vary as the applet is manipulated. |
424 | // state can vary as the applet is manipulated. |
425 | applet_setState_list["$appletName"] = function(state) { |
425 | applet_setState_list["$appletName"] = function(state) { |
|
|
426 | if (debug) { alert("set state for $appletName to " + state);} |
426 | state = state || getQE("$appletName"+"_state").value |
427 | state = state || getQE("$appletName"+"_state").value |
427 | if (state.match("\S") ) { // if state is not all white space |
428 | if (state.match(/<xml/i) || state.match(/<?xml/i) ) { // if state is not all white space |
428 | if ( base64Q(state) ) { |
429 | if ( base64Q(state) ) { |
429 | state=Base64.decode(state); |
430 | state=Base64.decode(state); |
430 | } |
431 | } |
431 | if (debug) { alert("set state for $appletName to " + state);} |
432 | alert("set (decoded) state for $appletName to " + state); |
432 | try { |
433 | try { |
433 | if (debug || !( typeof(getApplet("$appletName").$setState) =="undefined" ) ) { |
434 | if (debug || !( typeof(getApplet("$appletName").$setState) =="undefined" ) ) { |
434 | getApplet("$appletName").$setState( state ); |
435 | getApplet("$appletName").$setState( state ); |
435 | } |
436 | } |
436 | } catch(e) { |
437 | } catch(e) { |
437 | alert("Error in setting state of $appletName using command $setState : " + e ); |
438 | alert("Error in setting state of $appletName using command $setState : " + e ); |
438 | } |
439 | } |
|
|
440 | } else if (debug) { |
|
|
441 | alert("new state was empty string or did not begin with <xml-- state was not reset"); |
439 | } |
442 | } |
440 | }; |
443 | }; |
441 | applet_getState_list["$appletName"] = function () { |
444 | applet_getState_list["$appletName"] = function () { |
442 | if (debug) { alert("getState for applet $appletName");} |
445 | if (debug) { alert("getState for applet $appletName");} |
443 | try { |
446 | try { |