chore: refactor a bit
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
8c3de42f1f
commit
9da7013eb0
1 changed files with 12 additions and 10 deletions
|
@ -9,8 +9,9 @@ let rRecorder = new Recorder(
|
||||||
"right"
|
"right"
|
||||||
).renderAtOnce();
|
).renderAtOnce();
|
||||||
|
|
||||||
let left = new AVLTree();
|
let left = null;
|
||||||
let right = new WAVLTree();
|
let right = null;
|
||||||
|
setTrees(AVLTree, WAVLTree);
|
||||||
|
|
||||||
function operationCallback(lMethod, rMethod, id) {
|
function operationCallback(lMethod, rMethod, id) {
|
||||||
let number = document.getElementById(id).value;
|
let number = document.getElementById(id).value;
|
||||||
|
@ -41,12 +42,7 @@ function deleteCallback() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function switchTree(TreeType, side) {
|
function setTrees(lType, rType) {
|
||||||
let [lType, rType] =
|
|
||||||
side == "left"
|
|
||||||
? [TreeType, right.constructor]
|
|
||||||
: [left.constructor, TreeType];
|
|
||||||
|
|
||||||
left = new lType();
|
left = new lType();
|
||||||
left.recorder = lRecorder;
|
left.recorder = lRecorder;
|
||||||
|
|
||||||
|
@ -59,13 +55,19 @@ function switchTree(TreeType, side) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function switchTree(TreeType, side) {
|
||||||
|
let [lType, rType] =
|
||||||
|
side == "left"
|
||||||
|
? [TreeType, right.constructor]
|
||||||
|
: [left.constructor, TreeType];
|
||||||
|
setTrees(lType, rType);
|
||||||
|
}
|
||||||
|
|
||||||
async function render() {
|
async function render() {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
new Promise(() => lRecorder.render()),
|
new Promise(() => lRecorder.render()),
|
||||||
new Promise(() => rRecorder.render()),
|
new Promise(() => rRecorder.render()),
|
||||||
]);
|
]);
|
||||||
// lRecorder.render();
|
|
||||||
// rRecorder.render();
|
|
||||||
setTimeout(render);
|
setTimeout(render);
|
||||||
}
|
}
|
||||||
render();
|
render();
|
||||||
|
|
Loading…
Reference in a new issue