# HG changeset patch # User Robert McIntyre # Date 1280201943 14400 # Node ID a0b768d3494a71a2499d44cccd778cf00b5f51ac # Parent 5fb202915c11c3c2906241e21a69fa07478a0bec created text-entry-restriction function diff -r 5fb202915c11 -r a0b768d3494a js-lib/buy3.js --- a/js-lib/buy3.js Mon Jul 26 21:42:20 2010 -0400 +++ b/js-lib/buy3.js Mon Jul 26 23:39:03 2010 -0400 @@ -53,33 +53,30 @@ else if ($.trim($(this).val()) == '') $(this).addClass('exampleText').val($(this).attr('title'));}); + //what an asinine function... referential transparency blah blah... + var deref = (function (var_name){return var_name;}); // Initilization Functions. - var card = - {name : {text: "Robert McIntyre", ref: ""}, - company : {text: "", ref: ""}, - occupation : {text: "", ref: ""}, - phone : {text: "", ref: ""}, - email : {text: "rlm@mit.edu", ref: ""}, - website : {text: "", ref: ""}, - decoration : {text: "", ref: ""}}; - + var card; + var card_init = (function () { - card.name.ref = display.set(); - card.company.ref = display.set(); - card.occupation.ref = display.set(); - card.phone.ref = display.set(); - card.email.ref = display.set(); - card.website.ref = display.set(); - card.decoration.ref = display.set(); + + card = { + name : {text: "Robert McIntyre", ref: display.set()}, + company : {text: "", ref: display.set()}, + occupation : {text: "", ref: display.set()}, + phone : {text: "", ref: display.set()}, + email : {text: "rlm@mit.edu", ref: display.set()}, + website : {text: "", ref: display.set()}, + decoration : {text: "", ref: display.set()}}; }); var order = - {color : "green", + {color : "blue", style : "bold", quantity : 30, content : undefined, @@ -197,9 +194,7 @@ state_map["display"].ref.animate( {"fill" : state_map[order.color].onState.fill}, 2000); color = order.color;}})})(); - - var display_style_update = (function (){ var style = null; return (function (){ @@ -207,8 +202,6 @@ ""; }}); }); - - var key_handling = (function (){ var assoc = (function (target, field) { $(target).keyup(function() { @@ -222,13 +215,30 @@ assoc('#user-website', card.website); }); + var display_style_update = (function (){ + var style = null; + return (function () { + if (style !== order.style){ + + for ( var property in card ) + { + alert( property ); + if (!Cards[order.style][(deref(property))]){ + $("#user" + "-" + property).toggle(400);} + } + + + style = order.style; } + + });})(); var display_text_update = (function (){ var state = {name : "nothing", phone: "nothing", - email: "nothing"}; - //what an asinine function... referential transparency blah blah... - var deref = (function (var_name){return var_name;}); + email: "nothing", + occupation: "nothing", + company : "nothing", + website : "nothing" }; var check_text = (function (var_name) { if (state[deref(var_name)] !== (card[deref(var_name)]).text){ @@ -244,22 +254,22 @@ check_text("name"); check_text("phone"); check_text("email"); + check_text("occupation"); + check_text("company"); + check_text("website"); + $("#debug").html(JSON.stringify(state)); }); - + })(); - - var update = (function (){ color_select_update(); display_color_update(); display_text_update(); -// $("#debug").html(JSON.stringify({name : card.name.text, email : card.email.text, phone : card.phone.text})); + display_style_update(); }); - - // return closure over state return {init : init, update : update};})();