annotate buy.pl @ 11:31c3bd2ee5cf laserkard

[svn r12]
author rlm
date Fri, 01 Jan 2010 23:11:47 -0500
parents 116b15d3d68c
children 839533015ed3
rev   line source
rlm@0 1 #!/usr/bin/perl
rlm@0 2
rlm@0 3
rlm@0 4 use List::Util qw(first max maxstr min minstr reduce shuffle sum);
rlm@0 5 use Storable;
rlm@0 6 use CGI::Ajax;
rlm@0 7 use CGI;
rlm@0 8
rlm@0 9
rlm@0 10
rlm@0 11 my $q = new CGI;
rlm@0 12
rlm@0 13
rlm@0 14
rlm@0 15 my %hash = (
rlm@0 16
rlm@0 17 'material' => \&material,
rlm@2 18 'pokedex' => \&pokedex,
rlm@0 19 'template' => \&template,
rlm@0 20 'inputbox' => \&inputbox,
rlm@0 21 'display' => \&display,
rlm@0 22 'change_rules' => \&change_rules);
rlm@0 23
rlm@0 24
rlm@0 25
rlm@0 26 my $pjx = CGI::Ajax->new(%hash);
rlm@0 27 #$pjx->JSDEBUG(1);
rlm@0 28 #$pjx->DEBUG(1);
rlm@0 29
rlm@0 30 print $pjx->build_html($q,\&gen); # this outputs the html for the page
rlm@0 31
rlm@0 32
rlm@0 33
rlm@0 34
rlm@0 35
rlm@0 36 sub material{
rlm@0 37
rlm@0 38 $newvar = shift;
rlm@0 39
rlm@0 40 my $t = $newvar;
rlm@0 41
rlm@0 42 $newvar =~ m/([^_]*)_/;
rlm@0 43 $newvar = $1;
rlm@0 44
rlm@0 45 #return (($t =~ m/_acrylic_green/) ? 'CHECKED' : 'notchecked');
rlm@0 46
rlm@0 47 #$y = "$t<br>".(($t =~ m/_acrylic_green/) ? 'CHECKED' : 'notchecked')."
rlm@2 48
rlm@2 49 {
rlm@2 50 local( $/, *FH ) ;
rlm@2 51 open( FH, "<./buy_pieces/materials2.html" ) or die "sudden flaming death\n";
rlm@2 52 $y = <FH>;
rlm@2 53 }
rlm@2 54
rlm@2 55 @symbols = qw(PERL::ACRYLIC_CLEAR PERL::ACRYLIC_BLUE PERL::ACRYLIC_GREEN PERL::ALUMINUM_RED PERL::ALUMINUM_BLUE PERL::ALUMINUM_GREEN PERL::ALUMINUM_BLACK);
rlm@2 56
rlm@2 57 for (@symbols)
rlm@2 58 {
rlm@2 59 $c = $_;
rlm@2 60 $c =~ s/PERL:://;
rlm@2 61 $c =~ tr/[A-Z]/[a-z]/;
rlm@2 62 $c =~ s/^/_/;
rlm@2 63
rlm@2 64 $b = '"'.$newvar.$c.'"'.(($t =~ m/$c/) ? ' CHECKED ' : '');
rlm@2 65 $y =~ s/$_/$b/;
rlm@2 66 }
rlm@2 67
rlm@2 68
rlm@2 69 $first = shift;
rlm@2 70 if ($first){ $y =~ s/display[^;]*;//g; }
rlm@2 71
rlm@0 72
rlm@0 73
rlm@0 74 return $y;
rlm@0 75
rlm@0 76
rlm@0 77 }
rlm@0 78
rlm@0 79
rlm@0 80
rlm@0 81 sub template
rlm@0 82 {
rlm@0 83
rlm@0 84 $all = shift;
rlm@0 85 $all =~ m/_(.*)/;
rlm@0 86
rlm@0 87 $materialcolor = $1;
rlm@0 88
rlm@0 89
rlm@5 90 $r = "<div id = \"i_templates\">Templates:<br>
rlm@2 91 <input TYPE=\"image\" src = \"./templates/thumbnails/classic_$materialcolor.jpg\" onmouseover=\"pokedex([\'args__classic\'],[\'pokedex\']);\" onclick=\"display([\'template1\'], [\'display\']); inputbox([\'template1\'], [\'inputbox\']);material([\'template1\'], [\'materials\']);\" ID=\"template1\" NAME=\"template1\" VALUE=\"classic_$materialcolor\" >
rlm@2 92 <input TYPE=\"image\" src = \"./templates/thumbnails/big_$materialcolor.jpg\" onmouseover=\"pokedex([\'args__big\'],[\'pokedex\']);\" onclick=\"display([\'template2\'], [\'display\']); inputbox([\'template2\'], [\'inputbox\']);material([\'template2\'], [\'materials\']);\" ID=\"template2\" NAME=\"template2\" VALUE=\"big_$materialcolor\" >
rlm@2 93 <input TYPE=\"image\" src = \"./templates/thumbnails/basic_$materialcolor.jpg\" onmouseover=\"pokedex([\'args__basic\'],['pokedex\']);\" onclick=\"display([\'template3\'], [\'display\']); inputbox([\'template3\'], [\'inputbox\']);material([\'template3\'], [\'materials\']);\" ID=\"template3\" NAME=\"template3\" VALUE=\"basic_$materialcolor\" >
rlm@2 94 <input TYPE=\"image\" src = \"./templates/thumbnails/lines_$materialcolor.jpg\" onmouseover=\"pokedex([\'args__lines\'],[\'pokedex\']);\" onclick=\"display([\'template4\'], [\'display\']); inputbox([\'template4\'], [\'inputbox\']);material([\'template4\'], [\'materials\']);\" ID=\"template4\" NAME=\"template4\" VALUE=\"lines_$materialcolor\" >
rlm@5 95 </div>
rlm@0 96
rlm@0 97 ";
rlm@0 98
rlm@0 99 return $r;
rlm@0 100 }
rlm@0 101
rlm@0 102
rlm@0 103
rlm@0 104
rlm@0 105 sub inputbox
rlm@0 106 {
rlm@0 107
rlm@0 108 #grab the type of template we'll be using <<<<
rlm@0 109 $type = shift;
rlm@0 110 # return $type;
rlm@0 111 # we have to care about both the type of template and the material and the color. these are stored in $type>>>>
rlm@0 112
rlm@0 113 #Then, update with a special custon paypal form, taken from the paypal folder and specially designed for that particular template.
rlm@0 114 #will probaly eventually create a script to automate the generation of these files.
rlm@0 115
rlm@0 116
rlm@0 117 #take care of everythign but acrylic clear type
rlm@2 118
rlm@2 119
rlm@2 120
rlm@2 121 {
rlm@2 122 local( $/, *FH ) ;
rlm@2 123 open( FH, "<./paypal/$type.paylist" ) or die "sudden flaming death\n";
rlm@2 124 $z = <FH>;
rlm@2 125 }
rlm@0 126
rlm@0 127
rlm@0 128 #every type has it's own associated paylist file the contains the things we need
rlm@2 129
rlm@4 130 $z = '<div id = "whatever" onmouseover='."\"pokedex([\'args__$type\'],[\'pokedex\']);\"".$z.'</div>';
rlm@2 131 return $z;
rlm@2 132
rlm@2 133
rlm@0 134
rlm@0 135
rlm@0 136
rlm@0 137 }
rlm@0 138
rlm@0 139
rlm@0 140
rlm@0 141
rlm@0 142
rlm@0 143
rlm@0 144
rlm@0 145
rlm@0 146 sub display
rlm@0 147 {
rlm@0 148 $all = shift;
rlm@0 149
rlm@0 150
rlm@0 151
rlm@2 152 $t ="
rlm@2 153 <input TYPE=\"image\" src = \"./templates/display/$all.jpg\" >
rlm@0 154 ";
rlm@0 155 return $t;
rlm@0 156
rlm@0 157 }
rlm@0 158
rlm@0 159
rlm@0 160
rlm@0 161
rlm@0 162 sub gen
rlm@0 163 {
rlm@0 164 {
rlm@0 165 local( $/, *FH ) ;
rlm@0 166 open( FH, "<./buy.html" ) or die "sudden flaming death\n";
rlm@0 167 $a = <FH>;
rlm@0 168 }
rlm@0 169
rlm@0 170 {
rlm@0 171 local( $/, *FH ) ;
rlm@0 172 open( FH, "<./top_menu.include" ) or die "sudden flaming death\n";
rlm@0 173 $b = <FH>;
rlm@0 174 }
rlm@0 175
rlm@2 176
rlm@2 177
rlm@2 178 $a =~ s/PERL-REPLACE::TOP_MENU/$b/; #equivalent to <?php include("top_menu.html"); ?>, but in perl and with more memory problems :)
rlm@2 179 $b = &material("void_acrylic_clear",1);
rlm@2 180 $a =~ s/PERL-REPLACE::MATERIALS/$b/; #let's do it again!!! :)
rlm@2 181 $b = &template("classic_acrylic_clear");
rlm@2 182
rlm@5 183 $a =~ s/PERL-REPLACE::TEMPLATES//;
rlm@5 184 #$a =~ s/PERL-REPLACE::TEMPLATES/$b/; #comment out one or the other!
rlm@2 185
rlm@2 186
rlm@0 187
rlm@0 188 return $a
rlm@0 189
rlm@0 190
rlm@2 191 }
rlm@0 192
rlm@0 193
rlm@2 194
rlm@2 195 sub pokedex
rlm@2 196 {
rlm@2 197
rlm@2 198 my $key = shift;
rlm@2 199
rlm@2 200 return $key;
rlm@2 201
rlm@2 202
rlm@2 203 }