web/comparator_visualization.js

58 lines
1.1 KiB
JavaScript
Raw Normal View History

let lRecorder = new Recorder(
d3.select("#left").graphviz(),
null,
"left"
).renderAtOnce();
let rRecorder = new Recorder(
d3.select("#right").graphviz(),
null,
"right"
).renderAtOnce();
let left = new AVLTree();
let right = new WAVLTree();
left.recorder = lRecorder;
right.recorder = rRecorder;
function insertCallback() {
let number = document.getElementById("insertInput").value;
if (number === "") {
return false;
}
let value = parseInt(number);
left.insert(value);
right.insert(value);
document.getElementById("insertInput").value = "";
return false;
}
function deleteCallback() {
let number = document.getElementById("deleteInput").value;
if (number === "") {
return false;
}
let value = parseInt(number);
left.delete(value);
right.delete(value);
document.getElementById("deleteInput").value = "";
return false;
}
async function render() {
await Promise.all([
new Promise(() => lRecorder.render()),
new Promise(() => rRecorder.render()),
]);
// lRecorder.render();
// rRecorder.render();
setTimeout(render);
}
render();