Permalink
Browse files

added ability to change order

  • Loading branch information...
1 parent ec28d41 commit 7775684725e4388cbd76f3daa20c64502c5bd0ff @johngunderman committed May 8, 2012
Showing with 32 additions and 4 deletions.
  1. +4 −0 index.html
  2. +27 −3 main.js
  3. +1 −1 style.css
View
@@ -13,6 +13,10 @@
<div id="board"></div>
<br/>
<div id="buttons">
+ <input type="text" id="order" size="3" maxlength="3"/>
+ <button type="button" onclick="setOrder();">Set Order</button>
+ <img id="insertLoader" class="imgLoader" src="images/loading.gif" />
+
<select id="treeSelector">
<option id="btree">B Tree</option>
<option id="bptree">B+ Tree</option>
View
30 main.js
@@ -1,11 +1,35 @@
-var tree = new b_tree(3);
+var order = 3;
+var tree = new b_tree(order);
+
function resizeCanvas() {
$("#board").empty();
initializeCanvas();
drawTree(tree);
};
+function setOrder() {
+
+ var a = parseInt($("#order").val());
+ console.log("we be changing the order to " + a);
+
+ if (a > 3 && a < 10) {
+ order = a;
+ }
+
+ var str = $("#treeSelector option:selected").attr('id');
+
+ if (str == "btree") {
+ tree = new b_tree(order);
+ resizeCanvas();
+ }
+
+ if (str == "bptree") {
+ tree = new bp_tree(order);
+ resizeCanvas();
+ }
+}
+
window.onload = function() {
resizeCanvas();
@@ -20,12 +44,12 @@ window.onload = function() {
var str = $("#treeSelector option:selected").attr('id');
if (str == "btree") {
- tree = new b_tree(3);
+ tree = new b_tree(order);
resizeCanvas();
}
if (str == "bptree") {
- tree = new bp_tree(3);
+ tree = new bp_tree(order);
resizeCanvas();
}
}).change();
View
@@ -10,7 +10,7 @@ h1 {
}
#buttons {
- margin-left: 50%;
+ margin-left: 10%;
}
#board {

0 comments on commit 7775684

Please sign in to comment.