rlm@83: //expects: Raphael.js, jQuery.js rlm@83: rlm@79: rlm@82: var Buy = rlm@82: /* main LaserKard function. Deals with updating the order. rlm@82: expects the following: rlm@82: rlm@83: class: rlm@82: select-green rlm@82: select-red rlm@82: select-blue rlm@82: select-black rlm@82: rlm@83: id: rlm@82: card-display rlm@82: color-select rlm@83: pokedex rlm@82: */ rlm@82: rlm@80: (function (){ rlm@80: rlm@80: var order = rlm@80: {color: "black", rlm@80: style: "bold", rlm@81: quantity: 30, rlm@82: content: undefined, rlm@82: info: undefined}; rlm@83: rlm@83: var display = rlm@83: {green: "buy-images/display-green.png", rlm@83: red: "buy-images/display-red.png", rlm@83: blue: "buy-images/display-blue.png", rlm@83: black: "buy-images/display-black.png"}; rlm@81: rlm@80: var raphe = undefined; rlm@80: rlm@80: var init = (function () { rlm@81: raphe = Raphael("card-display", 337 ,212); rlm@81: $(".select-green").click(function() {order.color="green";update();}); rlm@81: $(".select-red").click(function() {order.color="red";update();}); rlm@81: $(".select-blue").click(function() {order.color="blue";update();}); rlm@81: $(".select-black").click(function() {order.color="black";update();}); rlm@82: }); rlm@80: rlm@82: var drawRect = (function (){raphe.rect(0,0,337,212);}); rlm@83: rlm@83: var update_style = (function (){ rlm@83: var info = undefined; rlm@83: return (function () { rlm@83: if (order.info === info){} rlm@83: else { rlm@83: info = order.info; rlm@83: $("#pokedex").html(order.info); rlm@83: }});})(); rlm@83: rlm@83: var update_pokedex = (function (){ rlm@83: var info = undefined; rlm@83: return (function () { rlm@83: if (order.info === info){} rlm@83: else { rlm@83: info = order.info; rlm@83: $("#pokedex").html(order.info); rlm@83: }});})(); rlm@80: rlm@81: var update_color = (function (){ rlm@81: var color = undefined; rlm@81: return (function () { rlm@83: if (order.color === color){} rlm@82: else { rlm@82: color = order.color; rlm@83: $("#debug").append("color change"); rlm@83: $("#card-display > img").attr("src", display[(order.color)]); rlm@82: $(".selected").removeClass("selected"); rlm@82: $(".select-"+order.color).addClass("selected"); rlm@82: }});})(); rlm@82: rlm@81: var update_info = (function (){}); rlm@83: rlm@81: var update = (function (){ rlm@83: update_style(); rlm@83: update_pokedex(); rlm@83: update_color(); rlm@83: rlm@83: update_info(); rlm@83: }); rlm@81: rlm@80: return {init : init, rlm@81: draw : drawRect, rlm@81: update : update rlm@81: }; rlm@80: })(); rlm@80: rlm@80: rlm@80: rlm@80: $(document).ready(function() { rlm@80: Buy.init(); rlm@80: Buy.draw(); rlm@81: $("#radio1").buttonset(); rlm@80: rlm@80: rlm@80: }); rlm@80: