Mercurial > laserkard
view 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 source
2 var Buy =3 /* main LaserKard function. Deals with updating the order.4 expects the following:6 classes:7 select-green8 select-red9 select-blue10 select-black12 ids:13 card-display14 color-select16 */18 (function (){20 var order =21 {color: "black",22 style: "bold",23 quantity: 30,24 content: undefined,25 info: undefined};27 var raphe = undefined;29 var init = (function () {30 raphe = Raphael("card-display", 337 ,212);31 $(".select-green").click(function() {order.color="green";update();});32 $(".select-red").click(function() {order.color="red";update();});33 $(".select-blue").click(function() {order.color="blue";update();});34 $(".select-black").click(function() {order.color="black";update();});35 });37 var drawRect = (function (){raphe.rect(0,0,337,212);});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"};45 var update_color = (function (){46 var color = undefined;47 return (function () {48 if (order.color === color){$("#debug").html("REPEAT!");}49 else {50 color = order.color;52 $(".selected").removeClass("selected");53 $(".select-"+order.color).addClass("selected");54 }});})();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)]);65 }});})();67 var update_info = (function (){});70 var update = (function (){71 update_color();72 update_display();73 update_info();});75 return {init : init,76 draw : drawRect,77 update : update78 };79 })();83 $(document).ready(function() {84 // $("#color-select").html("Hello World");85 Buy.init();86 Buy.draw();87 $("#radio1").buttonset();90 });