56 lines
1.1 KiB
JavaScript
56 lines
1.1 KiB
JavaScript
|
let lRecorder = new Recorder(
|
||
|
d3.select("#left").graphviz(),
|
||
|
"left"
|
||
|
).renderAtOnce();
|
||
|
let rRecorder = new Recorder(
|
||
|
d3.select("#right").graphviz(),
|
||
|
"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();
|