Mercurial > laserkard
comparison buy.pl @ 0:599d0315537d laserkard
[svn r1] initial import
author | rlm |
---|---|
date | Wed, 30 Dec 2009 02:01:25 -0500 |
parents | |
children | e2e7c63a0a08 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:599d0315537d |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 | |
4 use List::Util qw(first max maxstr min minstr reduce shuffle sum); | |
5 use Storable; | |
6 use CGI::Ajax; | |
7 use CGI; | |
8 | |
9 | |
10 | |
11 my $q = new CGI; | |
12 | |
13 | |
14 | |
15 my %hash = ( | |
16 | |
17 'material' => \&material, | |
18 'template' => \&template, | |
19 'inputbox' => \&inputbox, | |
20 'display' => \&display, | |
21 'change_rules' => \&change_rules); | |
22 | |
23 | |
24 | |
25 my $pjx = CGI::Ajax->new(%hash); | |
26 #$pjx->JSDEBUG(1); | |
27 #$pjx->DEBUG(1); | |
28 | |
29 print $pjx->build_html($q,\&gen); # this outputs the html for the page | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 sub material{ | |
36 | |
37 $newvar = shift; | |
38 | |
39 my $t = $newvar; | |
40 | |
41 $newvar =~ m/([^_]*)_/; | |
42 $newvar = $1; | |
43 | |
44 #return (($t =~ m/_acrylic_green/) ? 'CHECKED' : 'notchecked'); | |
45 | |
46 #$y = "$t<br>".(($t =~ m/_acrylic_green/) ? 'CHECKED' : 'notchecked')." | |
47 $y = ""." | |
48 <form id=\"radiobuttons\"> | |
49 <h3>PICK your Materials?: </h3> | |
50 | |
51 <div class = \"Acrylic\"> | |
52 Acrylic: | |
53 <input TYPE=\"radio\" onclick=\"template([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); inputbox([\'radio1\'], [\'inputbox\']); \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_acrylic_clear\"".(($t =~ m/_acrylic_clear/) ? 'CHECKED' : '')."><a href=\"\#\">Clear</a> | |
54 <input TYPE=\"radio\" onclick=\"template([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); inputbox([\'radio1\'], [\'inputbox\']); \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_acrylic_blue\"".(($t =~ m/_acrylic_blue/) ? 'CHECKED' : '')."><a href=\"\#\">Blue</a> | |
55 <input TYPE=\"radio\" onclick=\"template([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); inputbox([\'radio1\'], [\'inputbox\']); \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_acrylic_green\"".(($t =~ m/_acrylic_green/) ? 'CHECKED' : '')."><a href=\"\#\">Green</a> | |
56 </div> | |
57 | |
58 <div class = \"Aluminum\"> | |
59 Aluminum: | |
60 <input TYPE=\"radio\" onclick=\"template([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); inputbox([\'radio1\'], [\'inputbox\']); \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_aluminum_red\"".(($t =~ m/_aluminum_red/) ? 'CHECKED' : '')."><a href=\"\#\">Red</a> | |
61 <input TYPE=\"radio\" onclick=\"template([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); inputbox([\'radio1\'], [\'inputbox\']); \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_aluminum_blue\"".(($t =~ m/_aluminum_blue/) ? 'CHECKED' : '')."><a href=\"\#\">Blue</a> | |
62 <input TYPE=\"radio\" onclick=\"template([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); inputbox([\'radio1\'], [\'inputbox\']); \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_aluminum_green\"".(($t =~ m/_aluminum_green/) ? 'CHECKED' : '')."><a href=\"\#\">Green</a> | |
63 <input TYPE=\"radio\" onclick=\"template([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); inputbox([\'radio1\'], [\'inputbox\']); \" ID=\"radio1\" NAME=\"radio1\" VALUE=\"".$newvar."_aluminum_black\"".(($t =~ m/_aluminum_black/) ? 'CHECKED' : '')."><a href=\"\#\">Black</a> | |
64 </div> | |
65 | |
66 | |
67 </form> | |
68 "; | |
69 | |
70 return $y; | |
71 | |
72 | |
73 } | |
74 | |
75 | |
76 | |
77 sub template | |
78 { | |
79 | |
80 $all = shift; | |
81 $all =~ m/_(.*)/; | |
82 | |
83 $materialcolor = $1; | |
84 | |
85 | |
86 $r = " | |
87 <input TYPE=\"image\" src = \"./templates/thumbnails/classic_$materialcolor.jpg\" onclick=\"display([\'template1\'], [\'display\']); inputbox([\'template1\'], [\'inputbox\']);material([\'template1\'], [\'materials\']);\" ID=\"template1\" NAME=\"template1\" VALUE=\"classic_$materialcolor\"> | |
88 <input TYPE=\"image\" src = \"./templates/thumbnails/big_$materialcolor.jpg\" onclick=\"display([\'template2\'], [\'display\']); inputbox([\'template2\'], [\'inputbox\']);material([\'template2\'], [\'materials\']);\" ID=\"template2\" NAME=\"template2\" VALUE=\"big_$materialcolor\"> | |
89 <input TYPE=\"image\" src = \"./templates/thumbnails/basic_$materialcolor.jpg\" onclick=\"display([\'template3\'], [\'display\']); inputbox([\'template3\'], [\'inputbox\']);material([\'template3\'], [\'materials\']);\" ID=\"template3\" NAME=\"template3\" VALUE=\"basic_$materialcolor\"> | |
90 <input TYPE=\"image\" src = \"./templates/thumbnails/lines_$materialcolor.jpg\" onclick=\"display([\'template4\'], [\'display\']); inputbox([\'template4\'], [\'inputbox\']);material([\'template4\'], [\'materials\']);\" ID=\"template4\" NAME=\"template4\" VALUE=\"lines_$materialcolor\"> | |
91 | |
92 | |
93 "; | |
94 | |
95 return $r; | |
96 } | |
97 | |
98 | |
99 | |
100 | |
101 sub inputbox | |
102 { | |
103 | |
104 #grab the type of template we'll be using <<<< | |
105 $type = shift; | |
106 # return $type; | |
107 # we have to care about both the type of template and the material and the color. these are stored in $type>>>> | |
108 | |
109 #Then, update with a special custon paypal form, taken from the paypal folder and specially designed for that particular template. | |
110 #will probaly eventually create a script to automate the generation of these files. | |
111 | |
112 | |
113 #take care of everythign but acrylic clear type | |
114 if (not($type =~ m/acrylic_clear/)) | |
115 { | |
116 return "comming soon!"; | |
117 } | |
118 | |
119 | |
120 #every type has it's own associated paylist file the contains the things we need | |
121 open FILE, "<./paypal/$type.paylist"; | |
122 return do { local $/; <FILE> }; | |
123 | |
124 | |
125 | |
126 } | |
127 | |
128 | |
129 | |
130 | |
131 | |
132 | |
133 | |
134 | |
135 sub display | |
136 { | |
137 $all = shift; | |
138 | |
139 | |
140 | |
141 $t ="$all | |
142 <input TYPE=\"image\" src = \"./templates/display/$all.jpg\" onclick=\"template([\'radio1\'], [\'templates\']);display([\'radio1\'], [\'display\']); \" ID=\"temp1\" NAME=\"temp1\" VALUE=\"\"> | |
143 "; | |
144 return $t; | |
145 | |
146 } | |
147 | |
148 | |
149 | |
150 | |
151 sub gen | |
152 { | |
153 { | |
154 local( $/, *FH ) ; | |
155 open( FH, "<./buy.html" ) or die "sudden flaming death\n"; | |
156 $a = <FH>; | |
157 } | |
158 | |
159 { | |
160 local( $/, *FH ) ; | |
161 open( FH, "<./top_menu.include" ) or die "sudden flaming death\n"; | |
162 $b = <FH>; | |
163 } | |
164 | |
165 $a =~ s/PERL-REPLACE::TOP_MENU/$b/; #equivalent to <?php include("top_menu.html"); ?>, but in perl with more memory problems :) | |
166 | |
167 return $a | |
168 | |
169 | |
170 }; | |
171 | |
172 |