web/visualization.js

48 lines
949 B
JavaScript
Raw Normal View History

let recorder = new Recorder(
d3.select("#graph").graphviz(),
document.getElementById("comment"),
"graph"
);
let tree = new WAVLTree();
tree.recorder = recorder;
function insertCallback() {
let number = document.getElementById("insertInput").value;
if (number === "") {
return false;
}
let value = parseInt(number);
tree.insert(value);
document.getElementById("insertInput").value = "";
return false;
}
function deleteCallback() {
let number = document.getElementById("deleteInput").value;
if (number === "") {
return false;
}
let value = parseInt(number);
tree.delete(value);
document.getElementById("deleteInput").value = "";
return false;
}
function switchTree(TreeType) {
tree = new TreeType();
tree.recorder = recorder;
recorder.clear();
tree.record("");
}
function render() {
recorder.render();
setTimeout(render);
}
render();