[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 5619 Revision 5622
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.4 2007/12/20 00:04:39 gage Exp $ 4# $CVSHeader: pg/lib/Applet.pm,v 1.5 2008/03/16 14:39:39 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.
339#FIXME 339#FIXME
340# need to be able to adjust header material 340# need to be able to adjust header material
341 341
342sub insertHeader { 342sub insertHeader {
343 my $self = shift; 343 my $self = shift;
344 my $codebase = $self->codebase; 344 my $codebase = $self->codebase;
345 my $appletId = $self->appletId; 345 my $appletId = $self->appletId;
346 my $appletName = $self->appletName; 346 my $appletName = $self->appletName;
347 my $base64_initialState = $self->base64_state; 347 my $base64_initialState = $self->base64_state;
348 my $initializeAction = $self->initializeActionAlias; 348 my $initializeAction = $self->initializeActionAlias;
349 my $submitAction = $self->submitActionAlias; 349 my $submitAction = $self->submitActionAlias;
350 my $setState = $self->setStateAlias; 350 my $setState = $self->setStateAlias;
351 my $getState = $self->getStateAlias; 351 my $getState = $self->getStateAlias;
352 my $config = $self->configAlias; 352 my $config = $self->configAlias;
353 my $base64_config = $self->base64_config; 353 my $base64_config = $self->base64_config;
354 my $debugMode = ($self->debug) ? "1": "0"; 354 my $debugMode = ($self->debug) ? "1": "0";
355 my $returnFieldName = $self->{returnFieldName}; 355 my $returnFieldName = $self->{returnFieldName};
356# my $encodeStateQ = ($self->debug)?'' : "state = Base64.encode(state);"; # in debug mode base64 encoding is not used. 356# my $encodeStateQ = ($self->debug)?'' : "state = Base64.encode(state);"; # in debug mode base64 encoding is not used.
357# my $decodeStateQ = "if (!state.match(/<XML>*/i) ) {state = Base64.decode(state)}"; # decode if <XML> is not present 357# my $decodeStateQ = "if (!state.match(/<XML>*/i) ) {state = Base64.decode(state)}"; # decode if <XML> is not present
358 my $headerText = $self->header(); 358 my $headerText = $self->header();
359
359 $headerText =~ s/(\$\w+)/$1/gee; # interpolate variables p17 of Cookbook 360 $headerText =~ s/(\$\w+)/$1/gee; # interpolate variables p17 of Cookbook
360 361
361 return $headerText; 362 return $headerText;
362 363
363 364
417 // 418 //
418 //STATE 419 //STATE
419 // 420 //
420 // state can vary as the applet is manipulated. 421 // state can vary as the applet is manipulated.
421 applet_setState_list["$appletName"] = function(state) { 422 applet_setState_list["$appletName"] = function(state) {
422 state = state || getQE("$appletName"+"_state").value || "<xml></xml>"; 423 state = state || getQE("$appletName"+"_state").value
423 if ( base64Q(state) ) { state=Base64.decode(state);} 424 if (state.match("\S") ) { // if state is not all white space
425 if ( base64Q(state) ) {
426 state=Base64.decode(state);
427 }
424 if (debug) { alert("set state for $appletName to " + state);} 428 if (debug) { alert("set state for $appletName to " + state);}
425 try { 429 try {
426 if (debug || !( typeof(getApplet("$appletName").$setState) =="undefined" ) ) { 430 if (debug || !( typeof(getApplet("$appletName").$setState) =="undefined" ) ) {
427 getApplet("$appletName").$setState( state ); 431 getApplet("$appletName").$setState( state );
428 } 432 }
429 } catch(e) { 433 } catch(e) {
430 alert("Error in setting state of $appletName: " + e ); 434 alert("Error in setting state of $appletName using command $setState : " + e );
431 } 435 }
436 }
432 }; 437 };
433 applet_getState_list["$appletName"] = function () { 438 applet_getState_list["$appletName"] = function () {
434 if (debug) { alert("getState for applet $appletName");} 439 if (debug) { alert("getState for applet $appletName");}
435 try { 440 try {
436 var applet = getApplet("$appletName"); 441 var applet = getApplet("$appletName");

Legend:
Removed from v.5619  
changed lines
  Added in v.5622

aubreyja at gmail dot com
ViewVC Help
Powered by ViewVC 1.0.9