view buy.pl @ 18:2f537455ebf7 laserkard

[svn r19] lots o changes
author rlm
date Sun, 03 Jan 2010 00:26:19 -0500
parents 839533015ed3
children 896afe03bc67
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);
26 my $pjx = CGI::Ajax->new(%hash);
27 #$pjx->JSDEBUG(1);
28 #$pjx->DEBUG(1);
30 print $pjx->build_html($q,\&gen); # this outputs the html for the page
36 sub material{
38 $newvar = shift;
40 my $t = $newvar;
42 $newvar =~ m/([^_]*)_/;
43 $newvar = $1;
45 #return (($t =~ m/_acrylic_green/) ? 'CHECKED' : 'notchecked');
47 #$y = "$t<br>".(($t =~ m/_acrylic_green/) ? 'CHECKED' : 'notchecked')."
49 {
50 local( $/, *FH ) ;
51 open( FH, "<./buy_pieces/materials2.html" ) or die "sudden flaming death\n";
52 $y = <FH>;
53 }
55 @symbols = qw(PERL::ACRYLIC_CLEAR PERL::ACRYLIC_BLUE PERL::ACRYLIC_GREEN PERL::ALUMINUM_RED PERL::ALUMINUM_BLUE PERL::ALUMINUM_GREEN PERL::ALUMINUM_BLACK);
57 for (@symbols)
58 {
59 $c = $_;
60 $c =~ s/PERL:://;
61 $c =~ tr/[A-Z]/[a-z]/;
62 $c =~ s/^/_/;
64 $b = '"'.$newvar.$c.'"'.(($t =~ m/$c/) ? ' CHECKED ' : '');
65 $y =~ s/$_/$b/;
66 }
69 $first = shift;
70 if ($first){ $y =~ s/display[^;]*;//g; }
74 return $y;
77 }
81 sub template
82 {
84 $all = shift;
85 $all =~ m/_(.*)/;
87 $materialcolor = $1;
90 $r = "<div id = \"i_templates\">Templates:<br>
91 <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\" >
92 <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>
93 <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\" >
94 <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\" >
95 </div>
97 ";
99 return $r;
100 }
105 sub inputbox
106 {
108 #grab the type of template we'll be using <<<<
109 $type = shift;
110 # return $type;
111 # we have to care about both the type of template and the material and the color. these are stored in $type>>>>
113 #Then, update with a special custon paypal form, taken from the paypal folder and specially designed for that particular template.
114 #will probaly eventually create a script to automate the generation of these files.
117 #take care of everythign but acrylic clear type
121 {
122 local( $/, *FH ) ;
123 open( FH, "<./paypal/$type.paylist" ) or die "sudden flaming death\n";
124 $z = <FH>;
125 }
128 #every type has it's own associated paylist file the contains the things we need
130 $z = '<div id = "whatever" onmouseover='."\"pokedex([\'args__$type\'],[\'pokedex\']);\"".$z.'</div>';
131 return $z;
137 }
146 sub display
147 {
148 $all = shift;
152 $t ="
153 <input TYPE=\"image\" src = \"./images/display/$all.jpg\" >
154 ";
155 return $t;
157 }
162 sub gen
163 {
164 {
165 local( $/, *FH ) ;
166 open( FH, "<./buy.html" ) or die "sudden flaming death\n";
167 $a = <FH>;
168 }
170 {
171 local( $/, *FH ) ;
172 open( FH, "<./top_menu.include" ) or die "sudden flaming death\n";
173 $b = <FH>;
174 }
178 $a =~ s/PERL-REPLACE::TOP_MENU/$b/; #equivalent to <?php include("top_menu.html"); ?>, but in perl and with more memory problems :)
179 $b = &material("void_acrylic_clear",1);
180 $a =~ s/PERL-REPLACE::MATERIALS/$b/; #let's do it again!!! :)
181 $b = &template("classic_acrylic_clear");
183 #$a =~ s/PERL-REPLACE::TEMPLATES//;
184 $a =~ s/PERL-REPLACE::TEMPLATES/$b/; #comment out one or the other!
187 $b = &display("classic_acrylic_clear");
188 $a =~ s/PERL-REPLACE::DISPLAY/$b/; #let's do it again!!! :)
190 $b = &inputbox("classic_acrylic_clear");
191 $a =~ s/PERL-REPLACE::INPUTBOX/$b/; #let's do it again!!! :)
193 return $a
196 }
200 sub pokedex
201 {
203 my $key = shift;
205 return $key;
208 }