view buy.pl @ 0:599d0315537d laserkard

[svn r1] initial import
author rlm
date Wed, 30 Dec 2009 02:01:25 -0500
parents
children e2e7c63a0a08
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 'template' => \&template,
19 'inputbox' => \&inputbox,
20 'display' => \&display,
21 'change_rules' => \&change_rules);
25 my $pjx = CGI::Ajax->new(%hash);
26 #$pjx->JSDEBUG(1);
27 #$pjx->DEBUG(1);
29 print $pjx->build_html($q,\&gen); # this outputs the html for the page
35 sub material{
37 $newvar = shift;
39 my $t = $newvar;
41 $newvar =~ m/([^_]*)_/;
42 $newvar = $1;
44 #return (($t =~ m/_acrylic_green/) ? 'CHECKED' : 'notchecked');
46 #$y = "$t<br>".(($t =~ m/_acrylic_green/) ? 'CHECKED' : 'notchecked')."
47 $y = ""."
48 <form id=\"radiobuttons\">
49 <h3>PICK your Materials?:&nbsp;</h3>
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>
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>
67 </form>
68 ";
70 return $y;
73 }
77 sub template
78 {
80 $all = shift;
81 $all =~ m/_(.*)/;
83 $materialcolor = $1;
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\">
93 ";
95 return $r;
96 }
101 sub inputbox
102 {
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>>>>
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.
113 #take care of everythign but acrylic clear type
114 if (not($type =~ m/acrylic_clear/))
115 {
116 return "comming soon!";
117 }
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> };
126 }
135 sub display
136 {
137 $all = shift;
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;
146 }
151 sub gen
152 {
153 {
154 local( $/, *FH ) ;
155 open( FH, "<./buy.html" ) or die "sudden flaming death\n";
156 $a = <FH>;
157 }
159 {
160 local( $/, *FH ) ;
161 open( FH, "<./top_menu.include" ) or die "sudden flaming death\n";
162 $b = <FH>;
163 }
165 $a =~ s/PERL-REPLACE::TOP_MENU/$b/; #equivalent to <?php include("top_menu.html"); ?>, but in perl with more memory problems :)
167 return $a
170 };