view buy2.js @ 106:5b0753c6f34d laserkard tip

updated to newest compojure and a simpler syntax
author Robert McIntyre <rlm@mit.edu>
date Mon, 27 Sep 2010 20:22:58 -0400
parents e0dadfad3dc4
children
line wrap: on
line source
1 //expects: Raphael.js, jQuery.js
4 var Buy =
5 /* main LaserKard function. Deals with updating the order.
6 expects the following:
8 class:
9 select-green
10 select-red
11 select-blue
12 select-black
14 id:
15 card-display
16 color-select
17 pokedex
18 */
20 (function (){
22 var order =
23 {color: "black",
24 style: "bold",
25 quantity: 30,
26 content: undefined,
27 info: undefined};
29 var display =
30 {green: "buy-images/display-green.png",
31 red: "buy-images/display-red.png",
32 blue: "buy-images/display-blue.png",
33 black: "buy-images/display-black.png"};
35 var raphe = undefined;
37 var init = (function () {
38 raphe = Raphael("card-display", 337 ,212);
39 $(".select-green").click(function() {order.color="green";update();});
40 $(".select-red").click(function() {order.color="red";update();});
41 $(".select-blue").click(function() {order.color="blue";update();});
42 $(".select-black").click(function() {order.color="black";update();});
43 });
45 var drawRect = (function (){raphe.rect(0,0,337,212);});
47 var update_style = (function (){
48 var info = undefined;
49 return (function () {
50 if (order.info === info){}
51 else {
52 info = order.info;
53 $("#pokedex").html(order.info);
54 }});})();
56 var update_pokedex = (function (){
57 var info = undefined;
58 return (function () {
59 if (order.info === info){}
60 else {
61 info = order.info;
62 $("#pokedex").html(order.info);
63 }});})();
65 var update_color = (function (){
66 var color = undefined;
67 return (function () {
68 if (order.color === color){}
69 else {
70 color = order.color;
71 $("#debug").append("color change");
72 $("#card-display > img").attr("src", display[(order.color)]);
73 $(".selected").removeClass("selected");
74 $(".select-"+order.color).addClass("selected");
75 }});})();
77 var update_info = (function (){});
79 var update = (function (){
80 update_style();
81 update_pokedex();
82 update_color();
84 update_info();
85 });
87 return {init : init,
88 draw : drawRect,
89 update : update
90 };
91 })();
95 $(document).ready(function() {
96 Buy.init();
97 Buy.draw();
98 $("#radio1").buttonset();
101 });