rlm@85: Buy = (function (){ rlm@85: var order = rlm@86: {color: "red", rlm@86: style: "bold", rlm@86: quantity: 30, rlm@86: content: undefined, rlm@86: info: undefined}; rlm@85: rlm@85: var display; rlm@85: var color; rlm@85: var style; rlm@85: rlm@86: // var select_green; rlm@86: //var select_red; rlm@86: //var select_blue; rlm@86: //var select_black; rlm@86: rlm@86: var select_map = rlm@86: {"green" : 0, rlm@86: "red" : 0, rlm@86: "blue" : 0, rlm@86: "green" : 0}; rlm@86: rlm@86: var toggle_on = (function (button){ rlm@86: button.scale(0.5, 0.75); rlm@86: }); rlm@86: rlm@86: var toggle_off = (function (button){ rlm@86: button.attr("fill", "black"); rlm@86: }); rlm@86: rlm@86: var color_update = (function (){ rlm@86: var color = order.color; rlm@86: return (function (){ rlm@86: if (order.color === color){} rlm@86: else { rlm@86: toggle_off(select_map[color]); rlm@86: toggle_on(select_map[(order.color)]); rlm@86: color = order.color;} rlm@86: });})(); rlm@86: rlm@86: var update = (function (){ rlm@86: color_update();}); rlm@86: rlm@85: var drawInit = (function (){ rlm@86: //color-select init rlm@86: select_map["red"] = color.rect(1, 1, 70, 50, 10).attr("fill","red"); rlm@86: select_map["red"].node.onclick = (function (){ rlm@86: order.color= "red"; update();}); rlm@86: //toggle_on(select_red); rlm@86: rlm@86: rlm@86: select_map["green"] = rlm@86: color.rect(80, 1, 70, 50,10).attr("fill", "green"); rlm@86: select_map["green"].node.onclick = rlm@86: (function (){order.color = "green"; update();}); rlm@86: select_map["blue"] = rlm@86: color.rect(160, 1, 70, 50, 10).attr("fill", "blue"); rlm@86: select_map["blue"].node.onclick = rlm@86: (function (){order.color = "blue"; update();}); rlm@86: rlm@86: toggle_on(select_map[order.color]); rlm@86: rlm@86: display.rect(1, 1, 338, 213, 20); rlm@86: style.rect(1, 1, 10, 10, 5); rlm@86: rlm@86: display.print(40, 45, "Robert" , display.getFont('HelveticaNeue', 700), 30); rlm@86: display.print(40, 90, "McIntyre" , display.getFont('HelveticaNeue', 800), 30); rlm@86: rlm@86: rlm@85: }); rlm@85: rlm@85: var init = (function () { rlm@85: rlm@85: $("#debug").append("init called."); rlm@85: display = Raphael("card-display", 340 ,215); rlm@86: color = Raphael("color-select", 300, 100); rlm@85: style = Raphael("style-select", 200, 70); rlm@85: drawInit(); rlm@85: }); rlm@85: rlm@85: rlm@85: rlm@86: return {init : init, rlm@86: update : update}; rlm@85: })(); rlm@85: rlm@85: rlm@85: rlm@85: $(document).ready(function() { rlm@85: Buy.init(); rlm@85: rlm@85: rlm@85: rlm@85: rlm@85: });