Mercurial > laserkard
comparison js-lib/buy3.js @ 91:0dd39631299c laserkard
saving progress before adding text entry
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Mon, 26 Jul 2010 05:45:51 -0400 |
parents | 08f93d043ed2 |
children | 614dca52e323 |
comparison
equal
deleted
inserted
replaced
90:08f93d043ed2 | 91:0dd39631299c |
---|---|
10 info: undefined}; | 10 info: undefined}; |
11 | 11 |
12 var display; | 12 var display; |
13 var color; | 13 var color; |
14 var style; | 14 var style; |
15 | |
16 // var state_map = | |
17 // {green :{ | |
18 // ref: null, | |
19 // offState : null, | |
20 // onState : null}, | |
21 // red : { | |
22 // offState: {"fill" : "#300", "scale" : 1}, | |
23 // onState : {"fill" : "#F00" ,"scale" : 1}, | |
24 // ref : null}, | |
25 // blue : { | |
26 // offState : null, | |
27 // onState : null, | |
28 // ref : null}, | |
29 // black : {offState : null, onState : null, ref : null}, | |
30 // display : {ref : null, state : {"fill" : "black"}}}; | |
31 | 15 |
32 var state_map = | 16 var state_map = { |
33 {green : { ref: null, offState : null, onState : null}, | 17 green : {ref : null, |
34 red : { | 18 offState : {"fill" : "#030", "scale": 1} , |
35 offState: {"fill" : "#300", "scale" : 1}, | 19 onState : {"fill" : "#0F0", "scale": 1}}, |
36 onState : {"fill" : "#F00" ,"scale" : 1}, | 20 red : {ref : null, |
37 ref : null}, | 21 offState: {"fill" : "#300", "scale" : 1}, |
38 blue : { | 22 onState : {"fill" : "#F00" ,"scale" : 1}}, |
39 offState : null, | 23 blue : {ref : null, |
40 onState : null, | 24 offState : {"fill" : "#003", "scale": 1}, |
41 ref : null}, | 25 onState : {"fill" : "#00F", "scale": 1}, |
42 black : {offState : null, onState : null, ref : null}, | 26 ref : null}, |
43 display : {ref : null, state : {"fill" : "black"}}}; | 27 black : {offState : null, onState : null, ref : null}, |
28 display : {ref : null, state : {"fill" : "black"}}}; | |
44 | 29 |
45 var color_select_init = (function (){ | 30 var color_select_init = (function (){ |
46 state_map["red"].ref = | 31 state_map["red"].ref = |
47 color.rect(1, 1, 70, 50, 10).attr(state_map["red"].offState); | 32 color.rect(1, 1, 70, 50, 10).attr(state_map["red"].offState); |
48 state_map["red"].ref.node.onclick = | 33 state_map["red"].ref.node.onclick = |
49 (function (){order.color= "red"; update();}); | 34 (function (){order.color= "red"; update();}); |
50 | |
51 state_map["green"].onState = | |
52 {"fill" : "#0F0", "scale": 1}; | |
53 state_map["green"].offState = | |
54 {"fill" : "#030", "scale": 1}; | |
55 state_map["green"].ref = | 35 state_map["green"].ref = |
56 color.rect(80, 1, 70, 50, 10).attr(state_map["green"].offState); | 36 color.rect(80, 1, 70, 50, 10).attr(state_map["green"].offState); |
57 state_map["green"].ref.node.onclick = | 37 state_map["green"].ref.node.onclick = |
58 (function (){order.color= "green"; update();}); | 38 (function (){order.color= "green"; update();}); |
59 | |
60 state_map["blue"].onState = | |
61 {"fill" : "#00F", "scale": 1}; | |
62 state_map["blue"].offState = | |
63 {"fill" : "#003", "scale": 1}; | |
64 state_map["blue"].ref = | 39 state_map["blue"].ref = |
65 color.rect(160, 1, 70, 50, 10).attr(state_map["blue"].offState); | 40 color.rect(160, 1, 70, 50, 10).attr(state_map["blue"].offState); |
66 state_map["blue"].ref.node.onclick = | 41 state_map["blue"].ref.node.onclick = |
67 (function (){order.color= "blue"; update();}); | 42 (function (){order.color= "blue"; update();}); |
68 | |
69 | 43 |
70 toggle_on(state_map[order.color]); | 44 toggle_on(state_map[order.color]); |
71 }); | 45 }); |
72 | 46 |
73 var display_init = (function (){ | 47 var display_init = (function (){ |
74 state_map["display"].state = | |
75 {"fill": "white"}; | |
76 state_map["display"].ref = | 48 state_map["display"].ref = |
77 display.rect(1, 1, 338, 213, 20).attr(state_map["display"].state); | 49 display.rect(1, 1, 338, 213, 20).attr(state_map["display"].state); |
78 }); | 50 }); |
79 | 51 |
80 var init = (function () { | 52 var init = (function () { |
81 | |
82 display = Raphael("card-display", 340 ,215); | 53 display = Raphael("card-display", 340 ,215); |
83 color = Raphael("color-select", 300, 100); | 54 color = Raphael("color-select", 300, 100); |
84 style = Raphael("style-select", 200, 70); | 55 style = Raphael("style-select", 200, 70); |
85 color_select_init(); | 56 color_select_init(); |
86 display_init(); | 57 display_init(); |
111 var color = state_map.display.state.fill | 82 var color = state_map.display.state.fill |
112 | 83 |
113 return (function (){ | 84 return (function (){ |
114 if (order.color === color){} | 85 if (order.color === color){} |
115 else { | 86 else { |
116 state_map["display"].ref.animate({"fill" : order.color}, 2000); | 87 state_map["display"].ref.animate( |
88 {"fill" : state_map[order.color].onState.fill}, 2000); | |
117 color = order.color;}})})(); | 89 color = order.color;}})})(); |
118 | 90 |
119 var update = (function (){ | 91 var update = (function (){ |
120 color_select_update(); | 92 color_select_update(); |
121 display_update(); | 93 display_update(); |