diff scripts/pjx_loading.pl @ 0:477258d09353 boosterpack

[svn r1] initial import
author robert
date Sun, 30 Aug 2009 02:19:26 -0400
parents
children
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/scripts/pjx_loading.pl	Sun Aug 30 02:19:26 2009 -0400
     1.3 @@ -0,0 +1,66 @@
     1.4 +#!C:/strawberry/perl/bin/perl.exe
     1.5 +
     1.6 +use strict;
     1.7 +use CGI::Ajax;
     1.8 +use CGI;
     1.9 +
    1.10 +my $func = sub {
    1.11 +  my $input = shift;
    1.12 +  my $i=6000000;
    1.13 +  while($i--){ }
    1.14 +  return "got input: $input " . 'done';
    1.15 +};
    1.16 +
    1.17 +
    1.18 +sub Show_HTML {
    1.19 +my  $html = <<EOT;
    1.20 +
    1.21 +<html>
    1.22 +<head><title>CGI::Ajax Example</title>
    1.23 +
    1.24 +<script type=text/javascript>
    1.25 +// these 2 functions provide access to the javascript events. Since
    1.26 +// is an object anything here will apply to any div that uses a
    1.27 +// cgi::ajx registered function. as a convenience, we send in the id
    1.28 +// of the current element (el) below. but that can also be accessed
    1.29 +// this.target;
    1.30 +// if these are not defined, no problem...
    1.31 +pjx.prototype.pjxInitialized = function(el){
    1.32 +  document.getElementById(el).innerHTML = 'Loading';
    1.33 +  document.getElementById(el).style.backgroundColor = '#ccc';
    1.34 +}
    1.35 +
    1.36 +pjx.prototype.pjxCompleted = function(el){
    1.37 +  // here we use this.target:
    1.38 +  // since this is a prototype function, we have access to all of hte 
    1.39 +  // pjx obejct properties. 
    1.40 +  document.getElementById(this.target).style.backgroundColor = '#fff';
    1.41 +}
    1.42 +
    1.43 +</script>
    1.44 +</head>
    1.45 +<body>
    1.46 +<form>
    1.47 +Enter Something:&nbsp;
    1.48 +  <input type="text" name="val1" id="val1" size="6" onkeyup="jsfunc( ['val1'], 'result' ); return true;"><br>
    1.49 +Enter Something:&nbsp;
    1.50 +  <input type="text" name="val2" id="val2" size="6" onkeyup="jsfunc( ['val2'], 'another' ); return true;"><br>
    1.51 +    <hr>
    1.52 +    <div id="result" style="border: 1px solid black;
    1.53 +          width: 440px; height: 80px; overflow: auto">
    1.54 +    </div>
    1.55 +
    1.56 +    <div id="another" style="border: 1px solid black;
    1.57 +          width: 440px; height: 80px; overflow: auto">
    1.58 +    </div>
    1.59 +</form>
    1.60 +</body>
    1.61 +</html>
    1.62 +
    1.63 +EOT
    1.64 +
    1.65 +}
    1.66 +
    1.67 +my $cgi = new CGI();  # create a new CGI object
    1.68 +my $pjx = new CGI::Ajax( 'jsfunc' => $func );
    1.69 +print $pjx->build_html($cgi,\&Show_HTML);