# HG changeset patch # User Robert McIntyre # Date 1280137551 14400 # Node ID 0dd39631299c73eb9461c49866e110dce74b34a6 # Parent 08f93d043ed2739c52dcb0f44addd00cf9d0f62a saving progress before adding text entry diff -r 08f93d043ed2 -r 0dd39631299c js-lib/buy3.js --- a/js-lib/buy3.js Mon Jul 26 04:13:05 2010 -0400 +++ b/js-lib/buy3.js Mon Jul 26 05:45:51 2010 -0400 @@ -12,73 +12,44 @@ var display; var color; var style; - - // var state_map = - // {green :{ - // ref: null, - // offState : null, - // onState : null}, - // red : { - // offState: {"fill" : "#300", "scale" : 1}, - // onState : {"fill" : "#F00" ,"scale" : 1}, - // ref : null}, - // blue : { - // offState : null, - // onState : null, - // ref : null}, - // black : {offState : null, onState : null, ref : null}, - // display : {ref : null, state : {"fill" : "black"}}}; - var state_map = - {green : { ref: null, offState : null, onState : null}, - red : { - offState: {"fill" : "#300", "scale" : 1}, - onState : {"fill" : "#F00" ,"scale" : 1}, - ref : null}, - blue : { - offState : null, - onState : null, - ref : null}, - black : {offState : null, onState : null, ref : null}, - display : {ref : null, state : {"fill" : "black"}}}; + var state_map = { + green : {ref : null, + offState : {"fill" : "#030", "scale": 1} , + onState : {"fill" : "#0F0", "scale": 1}}, + red : {ref : null, + offState: {"fill" : "#300", "scale" : 1}, + onState : {"fill" : "#F00" ,"scale" : 1}}, + blue : {ref : null, + offState : {"fill" : "#003", "scale": 1}, + onState : {"fill" : "#00F", "scale": 1}, + ref : null}, + black : {offState : null, onState : null, ref : null}, + display : {ref : null, state : {"fill" : "black"}}}; var color_select_init = (function (){ state_map["red"].ref = color.rect(1, 1, 70, 50, 10).attr(state_map["red"].offState); state_map["red"].ref.node.onclick = (function (){order.color= "red"; update();}); - - state_map["green"].onState = - {"fill" : "#0F0", "scale": 1}; - state_map["green"].offState = - {"fill" : "#030", "scale": 1}; state_map["green"].ref = color.rect(80, 1, 70, 50, 10).attr(state_map["green"].offState); state_map["green"].ref.node.onclick = (function (){order.color= "green"; update();}); - - state_map["blue"].onState = - {"fill" : "#00F", "scale": 1}; - state_map["blue"].offState = - {"fill" : "#003", "scale": 1}; state_map["blue"].ref = color.rect(160, 1, 70, 50, 10).attr(state_map["blue"].offState); state_map["blue"].ref.node.onclick = (function (){order.color= "blue"; update();}); - toggle_on(state_map[order.color]); }); var display_init = (function (){ - state_map["display"].state = - {"fill": "white"}; state_map["display"].ref = display.rect(1, 1, 338, 213, 20).attr(state_map["display"].state); }); var init = (function () { - display = Raphael("card-display", 340 ,215); color = Raphael("color-select", 300, 100); style = Raphael("style-select", 200, 70); @@ -113,7 +84,8 @@ return (function (){ if (order.color === color){} else { - state_map["display"].ref.animate({"fill" : order.color}, 2000); + state_map["display"].ref.animate( + {"fill" : state_map[order.color].onState.fill}, 2000); color = order.color;}})})(); var update = (function (){