view buy.pl @ 23:707d202f58b1 laserkard

[svn r24] added.... ARROWS~!
author rlm
date Sun, 03 Jan 2010 08:30:32 -0500
parents 3298256dd459
children 2979a76e3fdf
line wrap: on
line source
1 #!/usr/bin/perl
4 use List::Util qw(first max maxstr min minstr reduce shuffle sum);
5 use Storable;
6 use CGI::Ajax;
7 use CGI;
11 my $q = new CGI;
15 my %hash = (
17 'material' => \&material,
18 'pokedex' => \&pokedex,
19 'template' => \&template,
20 'inputbox' => \&inputbox,
21 'display' => \&display,
22 'change_rules' => \&change_rules,
23 'vanish' => \&vanish
24 );
28 my $pjx = CGI::Ajax->new(%hash);
29 #$pjx->JSDEBUG(1);
30 #$pjx->DEBUG(1);
32 print $pjx->build_html($q,\&gen); # this outputs the html for the page
38 sub material{
40 $newvar = shift;
42 my $t = $newvar;
44 $newvar =~ m/([^_]*)_/;
45 $newvar = $1;
47 #return (($t =~ m/_acrylic_green/) ? 'CHECKED' : 'notchecked');
49 #$y = "$t<br>".(($t =~ m/_acrylic_green/) ? 'CHECKED' : 'notchecked')."
51 {
52 local( $/, *FH ) ;
53 open( FH, "<./buy_pieces/materials2.html" ) or die "sudden flaming death\n";
54 $y = <FH>;
55 }
57 @symbols = qw(PERL::ACRYLIC_CLEAR PERL::ACRYLIC_BLUE PERL::ACRYLIC_GREEN PERL::ALUMINUM_RED PERL::ALUMINUM_BLUE PERL::ALUMINUM_GREEN PERL::ALUMINUM_BLACK);
59 for (@symbols)
60 {
61 $c = $_;
62 $c =~ s/PERL:://;
63 $c =~ tr/[A-Z]/[a-z]/;
64 $c =~ s/^/_/;
66 $b = '"'.$newvar.$c.'"'.(($t =~ m/$c/) ? ' CHECKED ' : '');
67 $y =~ s/$_/$b/;
68 }
71 $first = shift;
72 if ($first){ $y =~ s/display[^;]*;//g; }
76 return $y;
79 }
83 sub template
84 {
86 $all = shift;
87 $all =~ m/_(.*)/;
89 $materialcolor = $1;
92 $r = "<div id = \"i_templates\"><titletron>Templates:</titletron><br>
94 <input TYPE=\"image\" src = \"./images/templates/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\" > <br>
96 <input TYPE=\"image\" src = \"./images/templates/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\" ><br>
98 <input TYPE=\"image\" src = \"./images/templates/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\" ><br>
100 <input TYPE=\"image\" src = \"./images/templates/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\" >
101 </div>
103 ";
105 return $r;
106 }
111 sub inputbox
112 {
114 #grab the type of template we'll be using <<<<
115 $type = shift;
116 # return $type;
117 # we have to care about both the type of template and the material and the color. these are stored in $type>>>>
119 #Then, update with a special custon paypal form, taken from the paypal folder and specially designed for that particular template.
120 #will probaly eventually create a script to automate the generation of these files.
123 #take care of everythign but acrylic clear type
127 {
128 local( $/, *FH ) ;
129 open( FH, "<./paypal/$type.paylist" ) or die "sudden flaming death\n";
130 $z = <FH>;
131 }
134 #every type has it's own associated paylist file the contains the things we need
136 $z = '<div id = "whatever" onmouseover='."\"pokedex([\'args__$type\'],[\'pokedex\']);\">".$z.'</div>';
137 return $z;
143 }
152 sub display
153 {
154 $all = shift;
158 $t ="
159 <input TYPE=\"image\" src = \"./images/display/$all.jpg\" >
160 ";
161 return $t;
163 }
168 sub gen
169 {
170 {
171 local( $/, *FH ) ;
172 open( FH, "<./buy.html" ) or die "sudden flaming death\n";
173 $a = <FH>;
174 }
176 {
177 local( $/, *FH ) ;
178 open( FH, "<./top_menu.include" ) or die "sudden flaming death\n";
179 $b = <FH>;
180 }
184 $a =~ s/PERL-REPLACE::TOP_MENU/$b/; #equivalent to <?php include("top_menu.html"); ?>, but in perl and with more memory problems :)
185 $b = &material("void_acrylic_clear",1);
186 $a =~ s/PERL-REPLACE::MATERIALS/$b/; #let's do it again!!! :)
187 $b = &template("big_acrylic_clear");
189 #$a =~ s/PERL-REPLACE::TEMPLATES//;
190 $a =~ s/PERL-REPLACE::TEMPLATES/$b/; #comment out one or the other!
192 $b = &display("big_acrylic_clear");
193 $a =~ s/PERL-REPLACE::DISPLAY/$b/;
195 $b = &inputbox("big_acrylic_clear");
196 $a =~ s/PERL-REPLACE::INPUTBOX/$b/;
199 return $a
202 }
206 sub pokedex
207 {
209 my $key = shift;
211 return $key;
214 }
223 # this here function makes the paypal button go away so people know it's working!
224 sub vanish
225 {
226 return "Fuck you!"
229 }