web/visualization.js

37 lines
764 B
JavaScript
Raw Normal View History

let recorder = new Recorder(d3.select("#graph").graphviz(), "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 render() {
recorder.render();
setTimeout(render);
}
render();