/* * SPL - The SPL Programming Language * Copyright (C) 2004, 2005 Clifford Wolf * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * wsfdemo.webspl: A simple WebSPL forms application */ load "wsf"; load "encode_xml"; object Calculator WsfComponent { var currentvalue = 0; var title = "Calculator"; var offmessage = "TURNED OFF"; method get_html() { if ( offmessage ~== "" ) return #file-as-template calc_on.spltpl; else return #file-as-template calc_off.spltpl; } method main() { while (1) { task_co_return(); if ( declared cgi.param.turnon ) offmessage = ""; if ( declared cgi.param.act ) { if ( cgi.param.act ~== 'add' ) currentvalue = currentvalue + cgi.param.num; if ( cgi.param.act ~== 'sub' ) currentvalue = currentvalue - cgi.param.num; if ( cgi.param.act ~== 'mul' ) currentvalue = currentvalue * cgi.param.num; if ( cgi.param.act ~== 'div' ) { if ( cgi.param.num == 0 ) { currentvalue = 0; offmessage = "DIV BY ZERO"; } else currentvalue = currentvalue / cgi.param.num; } } dirty = 1; } } } object Calclist WsfComponent { method get_html() { var html = '
'; html ~= 'Active DOM Update mechanism: '~ '${WsfDocument.domupdate}
\n'; var domupdlist = [ "none" => 0, "xmlhttprequest" => 0, "iframe" => 0 ]; foreach x ( domupdlist ) html ~= '  [ $x ]\n'; html ~= '  [ iframe+debug ]\n'; html ~= '  (not all methods work with all browsers, Mozilla/Firefox recommended)'; html ~= '

\n\n'; for (var i=0; i<32; i++) { if ( i%4 == 0 ) html ~= "\n"; else if ( i%4 == 3 ) html ~= "\n"; else html ~= "\n"; } html ~= '
${ children.[i].get_html_cached() }${ children.[i].get_html_cached() }
${ children.[i].get_html_cached() }

\n'; return html; } method init() { *WsfComponent.init(); for (var i=0; i<32; i++) { children.[i] = new Calculator(); children.[i].title = "Calc #$i"; } return this; } } var page = new WsfDocument(); page.root = new Calclist(); page.main();