comparison buy2.js @ 82:da3028a52ac1 laserkard

wrote display_update
author Robert McIntyre <rlm@mit.edu>
date Sun, 25 Jul 2010 10:14:05 -0400
parents 6adb5da55d18
children e0dadfad3dc4
comparison
equal deleted inserted replaced
81:6adb5da55d18 82:da3028a52ac1
1 1
2 var Buy = //main LaserKard function. Deals with updating the order. 2 var Buy =
3 /* main LaserKard function. Deals with updating the order.
4 expects the following:
5
6 classes:
7 select-green
8 select-red
9 select-blue
10 select-black
11
12 ids:
13 card-display
14 color-select
15
16 */
17
3 (function (){ 18 (function (){
4 19
5 var order = 20 var order =
6 {color: "black", 21 {color: "black",
7 style: "bold", 22 style: "bold",
8 quantity: 30, 23 quantity: 30,
9 content: undefined}; 24 content: undefined,
25 info: undefined};
10 26
11 var raphe = undefined; 27 var raphe = undefined;
12 28
13 var init = (function () { 29 var init = (function () {
14
15 raphe = Raphael("card-display", 337 ,212); 30 raphe = Raphael("card-display", 337 ,212);
16 $(".select-green").click(function() {order.color="green";update();}); 31 $(".select-green").click(function() {order.color="green";update();});
17 $(".select-red").click(function() {order.color="red";update();}); 32 $(".select-red").click(function() {order.color="red";update();});
18 $(".select-blue").click(function() {order.color="blue";update();}); 33 $(".select-blue").click(function() {order.color="blue";update();});
19 $(".select-black").click(function() {order.color="black";update();}); 34 $(".select-black").click(function() {order.color="black";update();});
20 35 });
21
22 });
23 36
24 var drawRect = (function (){ 37 var drawRect = (function (){raphe.rect(0,0,337,212);});
25 raphe.rect(0,0,337,212);});
26 38
27 var materials = 39 var display =
28 {green: "buy-images/select-green.png", 40 {green: "buy-images/display-green.png",
29 red: "buy-images/select-red.png", 41 red: "buy-images/display-red.png",
30 blue: "buy-images/select-blue.png", 42 blue: "buy-images/display-blue.png",
31 black: "buy-images/select-black.png"}; 43 black: "buy-images/display-black.png"};
32 44
33 var update_color = (function (){ 45 var update_color = (function (){
34 var color = undefined; 46 var color = undefined;
35 return (function () { 47 return (function () {
48 if (order.color === color){$("#debug").html("REPEAT!");}
49 else {
50 color = order.color;
51
52 $(".selected").removeClass("selected");
53 $(".select-"+order.color).addClass("selected");
54 }});})();
55
56 var update_display = (function (){
57 var color = undefined;
58 return (function () {
36 if (order.color === color){} 59 if (order.color === color){}
37 else {color = order.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 }});})();
38 66
39 var update_display = (function (){});
40 var update_info = (function (){}); 67 var update_info = (function (){});
41 68
42 69
43 var update = (function (){ 70 var update = (function (){
44 update_color(); 71 update_color();
45 $("#whatev").html(order.color); 72 update_display();
46 update_display();
47 update_info();}); 73 update_info();});
48 74
49
50
51 return {init : init, 75 return {init : init,
52 draw : drawRect, 76 draw : drawRect,
53 update : update 77 update : update
54 }; 78 };
55 })(); 79 })();