diff buy.pl @ 42:ef8615de8a9c laserkard

[svn r43] implemented form memory
author rlm
date Wed, 27 Jan 2010 22:04:43 -0500
parents 1ac1409ea68c
children 1045db9799e3
line wrap: on
line diff
     1.1 --- a/buy.pl	Mon Jan 25 13:38:05 2010 -0500
     1.2 +++ b/buy.pl	Wed Jan 27 22:04:43 2010 -0500
     1.3 @@ -5,6 +5,7 @@
     1.4  use Storable;
     1.5  use CGI::Ajax;
     1.6  use CGI;
     1.7 +use JSON;
     1.8  
     1.9  
    1.10  
    1.11 @@ -20,17 +21,41 @@
    1.12  'inputbox'	=> \&inputbox,
    1.13  'display'	=> \&display,
    1.14  'change_rules' => \&change_rules,
    1.15 -'vanish'      => \&vanish
    1.16 +'vanish'      => \&vanish,
    1.17 +'updateForm'  => \&updateForm
    1.18  );
    1.19  
    1.20   
    1.21  
    1.22  my $pjx = CGI::Ajax->new(%hash);
    1.23 -#$pjx->JSDEBUG(1);
    1.24 -#$pjx->DEBUG(1);
    1.25  
    1.26 -print $pjx->build_html($q,\&gen,{-Cache_Control => 'no-store, no-cache, must-revalidate', -Pragma => 'no-cache'}); # this outputs the html for the page
    1.27  
    1.28 +# this outputs the html for the page
    1.29 +print $pjx->build_html($q,\&gen,{-Cache_Control => 'no-store, no-cache, must-revalidate', -Pragma => 'no-cache'}); 
    1.30 +
    1.31 + 
    1.32 +
    1.33 +sub updateForm
    1.34 +
    1.35 +{
    1.36 +	
    1.37 +	
    1.38 +	$key = shift;
    1.39 +	$value = shift;
    1.40 +	$hashString = shift;
    1.41 +	
    1.42 +	$perl_hash  = decode_json $hashString;
    1.43 +
    1.44 +	%fieldHash = %$perl_hash;
    1.45 +
    1.46 +
    1.47 +	$fieldHash{$key} = $value;
    1.48 +	$ref = \%fieldHash;
    1.49 +	
    1.50 +	$utf8_encoded_json_text = encode_json  $ref ;
    1.51 +	return $utf8_encoded_json_text;
    1.52 +
    1.53 +}
    1.54  
    1.55  
    1.56  
    1.57 @@ -97,19 +122,44 @@
    1.58  <div id = 'stupid'>
    1.59  
    1.60  
    1.61 -<input TYPE="image" src = "./images/templates/big_$materialcolor.jpg" 	onmouseover="pokedex(['args__big'],['pokedex']);" 	onclick="display(['template2'], ['display']); inputbox(['template2'], ['inputbox']);material(['template2'], ['materials']);redraw('bold');" ID="template2" NAME="template2" VALUE="big_$materialcolor"        > <br>
    1.62 +<input TYPE="image" src = "./images/templates/big_$materialcolor.jpg" 	
    1.63 +onmouseover="pokedex(['args__big'],['pokedex']);" 	
    1.64 +onclick=
    1.65 +"display(['template2'], ['display']); 
    1.66 +inputbox(['template2', 'formValues'], ['inputbox']);
    1.67 +material(['template2'], ['materials']);
    1.68 +redraw('bold');" ID="template2" NAME="template2" VALUE="big_$materialcolor">
    1.69 +<br>
    1.70  
    1.71    
    1.72  
    1.73 -<input TYPE="image" src = "./images/templates/basic_$materialcolor.jpg"  onmouseover="pokedex(['args__basic'],['pokedex']);"	onclick="display(['template3'], ['display']); inputbox(['template3'], ['inputbox']);material(['template3'], ['materials']);redraw('arrow');" ID="template3" NAME="template3" VALUE="basic_$materialcolor"          ><br>
    1.74 +<input TYPE="image" src = "./images/templates/basic_$materialcolor.jpg"
    1.75 +onmouseover="pokedex(['args__basic'],['pokedex']);"	
    1.76 +onclick=
    1.77 +"display(['template3'], ['display']); 
    1.78 +inputbox(['template3', 'formValues'], ['inputbox']);
    1.79 +material(['template3'], ['materials']);
    1.80 +redraw('arrow');" ID="template3" NAME="template3" VALUE="basic_$materialcolor"          ><br>
    1.81  
    1.82   
    1.83  
    1.84 -<input TYPE="image" src = "./images/templates/classic_$materialcolor.jpg"  onmouseover="pokedex(['args__classic'],['pokedex']);"	onclick="display(['template1'], ['display']); inputbox(['template1'], ['inputbox']);material(['template1'], ['materials']);redraw('classic');" ID="template1" NAME="template1" VALUE="classic_$materialcolor"    ><br>
    1.85 +<input TYPE="image" src = "./images/templates/classic_$materialcolor.jpg"  
    1.86 +onmouseover="pokedex(['args__classic'],['pokedex']);"	
    1.87 +onclick=
    1.88 +"display(['template1'], ['display']); 
    1.89 +inputbox(['template1', 'formValues'], ['inputbox']);
    1.90 +material(['template1'], ['materials']);
    1.91 +redraw('classic');" ID="template1" NAME="template1" VALUE="classic_$materialcolor"    ><br>
    1.92  
    1.93   
    1.94  
    1.95 -<input TYPE="image" src = "./images/templates/lines_$materialcolor.jpg"  onmouseover="pokedex(['args__lines'],['pokedex']);"	onclick="display(['template4'], ['display']); inputbox(['template4'], ['inputbox']);material(['template4'], ['materials']);redraw('direct');" ID="template4" NAME="template4" VALUE="lines_$materialcolor"           > 
    1.96 +<input TYPE="image" src = "./images/templates/lines_$materialcolor.jpg" 
    1.97 +onmouseover="pokedex(['args__lines'],['pokedex']);"	
    1.98 +onclick=
    1.99 +"display(['template4'], ['display']); 
   1.100 +inputbox(['template4', 'formValues'], ['inputbox']);
   1.101 +material(['template4'], ['materials']);
   1.102 +redraw('direct');" ID="template4" NAME="template4" VALUE="lines_$materialcolor"           > 
   1.103  
   1.104  	</div>
   1.105  	</div>
   1.106 @@ -148,7 +198,15 @@
   1.107  
   1.108  #grab the type of template we'll be using <<<<
   1.109  	$type = shift;
   1.110 -#	return $type;
   1.111 +	
   1.112 +	$hashString = shift;
   1.113 +	#return $hashString;
   1.114 +	
   1.115 +	$perl_hash  = decode_json $hashString;
   1.116 +
   1.117 +	%fieldHash = %$perl_hash;
   1.118 + 
   1.119 +
   1.120  # we have to care about both the type of template and the material and the color. these are stored in $type>>>>
   1.121  
   1.122  #Then, update with a special custon paypal form, taken from the paypal folder and specially designed for that particular template.
   1.123 @@ -157,8 +215,6 @@
   1.124  
   1.125  #take care of everythign but acrylic clear type
   1.126  
   1.127 -
   1.128 -
   1.129    {
   1.130      local( $/, *FH ) ;
   1.131      open( FH, "<./paypal/$type.paylist" ) or die "sudden flaming death\n";
   1.132 @@ -169,20 +225,32 @@
   1.133  #every type has it's own associated paylist file the contains the things we need
   1.134  
   1.135  $z = '<div id = "whatever" onmouseover='."\"pokedex([\'args__$type\'],[\'pokedex\']);\">".$z.'</div>';
   1.136 -return $z;
   1.137  
   1.138  
   1.139 +foreach my $key ( keys %fieldHash )
   1.140 +{
   1.141  
   1.142 +my $replace  = $fieldHash{$key};
   1.143 +
   1.144 +#id="Name" value = "PERL::NAME" 
   1.145 +
   1.146 +
   1.147 +$z =~ s/id="$key"/id="$key" value = "$replace"/g;
   1.148  
   1.149  
   1.150  }
   1.151  
   1.152  
   1.153 +return $z;
   1.154  
   1.155  
   1.156  
   1.157  
   1.158  
   1.159 +}
   1.160 +
   1.161 +
   1.162 +
   1.163  
   1.164  sub display
   1.165  {
   1.166 @@ -250,13 +318,24 @@
   1.167  $b = &display("big_acrylic_clear");
   1.168  $a =~ s/PERL-REPLACE::DISPLAY/$b/;
   1.169  
   1.170 -$b = &inputbox("big_acrylic_clear");
   1.171 +$initials = <<HERE;
   1.172 +{"Email":"rlm\@mit.edu","Name":"Robert McIntyre"}
   1.173 +HERE
   1.174 +
   1.175 +
   1.176 +$b = &inputbox("big_acrylic_clear", $initials);
   1.177  $a =~ s/PERL-REPLACE::INPUTBOX/$b/;
   1.178  
   1.179  $b = &pokedex('big');
   1.180  $a =~ s/PERL-REPLACE::POKEDEX/$b/;
   1.181  
   1.182  
   1.183 +
   1.184 +#$b = &updateForm('fuck','12', '{}');
   1.185 +$a =~ s/PERL::INITIALVALUES/$initials/;
   1.186 +
   1.187 +
   1.188 +
   1.189  return $a
   1.190  
   1.191