Mercurial > laserkard
comparison buy2.js @ 83:e0dadfad3dc4 laserkard
going to try a pure raphael solution
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Sun, 25 Jul 2010 21:46:00 -0400 |
parents | da3028a52ac1 |
children |
comparison
equal
deleted
inserted
replaced
82:da3028a52ac1 | 83:e0dadfad3dc4 |
---|---|
1 //expects: Raphael.js, jQuery.js | |
2 | |
1 | 3 |
2 var Buy = | 4 var Buy = |
3 /* main LaserKard function. Deals with updating the order. | 5 /* main LaserKard function. Deals with updating the order. |
4 expects the following: | 6 expects the following: |
5 | 7 |
6 classes: | 8 class: |
7 select-green | 9 select-green |
8 select-red | 10 select-red |
9 select-blue | 11 select-blue |
10 select-black | 12 select-black |
11 | 13 |
12 ids: | 14 id: |
13 card-display | 15 card-display |
14 color-select | 16 color-select |
15 | 17 pokedex |
16 */ | 18 */ |
17 | 19 |
18 (function (){ | 20 (function (){ |
19 | 21 |
20 var order = | 22 var order = |
21 {color: "black", | 23 {color: "black", |
22 style: "bold", | 24 style: "bold", |
23 quantity: 30, | 25 quantity: 30, |
24 content: undefined, | 26 content: undefined, |
25 info: undefined}; | 27 info: undefined}; |
28 | |
29 var display = | |
30 {green: "buy-images/display-green.png", | |
31 red: "buy-images/display-red.png", | |
32 blue: "buy-images/display-blue.png", | |
33 black: "buy-images/display-black.png"}; | |
26 | 34 |
27 var raphe = undefined; | 35 var raphe = undefined; |
28 | 36 |
29 var init = (function () { | 37 var init = (function () { |
30 raphe = Raphael("card-display", 337 ,212); | 38 raphe = Raphael("card-display", 337 ,212); |
33 $(".select-blue").click(function() {order.color="blue";update();}); | 41 $(".select-blue").click(function() {order.color="blue";update();}); |
34 $(".select-black").click(function() {order.color="black";update();}); | 42 $(".select-black").click(function() {order.color="black";update();}); |
35 }); | 43 }); |
36 | 44 |
37 var drawRect = (function (){raphe.rect(0,0,337,212);}); | 45 var drawRect = (function (){raphe.rect(0,0,337,212);}); |
46 | |
47 var update_style = (function (){ | |
48 var info = undefined; | |
49 return (function () { | |
50 if (order.info === info){} | |
51 else { | |
52 info = order.info; | |
53 $("#pokedex").html(order.info); | |
54 }});})(); | |
55 | |
56 var update_pokedex = (function (){ | |
57 var info = undefined; | |
58 return (function () { | |
59 if (order.info === info){} | |
60 else { | |
61 info = order.info; | |
62 $("#pokedex").html(order.info); | |
63 }});})(); | |
38 | 64 |
39 var display = | |
40 {green: "buy-images/display-green.png", | |
41 red: "buy-images/display-red.png", | |
42 blue: "buy-images/display-blue.png", | |
43 black: "buy-images/display-black.png"}; | |
44 | |
45 var update_color = (function (){ | 65 var update_color = (function (){ |
46 var color = undefined; | 66 var color = undefined; |
47 return (function () { | 67 return (function () { |
48 if (order.color === color){$("#debug").html("REPEAT!");} | 68 if (order.color === color){} |
49 else { | 69 else { |
50 color = order.color; | 70 color = order.color; |
51 | 71 $("#debug").append("color change"); |
72 $("#card-display > img").attr("src", display[(order.color)]); | |
52 $(".selected").removeClass("selected"); | 73 $(".selected").removeClass("selected"); |
53 $(".select-"+order.color).addClass("selected"); | 74 $(".select-"+order.color).addClass("selected"); |
54 }});})(); | 75 }});})(); |
55 | 76 |
56 var update_display = (function (){ | |
57 var color = undefined; | |
58 return (function () { | |
59 if (order.color === color){} | |
60 else { | |
61 $("#debug").html("make displayings!!! Sexy Time!!!"); | |
62 color = order.color; | |
63 $("#card-display > img").attr("src", display[(order.color)]); | |
64 | |
65 }});})(); | |
66 | |
67 var update_info = (function (){}); | 77 var update_info = (function (){}); |
68 | 78 |
69 | |
70 var update = (function (){ | 79 var update = (function (){ |
71 update_color(); | 80 update_style(); |
72 update_display(); | 81 update_pokedex(); |
73 update_info();}); | 82 update_color(); |
83 | |
84 update_info(); | |
85 }); | |
74 | 86 |
75 return {init : init, | 87 return {init : init, |
76 draw : drawRect, | 88 draw : drawRect, |
77 update : update | 89 update : update |
78 }; | 90 }; |
79 })(); | 91 })(); |
80 | 92 |
81 | 93 |
82 | 94 |
83 $(document).ready(function() { | 95 $(document).ready(function() { |
84 // $("#color-select").html("Hello World"); | |
85 Buy.init(); | 96 Buy.init(); |
86 Buy.draw(); | 97 Buy.draw(); |
87 $("#radio1").buttonset(); | 98 $("#radio1").buttonset(); |
88 | 99 |
89 | 100 |