Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added ability to change order

  • Loading branch information...
commit 7775684725e4388cbd76f3daa20c64502c5bd0ff 1 parent ec28d41
@johngunderman authored
Showing with 32 additions and 4 deletions.
  1. +4 −0 index.html
  2. +27 −3 main.js
  3. +1 −1  style.css
View
4 index.html
@@ -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,4 +1,6 @@
-var tree = new b_tree(3);
+var order = 3;
+var tree = new b_tree(order);
+
function resizeCanvas() {
$("#board").empty();
@@ -6,6 +8,28 @@ function resizeCanvas() {
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
2  style.css
@@ -10,7 +10,7 @@ h1 {
}
#buttons {
- margin-left: 50%;
+ margin-left: 10%;
}
#board {
Please sign in to comment.
Something went wrong with that request. Please try again.