diff buy2.js @ 81:6adb5da55d18 laserkard

getting color select working
author Robert McIntyre <rlm@mit.edu>
date Sun, 25 Jul 2010 05:45:56 -0400
parents d913ee48d935
children da3028a52ac1
line wrap: on
line diff
     1.1 --- a/buy2.js	Sun Jul 25 03:11:26 2010 -0400
     1.2 +++ b/buy2.js	Sun Jul 25 05:45:56 2010 -0400
     1.3 @@ -1,37 +1,66 @@
     1.4  
     1.5 -var Buy = 
     1.6 +var Buy = //main LaserKard function.  Deals with updating the order. 
     1.7  (function (){ 
     1.8  
     1.9      var order = 
    1.10      {color: "black",
    1.11       style: "bold",
    1.12 -     quantity: 30};
    1.13 -    
    1.14 +     quantity: 30,
    1.15 +     content: undefined};
    1.16 +
    1.17      var raphe = undefined;
    1.18      
    1.19      var init = (function () {
    1.20 -	    $("#whatev").html("LAMBDA the ULTIMATE!!!");
    1.21 -	    raphe = Raphael("card-display", 200 ,200);});
    1.22 +	    
    1.23 +	    raphe = Raphael("card-display", 337 ,212);
    1.24 +	    $(".select-green").click(function() {order.color="green";update();});
    1.25 +	    $(".select-red").click(function() {order.color="red";update();});
    1.26 +	    $(".select-blue").click(function() {order.color="blue";update();});
    1.27 +	    $(".select-black").click(function() {order.color="black";update();});
    1.28 +	    
    1.29 +	    
    1.30 +});
    1.31      
    1.32      var drawRect = (function (){
    1.33 -	    raphe.rect(1,1,50,50);});
    1.34 +	    raphe.rect(0,0,337,212);});
    1.35      
    1.36      var materials = 
    1.37 -    {green: "buy-images/green.png",
    1.38 -     red:   "buy-images/red.png",
    1.39 -     blue:  "buy-images/blue.png",
    1.40 -     black: "buy-images/black.png"}
    1.41 +    {green: "buy-images/select-green.png",
    1.42 +     red:   "buy-images/select-red.png",
    1.43 +     blue:  "buy-images/select-blue.png",
    1.44 +     black: "buy-images/select-black.png"};
    1.45 +
    1.46 +    var update_color = (function (){
    1.47 +    	    var color = undefined;
    1.48 +    	    return (function () {
    1.49 +		    if (order.color === color){}
    1.50 +		    else {color = order.color;}});})();
    1.51      
    1.52 +    var update_display = (function (){});
    1.53 +    var update_info = (function (){});
    1.54 +    
    1.55 +    
    1.56 +    var update = (function (){
    1.57 +    	    update_color();
    1.58 +	    $("#whatev").html(order.color);
    1.59 +    	    update_display();
    1.60 +    	    update_info();});
    1.61 +	    
    1.62 +
    1.63 +
    1.64      return {init : init,
    1.65 -	    draw : drawRect};
    1.66 +	    draw : drawRect,
    1.67 +	    update : update
    1.68 +	    };
    1.69  })();
    1.70  
    1.71  
    1.72  
    1.73  $(document).ready(function() {
    1.74 -	$("#color-select").html("Hello World");
    1.75 +	//	$("#color-select").html("Hello World");
    1.76  	Buy.init();
    1.77  	Buy.draw();
    1.78 +	$("#radio1").buttonset();
    1.79  
    1.80  	
    1.81      });