chore: refactor a bit

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2022-05-17 13:55:55 +02:00
parent 8c3de42f1f
commit 9da7013eb0
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -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();