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