annotate BoosterPack/scripts/.svn/text-base/pjx_loading.pl.svn-base @ 0:0d795f02a8bb tip

initial committ. what was I thinking?
author Robert McIntyre <rlm@mit.edu>
date Mon, 27 Sep 2010 16:57:26 -0400
parents
children
rev   line source
rlm@0 1 #!C:/strawberry/perl/bin/perl.exe
rlm@0 2
rlm@0 3 use strict;
rlm@0 4 use CGI::Ajax;
rlm@0 5 use CGI;
rlm@0 6
rlm@0 7 my $func = sub {
rlm@0 8 my $input = shift;
rlm@0 9 my $i=6000000;
rlm@0 10 while($i--){ }
rlm@0 11 return "got input: $input " . 'done';
rlm@0 12 };
rlm@0 13
rlm@0 14
rlm@0 15 sub Show_HTML {
rlm@0 16 my $html = <<EOT;
rlm@0 17
rlm@0 18 <html>
rlm@0 19 <head><title>CGI::Ajax Example</title>
rlm@0 20
rlm@0 21 <script type=text/javascript>
rlm@0 22 // these 2 functions provide access to the javascript events. Since
rlm@0 23 // is an object anything here will apply to any div that uses a
rlm@0 24 // cgi::ajx registered function. as a convenience, we send in the id
rlm@0 25 // of the current element (el) below. but that can also be accessed
rlm@0 26 // this.target;
rlm@0 27 // if these are not defined, no problem...
rlm@0 28 pjx.prototype.pjxInitialized = function(el){
rlm@0 29 document.getElementById(el).innerHTML = 'Loading';
rlm@0 30 document.getElementById(el).style.backgroundColor = '#ccc';
rlm@0 31 }
rlm@0 32
rlm@0 33 pjx.prototype.pjxCompleted = function(el){
rlm@0 34 // here we use this.target:
rlm@0 35 // since this is a prototype function, we have access to all of hte
rlm@0 36 // pjx obejct properties.
rlm@0 37 document.getElementById(this.target).style.backgroundColor = '#fff';
rlm@0 38 }
rlm@0 39
rlm@0 40 </script>
rlm@0 41 </head>
rlm@0 42 <body>
rlm@0 43 <form>
rlm@0 44 Enter Something:&nbsp;
rlm@0 45 <input type="text" name="val1" id="val1" size="6" onkeyup="jsfunc( ['val1'], 'result' ); return true;"><br>
rlm@0 46 Enter Something:&nbsp;
rlm@0 47 <input type="text" name="val2" id="val2" size="6" onkeyup="jsfunc( ['val2'], 'another' ); return true;"><br>
rlm@0 48 <hr>
rlm@0 49 <div id="result" style="border: 1px solid black;
rlm@0 50 width: 440px; height: 80px; overflow: auto">
rlm@0 51 </div>
rlm@0 52
rlm@0 53 <div id="another" style="border: 1px solid black;
rlm@0 54 width: 440px; height: 80px; overflow: auto">
rlm@0 55 </div>
rlm@0 56 </form>
rlm@0 57 </body>
rlm@0 58 </html>
rlm@0 59
rlm@0 60 EOT
rlm@0 61
rlm@0 62 }
rlm@0 63
rlm@0 64 my $cgi = new CGI(); # create a new CGI object
rlm@0 65 my $pjx = new CGI::Ajax( 'jsfunc' => $func );
rlm@0 66 print $pjx->build_html($cgi,\&Show_HTML);