From f37456d27d33b8f5ff734218e3dfc34dfab09969 Mon Sep 17 00:00:00 2001 From: Steven Schronk Date: Mon, 2 Jul 2012 11:04:02 -0500 Subject: [PATCH] Refactored canvas clicked function. --- finite_automata.html | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/finite_automata.html b/finite_automata.html index 24463b8..c8e163b 100644 --- a/finite_automata.html +++ b/finite_automata.html @@ -35,7 +35,7 @@ var canvas; /* object id of canvas tag */ var canvas_input; /* object id of input tag */ var canvas_control; /* object id of control tag */ -var control_panel = new panel("delete", GREEN, '1', '1', '1'); +var control_panel = new panel("del", GREEN, '1', '1', '1'); var ctx; /* context of canvas */ var input; /* context of input canvas */ @@ -106,11 +106,6 @@ function init_stage(){ } stage[5][0].type = "input"; stage[5][8].type = "output"; - - stage[1][1].type = "bus"; - stage[1][1].dir = 1; - - //test_types(); } @@ -816,22 +811,19 @@ function cnvs_clicked(e){ var y_pos = Math.floor(coords[1] / grid_size); if(stage[x_pos][y_pos].type == "input" || stage[x_pos][y_pos].type == "output") { return; } + stage[x_pos][y_pos].type = control_panel.selected; switch(control_panel.selected){ case "bitadd": - stage[x_pos][y_pos].type = "bitadd"; stage[x_pos][y_pos].dir = 1; stage[x_pos][y_pos].col = control_panel.bitadd_col; break; case "branch_rb": - stage[x_pos][y_pos].type = "branch_rb"; stage[x_pos][y_pos].dir = control_panel.branch_rb_dir; break; case "branch_yg": - stage[x_pos][y_pos].type = "branch_yg"; stage[x_pos][y_pos].dir = control_panel.branch_yg_dir; break; case "bus": - stage[x_pos][y_pos].type = "bus"; stage[x_pos][y_pos].dir = control_panel.bus_dir; break; case "delete": -- 2.11.4.GIT