comparison buy2.js @ 81:6adb5da55d18 laserkard

getting color select working
author Robert McIntyre <rlm@mit.edu>
date Sun, 25 Jul 2010 05:45:56 -0400
parents d913ee48d935
children da3028a52ac1
comparison
equal deleted inserted replaced
80:d913ee48d935 81:6adb5da55d18
1 1
2 var Buy = 2 var Buy = //main LaserKard function. Deals with updating the order.
3 (function (){ 3 (function (){
4 4
5 var order = 5 var order =
6 {color: "black", 6 {color: "black",
7 style: "bold", 7 style: "bold",
8 quantity: 30}; 8 quantity: 30,
9 9 content: undefined};
10
10 var raphe = undefined; 11 var raphe = undefined;
11 12
12 var init = (function () { 13 var init = (function () {
13 $("#whatev").html("LAMBDA the ULTIMATE!!!"); 14
14 raphe = Raphael("card-display", 200 ,200);}); 15 raphe = Raphael("card-display", 337 ,212);
16 $(".select-green").click(function() {order.color="green";update();});
17 $(".select-red").click(function() {order.color="red";update();});
18 $(".select-blue").click(function() {order.color="blue";update();});
19 $(".select-black").click(function() {order.color="black";update();});
20
21
22 });
15 23
16 var drawRect = (function (){ 24 var drawRect = (function (){
17 raphe.rect(1,1,50,50);}); 25 raphe.rect(0,0,337,212);});
18 26
19 var materials = 27 var materials =
20 {green: "buy-images/green.png", 28 {green: "buy-images/select-green.png",
21 red: "buy-images/red.png", 29 red: "buy-images/select-red.png",
22 blue: "buy-images/blue.png", 30 blue: "buy-images/select-blue.png",
23 black: "buy-images/black.png"} 31 black: "buy-images/select-black.png"};
32
33 var update_color = (function (){
34 var color = undefined;
35 return (function () {
36 if (order.color === color){}
37 else {color = order.color;}});})();
24 38
39 var update_display = (function (){});
40 var update_info = (function (){});
41
42
43 var update = (function (){
44 update_color();
45 $("#whatev").html(order.color);
46 update_display();
47 update_info();});
48
49
50
25 return {init : init, 51 return {init : init,
26 draw : drawRect}; 52 draw : drawRect,
53 update : update
54 };
27 })(); 55 })();
28 56
29 57
30 58
31 $(document).ready(function() { 59 $(document).ready(function() {
32 $("#color-select").html("Hello World"); 60 // $("#color-select").html("Hello World");
33 Buy.init(); 61 Buy.init();
34 Buy.draw(); 62 Buy.draw();
63 $("#radio1").buttonset();
35 64
36 65
37 }); 66 });
38 67