comparison 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
comparison
equal deleted inserted replaced
41:c4747d955ac8 42:ef8615de8a9c
3 3
4 use List::Util qw(first max maxstr min minstr reduce shuffle sum); 4 use List::Util qw(first max maxstr min minstr reduce shuffle sum);
5 use Storable; 5 use Storable;
6 use CGI::Ajax; 6 use CGI::Ajax;
7 use CGI; 7 use CGI;
8 use JSON;
8 9
9 10
10 11
11 my $q = new CGI; 12 my $q = new CGI;
12 13
18 'pokedex' => \&pokedex, 19 'pokedex' => \&pokedex,
19 'template' => \&template, 20 'template' => \&template,
20 'inputbox' => \&inputbox, 21 'inputbox' => \&inputbox,
21 'display' => \&display, 22 'display' => \&display,
22 'change_rules' => \&change_rules, 23 'change_rules' => \&change_rules,
23 'vanish' => \&vanish 24 'vanish' => \&vanish,
25 'updateForm' => \&updateForm
24 ); 26 );
25 27
26 28
27 29
28 my $pjx = CGI::Ajax->new(%hash); 30 my $pjx = CGI::Ajax->new(%hash);
29 #$pjx->JSDEBUG(1); 31
30 #$pjx->DEBUG(1); 32
31 33 # this outputs the html for the page
32 print $pjx->build_html($q,\&gen,{-Cache_Control => 'no-store, no-cache, must-revalidate', -Pragma => 'no-cache'}); # this outputs the html for the page 34 print $pjx->build_html($q,\&gen,{-Cache_Control => 'no-store, no-cache, must-revalidate', -Pragma => 'no-cache'});
33 35
36
37
38 sub updateForm
39
40 {
41
42
43 $key = shift;
44 $value = shift;
45 $hashString = shift;
46
47 $perl_hash = decode_json $hashString;
48
49 %fieldHash = %$perl_hash;
50
51
52 $fieldHash{$key} = $value;
53 $ref = \%fieldHash;
54
55 $utf8_encoded_json_text = encode_json $ref ;
56 return $utf8_encoded_json_text;
57
58 }
34 59
35 60
36 61
37 62
38 sub material{ 63 sub material{
95 $r = <<HERE; 120 $r = <<HERE;
96 <div id = "i_templates"><div class = 'ttyl'> <titletron>Select Style.</titletron></div> 121 <div id = "i_templates"><div class = 'ttyl'> <titletron>Select Style.</titletron></div>
97 <div id = 'stupid'> 122 <div id = 'stupid'>
98 123
99 124
100 <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> 125 <input TYPE="image" src = "./images/templates/big_$materialcolor.jpg"
126 onmouseover="pokedex(['args__big'],['pokedex']);"
127 onclick=
128 "display(['template2'], ['display']);
129 inputbox(['template2', 'formValues'], ['inputbox']);
130 material(['template2'], ['materials']);
131 redraw('bold');" ID="template2" NAME="template2" VALUE="big_$materialcolor">
132 <br>
101 133
102 134
103 135
104 <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> 136 <input TYPE="image" src = "./images/templates/basic_$materialcolor.jpg"
137 onmouseover="pokedex(['args__basic'],['pokedex']);"
138 onclick=
139 "display(['template3'], ['display']);
140 inputbox(['template3', 'formValues'], ['inputbox']);
141 material(['template3'], ['materials']);
142 redraw('arrow');" ID="template3" NAME="template3" VALUE="basic_$materialcolor" ><br>
105 143
106 144
107 145
108 <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> 146 <input TYPE="image" src = "./images/templates/classic_$materialcolor.jpg"
147 onmouseover="pokedex(['args__classic'],['pokedex']);"
148 onclick=
149 "display(['template1'], ['display']);
150 inputbox(['template1', 'formValues'], ['inputbox']);
151 material(['template1'], ['materials']);
152 redraw('classic');" ID="template1" NAME="template1" VALUE="classic_$materialcolor" ><br>
109 153
110 154
111 155
112 <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" > 156 <input TYPE="image" src = "./images/templates/lines_$materialcolor.jpg"
157 onmouseover="pokedex(['args__lines'],['pokedex']);"
158 onclick=
159 "display(['template4'], ['display']);
160 inputbox(['template4', 'formValues'], ['inputbox']);
161 material(['template4'], ['materials']);
162 redraw('direct');" ID="template4" NAME="template4" VALUE="lines_$materialcolor" >
113 163
114 </div> 164 </div>
115 </div> 165 </div>
116 166
117 HERE 167 HERE
146 sub inputbox 196 sub inputbox
147 { 197 {
148 198
149 #grab the type of template we'll be using <<<< 199 #grab the type of template we'll be using <<<<
150 $type = shift; 200 $type = shift;
151 # return $type; 201
202 $hashString = shift;
203 #return $hashString;
204
205 $perl_hash = decode_json $hashString;
206
207 %fieldHash = %$perl_hash;
208
209
152 # we have to care about both the type of template and the material and the color. these are stored in $type>>>> 210 # we have to care about both the type of template and the material and the color. these are stored in $type>>>>
153 211
154 #Then, update with a special custon paypal form, taken from the paypal folder and specially designed for that particular template. 212 #Then, update with a special custon paypal form, taken from the paypal folder and specially designed for that particular template.
155 #will probaly eventually create a script to automate the generation of these files. 213 #will probaly eventually create a script to automate the generation of these files.
156 214
157 215
158 #take care of everythign but acrylic clear type 216 #take care of everythign but acrylic clear type
159
160
161 217
162 { 218 {
163 local( $/, *FH ) ; 219 local( $/, *FH ) ;
164 open( FH, "<./paypal/$type.paylist" ) or die "sudden flaming death\n"; 220 open( FH, "<./paypal/$type.paylist" ) or die "sudden flaming death\n";
165 $z = <FH>; 221 $z = <FH>;
167 223
168 224
169 #every type has it's own associated paylist file the contains the things we need 225 #every type has it's own associated paylist file the contains the things we need
170 226
171 $z = '<div id = "whatever" onmouseover='."\"pokedex([\'args__$type\'],[\'pokedex\']);\">".$z.'</div>'; 227 $z = '<div id = "whatever" onmouseover='."\"pokedex([\'args__$type\'],[\'pokedex\']);\">".$z.'</div>';
228
229
230 foreach my $key ( keys %fieldHash )
231 {
232
233 my $replace = $fieldHash{$key};
234
235 #id="Name" value = "PERL::NAME"
236
237
238 $z =~ s/id="$key"/id="$key" value = "$replace"/g;
239
240
241 }
242
243
172 return $z; 244 return $z;
173 245
174 246
175 247
176 248
177 249
178 } 250 }
179
180
181
182
183 251
184 252
185 253
186 254
187 sub display 255 sub display
248 $a =~ s/PERL-REPLACE::TEMPLATES/$b/; 316 $a =~ s/PERL-REPLACE::TEMPLATES/$b/;
249 317
250 $b = &display("big_acrylic_clear"); 318 $b = &display("big_acrylic_clear");
251 $a =~ s/PERL-REPLACE::DISPLAY/$b/; 319 $a =~ s/PERL-REPLACE::DISPLAY/$b/;
252 320
253 $b = &inputbox("big_acrylic_clear"); 321 $initials = <<HERE;
322 {"Email":"rlm\@mit.edu","Name":"Robert McIntyre"}
323 HERE
324
325
326 $b = &inputbox("big_acrylic_clear", $initials);
254 $a =~ s/PERL-REPLACE::INPUTBOX/$b/; 327 $a =~ s/PERL-REPLACE::INPUTBOX/$b/;
255 328
256 $b = &pokedex('big'); 329 $b = &pokedex('big');
257 $a =~ s/PERL-REPLACE::POKEDEX/$b/; 330 $a =~ s/PERL-REPLACE::POKEDEX/$b/;
331
332
333
334 #$b = &updateForm('fuck','12', '{}');
335 $a =~ s/PERL::INITIALVALUES/$initials/;
336
258 337
259 338
260 return $a 339 return $a
261 340
262 341