Mercurial > laserkard
diff buy.pl @ 51:95fa4bcc5d67 laserkard
[svn r52] implemented SVG backend
author | rlm |
---|---|
date | Wed, 03 Feb 2010 03:14:09 -0500 |
parents | 4431dc7d4bb5 |
children | 343dc947f999 |
line wrap: on
line diff
1.1 --- a/buy.pl Mon Feb 01 02:54:59 2010 -0500 1.2 +++ b/buy.pl Wed Feb 03 03:14:09 2010 -0500 1.3 @@ -1,29 +1,24 @@ 1.4 #!/usr/bin/perl 1.5 1.6 1.7 -use List::Util qw(first max maxstr min minstr reduce shuffle sum); 1.8 -use Storable; 1.9 -use CGI::Ajax; 1.10 -use CGI; 1.11 -use JSON; 1.12 1.13 +use Laserkard; 1.14 1.15 1.16 my $q = new CGI; 1.17 1.18 +#print Laserkard::gen(); 1.19 1.20 - 1.21 -my %hash = ( 1.22 - 1.23 -'material' => \&material, 1.24 - 1.25 -'template' => \&template, 1.26 -'inputbox' => \&inputbox, 1.27 -'display' => \&display, 1.28 -'change_rules' => \&change_rules, 1.29 -'vanish' => \&vanish, 1.30 -'updateForm' => \&updateForm, 1.31 -'cardType' => \&cardType 1.32 +my %hash = 1.33 +( 1.34 +'material' => \&Laserkard::material, 1.35 +'template' => \&Laserkard::template, 1.36 +'inputbox' => \&Laserkard::inputbox, 1.37 +'display' => \&Laserkard::display, 1.38 +'change_rules' => \&Laserkard::change_rules, 1.39 +'vanish' => \&Laserkard::vanish, 1.40 +'updateForm' => \&Laserkard::updateForm, 1.41 +'cardType' => \&Laserkard::cardType 1.42 ); 1.43 1.44 1.45 @@ -32,441 +27,7 @@ 1.46 1.47 1.48 # this outputs the html for the page 1.49 -print $pjx->build_html($q,\&gen,{-Cache_Control => 'no-store, no-cache, must-revalidate', -Pragma => 'no-cache'}); 1.50 +print $pjx->build_html($q,\&Laserkard::genBuy,{-Cache_Control => 'no-store, no-cache, must-revalidate', -Pragma => 'no-cache'}); 1.51 1.52 1.53 - 1.54 -sub cardType 1.55 -{ 1.56 - 1.57 -return $_[0]; 1.58 - 1.59 -} 1.60 - 1.61 - 1.62 - 1.63 -sub updateForm 1.64 - 1.65 -{ 1.66 - 1.67 - 1.68 - $key = shift; 1.69 - $value = shift; 1.70 - $hashString = shift; 1.71 - 1.72 - $perl_hash = decode_json $hashString; 1.73 - 1.74 - %fieldHash = %$perl_hash; 1.75 - 1.76 - 1.77 - $fieldHash{$key} = $value; 1.78 - $ref = \%fieldHash; 1.79 - 1.80 - $utf8_encoded_json_text = encode_json $ref ; 1.81 - return $utf8_encoded_json_text; 1.82 - 1.83 -} 1.84 - 1.85 - 1.86 - 1.87 - 1.88 -sub material{ 1.89 - 1.90 - $newvar = shift; 1.91 - 1.92 - my $t = $newvar; 1.93 - 1.94 - $newvar =~ m/([^_]*)_/; 1.95 - $newvar = $1; 1.96 - 1.97 - #return (($t =~ m/_acrylic_green/) ? 'CHECKED' : 'notchecked'); 1.98 - 1.99 - #$y = "$t<br>".(($t =~ m/_acrylic_green/) ? 'CHECKED' : 'notchecked')." 1.100 - 1.101 - { 1.102 - local( $/, *FH ) ; 1.103 - open( FH, "<./buy_pieces/materials2.html" ) or die "sudden flaming death\n"; 1.104 - $y = <FH>; 1.105 - } 1.106 - 1.107 - @symbols = qw(PERL::ACRYLIC_CLEAR PERL::ACRYLIC_BLUE PERL::ACRYLIC_GREEN PERL::ALUMINUM_RED PERL::ALUMINUM_BLUE PERL::ALUMINUM_GREEN PERL::ALUMINUM_BLACK); 1.108 - 1.109 - for (@symbols) 1.110 - { 1.111 - $c = $_; 1.112 - $c =~ s/PERL:://; 1.113 - $c =~ tr/[A-Z]/[a-z]/; 1.114 - $c =~ s/^/_/; 1.115 - 1.116 - $b = '"'.$newvar.$c.'"'.(($t =~ m/$c/) ? ' CHECKED ' : ''); 1.117 - $y =~ s/$_/$b/; 1.118 - } 1.119 - 1.120 - 1.121 - $first = shift; 1.122 - if ($first){ $y =~ s/display[^;]*;//g; } 1.123 - 1.124 - 1.125 - 1.126 - return $y; 1.127 - 1.128 - 1.129 -} 1.130 - 1.131 - 1.132 - 1.133 -sub template 1.134 -{ 1.135 - 1.136 -$all = shift; 1.137 -$all =~ m/([^_]*)_(.*)/; 1.138 - 1.139 -$materialcolor = $2; 1.140 -$style = $1; 1.141 -#here is where we handle important drawing commands relating to the cards. 1.142 - 1.143 - 1.144 - 1.145 -$r = <<HERE; 1.146 -<div id = "i_templates"><div class = 'ttyl'> <titletron>Select Style.</titletron></div> 1.147 -<div id = 'stupid'> 1.148 - 1.149 - 1.150 -<input TYPE="image" src = "./images/templates/big_$materialcolor.jpg" 1.151 -onmouseover="pokedex('big_$materialcolor');" 1.152 -onmouseout = "pokedex(document.getElementById('currentSpec').innerHTML);" 1.153 - 1.154 - 1.155 - 1.156 -onclick= 1.157 -"display(['template2'], ['display']); 1.158 -inputbox(['template2', 'formValues'], ['inputbox']); 1.159 -material(['template2'], ['materials']); 1.160 -cardType(['template2'], ['currentSpec']); 1.161 -redraw('bold');" 1.162 -ID="template2" NAME="template2" VALUE="big_$materialcolor"> 1.163 -<br> 1.164 - 1.165 - 1.166 - 1.167 -<input TYPE="image" src = "./images/templates/basic_$materialcolor.jpg" 1.168 -onmouseover="pokedex('basic_$materialcolor');" 1.169 -onmouseout = "pokedex(document.getElementById('currentSpec').innerHTML);" 1.170 -onclick= 1.171 -"display(['template3'], ['display']); 1.172 -inputbox(['template3', 'formValues'], ['inputbox']); 1.173 -material(['template3'], ['materials']); 1.174 -cardType(['template3'], ['currentSpec']); 1.175 -redraw('arrow');" 1.176 -ID="template3" NAME="template3" VALUE="basic_$materialcolor" ><br> 1.177 - 1.178 - 1.179 - 1.180 -<input TYPE="image" src = "./images/templates/classic_$materialcolor.jpg" 1.181 -onmouseover="pokedex('classic_$materialcolor');" 1.182 -onmouseout = "pokedex(document.getElementById('currentSpec').innerHTML);" 1.183 -onclick= 1.184 -"display(['template1'], ['display']); 1.185 -inputbox(['template1', 'formValues'], ['inputbox']); 1.186 -material(['template1'], ['materials']); 1.187 -cardType(['template1'], ['currentSpec']); 1.188 -redraw('classic');" 1.189 -ID="template1" NAME="template1" VALUE="classic_$materialcolor" ><br> 1.190 - 1.191 - 1.192 - 1.193 -<input TYPE="image" src = "./images/templates/lines_$materialcolor.jpg" 1.194 -onmouseover="pokedex('lines_$materialcolor');" 1.195 -onmouseout = "pokedex(document.getElementById('currentSpec').innerHTML);" 1.196 -onclick= 1.197 -"display(['template4'], ['display']); 1.198 -inputbox(['template4', 'formValues'], ['inputbox']); 1.199 -material(['template4'], ['materials']); 1.200 -cardType(['template4'], ['currentSpec']); 1.201 -redraw('direct');" 1.202 -ID="template4" NAME="template4" VALUE="lines_$materialcolor" > 1.203 - 1.204 - </div> 1.205 - </div> 1.206 - 1.207 -HERE 1.208 - 1.209 - 1.210 -%shankHash = 1.211 -( 1.212 - 1.213 -big => template2, 1.214 -basic => template3, 1.215 -classic => template1, 1.216 -lines => template4 1.217 -); 1.218 - 1.219 -$target = $shankHash{$style}; 1.220 - 1.221 - 1.222 - 1.223 - 1.224 -#$r =~ s/inputbox\(\['$target'\], \['inputbox'\]\)\;//; 1.225 - 1.226 - 1.227 - 1.228 - 1.229 - 1.230 -return $r; 1.231 -} 1.232 - 1.233 - 1.234 - 1.235 - 1.236 -sub inputbox 1.237 -{ 1.238 - 1.239 -#grab the type of template we'll be using <<<< 1.240 - $type = shift; 1.241 - 1.242 - $hashString = shift; 1.243 - #return $hashString; 1.244 - 1.245 - $perl_hash = decode_json $hashString; 1.246 - 1.247 - %fieldHash = %$perl_hash; 1.248 - 1.249 - 1.250 -# we have to care about both the type of template and the material and the color. these are stored in $type>>>> 1.251 - 1.252 -#Then, update with a special custon paypal form, taken from the paypal folder and specially designed for that particular template. 1.253 -#will probaly eventually create a script to automate the generation of these files. 1.254 - 1.255 - 1.256 -#take care of everythign but acrylic clear type 1.257 - 1.258 - { 1.259 - local( $/, *FH ) ; 1.260 - open( FH, "<./paypal/$type.paylist" ) or die "sudden flaming death\n"; 1.261 - $z = <FH>; 1.262 - } 1.263 - 1.264 - 1.265 -#every type has it's own associated paylist file the contains the things we need 1.266 - 1.267 -$z = <<HERE . $z; 1.268 -<div id = "whatever" onmouseover = "pokedex(document.getElementById('currentSpec').innerHTML);"> 1.269 -HERE 1.270 - 1.271 - 1.272 - 1.273 - 1.274 -$z = $z.'</div>'; 1.275 - 1.276 - 1.277 -foreach my $key ( keys %fieldHash ) 1.278 -{ 1.279 - 1.280 -my $replace = $fieldHash{$key}; 1.281 - 1.282 -#id="Name" value = "PERL::NAME" 1.283 - 1.284 - 1.285 -$z =~ s/id="$key"/id="$key" value = "$replace"/g; 1.286 - 1.287 - 1.288 -} 1.289 - 1.290 - 1.291 -return $z; 1.292 - 1.293 - 1.294 - 1.295 - 1.296 - 1.297 -} 1.298 - 1.299 - 1.300 - 1.301 - 1.302 -sub display 1.303 -{ 1.304 - $all = shift; 1.305 - 1.306 - 1.307 - #~ 1.308 - #~ $t = <<HERE; 1.309 - #~ <image src = "./images/display/PERL::PIC.jpg" onmouseover="pokedex(['args__PERL::PIC'],['pokedex']);"> 1.310 - #~ 1.311 - #~ <div id = overlay> 1.312 -#~ 1.313 -#~ 1.314 - #~ </div> 1.315 - #~ 1.316 -#~ HERE 1.317 -#~ 1.318 -#~ 1.319 -#~ 1.320 -#~ $t =~ s/PERL::PIC/$all/g; 1.321 - 1.322 - $t = <<HERE; 1.323 - <image src = "./images/display/blank.jpg" 1.324 - onmouseover = "pokedex(document.getElementById('currentSpec').innerHTML);" 1.325 - > 1.326 - 1.327 - <div id = overlay> 1.328 - 1.329 - 1.330 - </div> 1.331 - 1.332 -HERE 1.333 - 1.334 - return $t; 1.335 - 1.336 -} 1.337 - 1.338 - 1.339 - 1.340 - 1.341 -sub gen 1.342 -{ 1.343 - { 1.344 - local( $/, *FH ) ; 1.345 - open( FH, "<./buy.html" ) or die "sudden flaming death\n"; 1.346 - $a = <FH>; 1.347 - } 1.348 - 1.349 - { 1.350 - local( $/, *FH ) ; 1.351 - open( FH, "<./top_menu.include" ) or die "sudden flaming death\n"; 1.352 - $b = <FH>; 1.353 - } 1.354 - 1.355 - { 1.356 - local( $/, *FH ) ; 1.357 - open( FH, "<./cardDefinitions.JSON" ) or die "sudden flaming death\n"; 1.358 - $c = <FH>; 1.359 - } 1.360 - 1.361 -$a =~s/PERL::DEFS/$c/; 1.362 - 1.363 - 1.364 - 1.365 -$a =~ s/PERL-REPLACE::TOP_MENU/$b/; #equivalent to <?php include("top_menu.html"); ?>, but in perl and with more memory problems :) 1.366 -$b = &material("void_acrylic_clear",1); 1.367 -$a =~ s/PERL-REPLACE::MATERIALS/$b/; #let's do it again!!! :) 1.368 - 1.369 - 1.370 - 1.371 -$b = "big_acrylic_clear"; 1.372 -$a =~ s/PERL::INITIALCARD/$b/; 1.373 -$b = &template("big_acrylic_clear"); 1.374 -$a =~ s/PERL-REPLACE::TEMPLATES/$b/; 1.375 - 1.376 -$b = &display("big_acrylic_clear"); 1.377 -$a =~ s/PERL-REPLACE::DISPLAY/$b/; 1.378 - 1.379 -$initials = <<HERE ; 1.380 -{ 1.381 -"Name":"James Bond", 1.382 -"Email":"jbond\@mi6.co.uk", 1.383 -"Phone": "123.456.7890", 1.384 -"Company": "MI6", 1.385 -"Website" : "http://jamesbond.com", 1.386 -"Occupation" : "Secret Agent" 1.387 -} 1.388 - 1.389 -HERE 1.390 - 1.391 - 1.392 - 1.393 -$b = &inputbox("big_acrylic_clear", $initials); 1.394 -$a =~ s/PERL-REPLACE::INPUTBOX/$b/; 1.395 - 1.396 -$b = &pokedex('big'); 1.397 -$a =~ s/PERL-REPLACE::POKEDEX/$b/; 1.398 - 1.399 - 1.400 - 1.401 -#$b = &updateForm('fuck','12', '{}'); 1.402 -$a =~ s/PERL::INITIALVALUES/$initials/; 1.403 - 1.404 - 1.405 - 1.406 -return $a 1.407 - 1.408 - 1.409 -} 1.410 - 1.411 - 1.412 - 1.413 -sub pokedex 1.414 -{ 1.415 - 1.416 - 1.417 -$classic = <<HERE; 1.418 -<h1>The Classic LaserKard.</h1> 1.419 -Balanced and Complete. The original LaserKard. For those that wish to leave no stone unturned. It's all there. 1.420 -HERE 1.421 - 1.422 -$bold = <<HERE; 1.423 -<h1>The Bold Kard.</h1> 1.424 -Austere and Iconic. For those that wish to leave an impression with the power of their name accompanied only by their main method of contact. Bold, period. 1.425 -HERE 1.426 - 1.427 -$arrow = <<HERE; 1.428 -<h1>The Arrow Kard.</h1> 1.429 -Precise and Straightforward. For those that seek to make a statement while being clear and concise. Straight as an arrow. 1.430 -HERE 1.431 - 1.432 -$direct = <<HERE; 1.433 -<h1>The Direct Kard.</h1> 1.434 -Thorough and Distinct. For those that aim to demonstrate their professionalism with style. Push the envelope. Be Direct. 1.435 -HERE 1.436 - 1.437 - 1.438 - 1.439 -my %megahash = 1.440 -( 1.441 - 1.442 -'big' => $bold, 1.443 - 1.444 -'basic' => $arrow, 1.445 - 1.446 -'lines' => $direct, 1.447 - 1.448 -'classic' => $classic, 1.449 - 1.450 -'big_acrylic_clear' => $bold, 1.451 - 1.452 -'classic_acrylic_clear' => $classic, 1.453 - 1.454 -'basic_acrylic_clear' => $arrow, 1.455 - 1.456 -'lines_acrylic_clear' => $direct 1.457 -); 1.458 - 1.459 - 1.460 - 1.461 -my $key = shift; 1.462 - 1.463 - 1.464 -if (!$megahash{$key}){return $key;} 1.465 - 1.466 -return $megahash{$key}; 1.467 - 1.468 - 1.469 - 1.470 - 1.471 -} 1.472 - 1.473 - 1.474 - 1.475 - 1.476 - 1.477 - 1.478 - 1.479 - 1.480 -# this here function makes the paypal button go away so people know it's working! 1.481 -sub vanish 1.482 -{ 1.483 -return ""; 1.484 - 1.485 - 1.486 -} 1.487 - 1.488 +# it's a refrence to a function, not a function itself.