Mercurial > laserkard
diff 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 |
line wrap: on
line diff
1.1 --- a/js-lib/buy3.js Mon Jul 26 04:13:05 2010 -0400 1.2 +++ b/js-lib/buy3.js Mon Jul 26 05:45:51 2010 -0400 1.3 @@ -12,73 +12,44 @@ 1.4 var display; 1.5 var color; 1.6 var style; 1.7 - 1.8 - // var state_map = 1.9 - // {green :{ 1.10 - // ref: null, 1.11 - // offState : null, 1.12 - // onState : null}, 1.13 - // red : { 1.14 - // offState: {"fill" : "#300", "scale" : 1}, 1.15 - // onState : {"fill" : "#F00" ,"scale" : 1}, 1.16 - // ref : null}, 1.17 - // blue : { 1.18 - // offState : null, 1.19 - // onState : null, 1.20 - // ref : null}, 1.21 - // black : {offState : null, onState : null, ref : null}, 1.22 - // display : {ref : null, state : {"fill" : "black"}}}; 1.23 1.24 - var state_map = 1.25 - {green : { ref: null, offState : null, onState : null}, 1.26 - red : { 1.27 - offState: {"fill" : "#300", "scale" : 1}, 1.28 - onState : {"fill" : "#F00" ,"scale" : 1}, 1.29 - ref : null}, 1.30 - blue : { 1.31 - offState : null, 1.32 - onState : null, 1.33 - ref : null}, 1.34 - black : {offState : null, onState : null, ref : null}, 1.35 - display : {ref : null, state : {"fill" : "black"}}}; 1.36 + var state_map = { 1.37 + green : {ref : null, 1.38 + offState : {"fill" : "#030", "scale": 1} , 1.39 + onState : {"fill" : "#0F0", "scale": 1}}, 1.40 + red : {ref : null, 1.41 + offState: {"fill" : "#300", "scale" : 1}, 1.42 + onState : {"fill" : "#F00" ,"scale" : 1}}, 1.43 + blue : {ref : null, 1.44 + offState : {"fill" : "#003", "scale": 1}, 1.45 + onState : {"fill" : "#00F", "scale": 1}, 1.46 + ref : null}, 1.47 + black : {offState : null, onState : null, ref : null}, 1.48 + display : {ref : null, state : {"fill" : "black"}}}; 1.49 1.50 var color_select_init = (function (){ 1.51 state_map["red"].ref = 1.52 color.rect(1, 1, 70, 50, 10).attr(state_map["red"].offState); 1.53 state_map["red"].ref.node.onclick = 1.54 (function (){order.color= "red"; update();}); 1.55 - 1.56 - state_map["green"].onState = 1.57 - {"fill" : "#0F0", "scale": 1}; 1.58 - state_map["green"].offState = 1.59 - {"fill" : "#030", "scale": 1}; 1.60 state_map["green"].ref = 1.61 color.rect(80, 1, 70, 50, 10).attr(state_map["green"].offState); 1.62 state_map["green"].ref.node.onclick = 1.63 (function (){order.color= "green"; update();}); 1.64 - 1.65 - state_map["blue"].onState = 1.66 - {"fill" : "#00F", "scale": 1}; 1.67 - state_map["blue"].offState = 1.68 - {"fill" : "#003", "scale": 1}; 1.69 state_map["blue"].ref = 1.70 color.rect(160, 1, 70, 50, 10).attr(state_map["blue"].offState); 1.71 state_map["blue"].ref.node.onclick = 1.72 (function (){order.color= "blue"; update();}); 1.73 - 1.74 1.75 toggle_on(state_map[order.color]); 1.76 }); 1.77 1.78 var display_init = (function (){ 1.79 - state_map["display"].state = 1.80 - {"fill": "white"}; 1.81 state_map["display"].ref = 1.82 display.rect(1, 1, 338, 213, 20).attr(state_map["display"].state); 1.83 }); 1.84 1.85 var init = (function () { 1.86 - 1.87 display = Raphael("card-display", 340 ,215); 1.88 color = Raphael("color-select", 300, 100); 1.89 style = Raphael("style-select", 200, 70); 1.90 @@ -113,7 +84,8 @@ 1.91 return (function (){ 1.92 if (order.color === color){} 1.93 else { 1.94 - state_map["display"].ref.animate({"fill" : order.color}, 2000); 1.95 + state_map["display"].ref.animate( 1.96 + {"fill" : state_map[order.color].onState.fill}, 2000); 1.97 color = order.color;}})})(); 1.98 1.99 var update = (function (){