annotate 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
rev   line source
rlm@79 1
rlm@81 2 var Buy = //main LaserKard function. Deals with updating the order.
rlm@80 3 (function (){
rlm@80 4
rlm@80 5 var order =
rlm@80 6 {color: "black",
rlm@80 7 style: "bold",
rlm@81 8 quantity: 30,
rlm@81 9 content: undefined};
rlm@81 10
rlm@80 11 var raphe = undefined;
rlm@80 12
rlm@80 13 var init = (function () {
rlm@81 14
rlm@81 15 raphe = Raphael("card-display", 337 ,212);
rlm@81 16 $(".select-green").click(function() {order.color="green";update();});
rlm@81 17 $(".select-red").click(function() {order.color="red";update();});
rlm@81 18 $(".select-blue").click(function() {order.color="blue";update();});
rlm@81 19 $(".select-black").click(function() {order.color="black";update();});
rlm@81 20
rlm@81 21
rlm@81 22 });
rlm@80 23
rlm@80 24 var drawRect = (function (){
rlm@81 25 raphe.rect(0,0,337,212);});
rlm@80 26
rlm@80 27 var materials =
rlm@81 28 {green: "buy-images/select-green.png",
rlm@81 29 red: "buy-images/select-red.png",
rlm@81 30 blue: "buy-images/select-blue.png",
rlm@81 31 black: "buy-images/select-black.png"};
rlm@81 32
rlm@81 33 var update_color = (function (){
rlm@81 34 var color = undefined;
rlm@81 35 return (function () {
rlm@81 36 if (order.color === color){}
rlm@81 37 else {color = order.color;}});})();
rlm@80 38
rlm@81 39 var update_display = (function (){});
rlm@81 40 var update_info = (function (){});
rlm@81 41
rlm@81 42
rlm@81 43 var update = (function (){
rlm@81 44 update_color();
rlm@81 45 $("#whatev").html(order.color);
rlm@81 46 update_display();
rlm@81 47 update_info();});
rlm@81 48
rlm@81 49
rlm@81 50
rlm@80 51 return {init : init,
rlm@81 52 draw : drawRect,
rlm@81 53 update : update
rlm@81 54 };
rlm@80 55 })();
rlm@80 56
rlm@80 57
rlm@80 58
rlm@80 59 $(document).ready(function() {
rlm@81 60 // $("#color-select").html("Hello World");
rlm@80 61 Buy.init();
rlm@80 62 Buy.draw();
rlm@81 63 $("#radio1").buttonset();
rlm@80 64
rlm@80 65
rlm@80 66 });
rlm@80 67