Mercurial > laserkard
diff 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 |
line wrap: on
line diff
1.1 --- a/buy2.js Sun Jul 25 05:45:56 2010 -0400 1.2 +++ b/buy2.js Sun Jul 25 10:14:05 2010 -0400 1.3 @@ -1,53 +1,77 @@ 1.4 1.5 -var Buy = //main LaserKard function. Deals with updating the order. 1.6 +var Buy = 1.7 + /* main LaserKard function. Deals with updating the order. 1.8 + expects the following: 1.9 + 1.10 + classes: 1.11 + select-green 1.12 + select-red 1.13 + select-blue 1.14 + select-black 1.15 + 1.16 + ids: 1.17 + card-display 1.18 + color-select 1.19 + 1.20 + */ 1.21 + 1.22 (function (){ 1.23 1.24 var order = 1.25 {color: "black", 1.26 style: "bold", 1.27 quantity: 30, 1.28 - content: undefined}; 1.29 + content: undefined, 1.30 + info: undefined}; 1.31 1.32 var raphe = undefined; 1.33 1.34 var init = (function () { 1.35 - 1.36 raphe = Raphael("card-display", 337 ,212); 1.37 $(".select-green").click(function() {order.color="green";update();}); 1.38 $(".select-red").click(function() {order.color="red";update();}); 1.39 $(".select-blue").click(function() {order.color="blue";update();}); 1.40 $(".select-black").click(function() {order.color="black";update();}); 1.41 - 1.42 - 1.43 -}); 1.44 + }); 1.45 1.46 - var drawRect = (function (){ 1.47 - raphe.rect(0,0,337,212);}); 1.48 + var drawRect = (function (){raphe.rect(0,0,337,212);}); 1.49 1.50 - var materials = 1.51 - {green: "buy-images/select-green.png", 1.52 - red: "buy-images/select-red.png", 1.53 - blue: "buy-images/select-blue.png", 1.54 - black: "buy-images/select-black.png"}; 1.55 + var display = 1.56 + {green: "buy-images/display-green.png", 1.57 + red: "buy-images/display-red.png", 1.58 + blue: "buy-images/display-blue.png", 1.59 + black: "buy-images/display-black.png"}; 1.60 1.61 var update_color = (function (){ 1.62 var color = undefined; 1.63 return (function () { 1.64 + if (order.color === color){$("#debug").html("REPEAT!");} 1.65 + else { 1.66 + color = order.color; 1.67 + 1.68 + $(".selected").removeClass("selected"); 1.69 + $(".select-"+order.color).addClass("selected"); 1.70 + }});})(); 1.71 + 1.72 + var update_display = (function (){ 1.73 + var color = undefined; 1.74 + return (function () { 1.75 if (order.color === color){} 1.76 - else {color = order.color;}});})(); 1.77 + else { 1.78 + $("#debug").html("make displayings!!! Sexy Time!!!"); 1.79 + color = order.color; 1.80 + $("#card-display > img").attr("src", display[(order.color)]); 1.81 + 1.82 + }});})(); 1.83 1.84 - var update_display = (function (){}); 1.85 var update_info = (function (){}); 1.86 1.87 1.88 var update = (function (){ 1.89 update_color(); 1.90 - $("#whatev").html(order.color); 1.91 - update_display(); 1.92 + update_display(); 1.93 update_info();}); 1.94 1.95 - 1.96 - 1.97 return {init : init, 1.98 draw : drawRect, 1.99 update : update