fix: add ability to choose trees to comparator too
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
93cb1d4241
commit
326756db69
4 changed files with 106 additions and 60 deletions
|
@ -2,7 +2,7 @@
|
||||||
# See https://pre-commit.com/hooks.html for more hooks
|
# See https://pre-commit.com/hooks.html for more hooks
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: v3.2.0
|
rev: v4.2.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: trailing-whitespace
|
- id: trailing-whitespace
|
||||||
- id: end-of-file-fixer
|
- id: end-of-file-fixer
|
||||||
|
|
115
comparator.html
115
comparator.html
|
@ -2,54 +2,82 @@
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link
|
|
||||||
href="https://fonts.googleapis.com/css?family=Open+Sans:600"
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
rel="stylesheet"
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet"
|
||||||
/>
|
integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor" crossorigin="anonymous" />
|
||||||
<link
|
|
||||||
rel="stylesheet"
|
|
||||||
href="https://unpkg.com/@patternfly/patternfly/patternfly.css"
|
|
||||||
crossorigin="anonymous"
|
|
||||||
/>
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div style="display: inline">
|
<div class="container px-5 py-5">
|
||||||
<form id="insertTree" onSubmit="return insertCallback()">
|
<div class="row">
|
||||||
<input
|
<div class="col-auto">
|
||||||
id="insertInput"
|
<form class="row" id="insertTree" onSubmit="return insertCallback()">
|
||||||
type="text"
|
<div class="col-auto">
|
||||||
placeholder="Number to insert"
|
<input class="form-control" id="insertInput" type="text" placeholder="Number to insert" autofocus />
|
||||||
maxlength="4"
|
</div>
|
||||||
size="14"
|
<div class="col-auto">
|
||||||
autofocus
|
<button class="btn btn-primary" type="submit">Insert</button>
|
||||||
/>
|
</div>
|
||||||
<input class="pf-c-button pf-m-primary" type="submit" value="Insert" />
|
|
||||||
</form>
|
|
||||||
<form id="deleteTree" onSubmit="return deleteCallback()">
|
|
||||||
<input
|
|
||||||
id="deleteInput"
|
|
||||||
type="text"
|
|
||||||
placeholder="Number to delete"
|
|
||||||
maxlength="4"
|
|
||||||
size="14"
|
|
||||||
/>
|
|
||||||
<input class="pf-c-button pf-m-primary" type="submit" value="Delete" />
|
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<table>
|
<div class="col-auto">
|
||||||
<tr>
|
<form class="row" id="deleteTree" onSubmit="return deleteCallback()">
|
||||||
<td>
|
<div class="col-auto">
|
||||||
<div id="left" style="text-align: center"></div>
|
<input class="form-control" id="deleteInput" type="text" placeholder="Number to delete" />
|
||||||
</td>
|
</div>
|
||||||
<td>
|
<div class="col-auto">
|
||||||
<div id="right" style="text-align: center"></div>
|
<input class="btn btn-primary" type="submit" value="Delete" />
|
||||||
</td>
|
</div>
|
||||||
</tr>
|
</form>
|
||||||
</table>
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
|
|
||||||
|
<div class="row py-3">
|
||||||
|
<div class="col">
|
||||||
|
<div class="row">
|
||||||
|
<h4 class="col-auto">Choose left tree:</h4>
|
||||||
|
<div class="btn-group col-auto" role="group">
|
||||||
|
<input type="radio" class="btn-check" name="leftTreeSelection" id="lWavlTreeBtn" autocomplete="off"
|
||||||
|
onclick="switchTree(WAVLTree, 'left')" />
|
||||||
|
<label class="btn btn-outline-primary" for="lWavlTreeBtn">WAVL</label>
|
||||||
|
|
||||||
|
<input type="radio" class="btn-check" name="leftTreeSelection" id="lAvlTreeBtn" checked autocomplete="off"
|
||||||
|
onclick="switchTree(AVLTree, 'left')" />
|
||||||
|
<label class="btn btn-outline-primary" for="lAvlTreeBtn">AVL</label>
|
||||||
|
|
||||||
|
<input type="radio" class="btn-check" name="leftTreeSelection" id="lRavlTreeBtn" autocomplete="off"
|
||||||
|
onclick="switchTree(RAVLTree, 'left')" />
|
||||||
|
<label class="btn btn-outline-primary" for="lRavlTreeBtn">rAVL</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col">
|
||||||
|
<div class="row">
|
||||||
|
<h4 class="col-auto">Choose right tree:</h4>
|
||||||
|
<div class="btn-group col-auto" role="group">
|
||||||
|
<input type="radio" class="btn-check" name="rightTreeSelection" id="rWavlTreeBtn" checked autocomplete="off"
|
||||||
|
onclick="switchTree(WAVLTree, 'right')" />
|
||||||
|
<label class="btn btn-outline-primary" for="rWavlTreeBtn">WAVL</label>
|
||||||
|
|
||||||
|
<input type="radio" class="btn-check" name="rightTreeSelection" id="rAvlTreeBtn" autocomplete="off"
|
||||||
|
onclick="switchTree(AVLTree, 'right')" />
|
||||||
|
<label class="btn btn-outline-primary" for="rAvlTreeBtn">AVL</label>
|
||||||
|
|
||||||
|
<input type="radio" class="btn-check" name="rightTreeSelection" id="rRavlTreeBtn" autocomplete="off"
|
||||||
|
onclick="switchTree(RAVLTree, 'right')" />
|
||||||
|
<label class="btn btn-outline-primary" for="rRavlTreeBtn">rAVL</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row py-3">
|
||||||
|
<div class="col px-3" style="text-align: center;" id="left"></div>
|
||||||
|
<div class="col px-3" style="text-align: center;" id="right"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<script src="https://d3js.org/d3.v5.min.js"></script>
|
<script src="https://d3js.org/d3.v5.min.js"></script>
|
||||||
<script src="https://unpkg.com/@hpcc-js/wasm@0.3.11/dist/index.min.js"></script>
|
<script src="https://unpkg.com/@hpcc-js/wasm@0.3.11/dist/index.min.js"></script>
|
||||||
|
@ -65,4 +93,9 @@
|
||||||
|
|
||||||
<script src="recorder.js"></script>
|
<script src="recorder.js"></script>
|
||||||
<script src="comparator_visualization.js"></script>
|
<script src="comparator_visualization.js"></script>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/js/bootstrap.bundle.min.js"
|
||||||
|
integrity="sha384-pprn3073KE6tl6bjs2QrFaJGz5/SUsLqktiwsUTF55Jfv3qYSDhgCecCxMW52nD2"
|
||||||
|
crossorigin="anonymous"
|
||||||
|
></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -45,6 +45,24 @@ function deleteCallback() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function switchTree(TreeType, side) {
|
||||||
|
let [lType, rType] =
|
||||||
|
side == "left"
|
||||||
|
? [TreeType, right.constructor]
|
||||||
|
: [left.constructor, TreeType];
|
||||||
|
|
||||||
|
left = new lType();
|
||||||
|
left.recorder = lRecorder;
|
||||||
|
|
||||||
|
right = new rType();
|
||||||
|
right.recorder = rRecorder;
|
||||||
|
|
||||||
|
for (let t of [left, right]) {
|
||||||
|
t.recorder.clear();
|
||||||
|
t.record();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function render() {
|
async function render() {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
new Promise(() => lRecorder.render()),
|
new Promise(() => lRecorder.render()),
|
||||||
|
|
|
@ -2,11 +2,6 @@
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8" />
|
<meta charset="UTF-8" />
|
||||||
<link
|
|
||||||
href="https://fonts.googleapis.com/css?family=Open+Sans:600"
|
|
||||||
rel="stylesheet"
|
|
||||||
/>
|
|
||||||
<link href="style.css" rel="stylesheet" />
|
|
||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||||
<link
|
<link
|
||||||
|
|
Loading…
Reference in a new issue