feat: switch to bootstrap

* switch to bootstrap
* allow selecting one of the trees to be run

Fixes #1
Fixes #4

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2022-05-16 15:58:46 +02:00
parent 8744e552f2
commit 93cb1d4241
Signed by: mfocko
GPG key ID: 7C47D46246790496
3 changed files with 119 additions and 47 deletions

View file

@ -6,7 +6,6 @@
href="https://fonts.googleapis.com/css?family=Open+Sans:600" href="https://fonts.googleapis.com/css?family=Open+Sans:600"
rel="stylesheet" rel="stylesheet"
/> />
<link href="style.css" rel="stylesheet" />
<link <link
rel="stylesheet" rel="stylesheet"
href="https://unpkg.com/@patternfly/patternfly/patternfly.css" href="https://unpkg.com/@patternfly/patternfly/patternfly.css"
@ -15,6 +14,7 @@
</head> </head>
<body> <body>
<div style="display: inline">
<form id="insertTree" onSubmit="return insertCallback()"> <form id="insertTree" onSubmit="return insertCallback()">
<input <input
id="insertInput" id="insertInput"
@ -36,6 +36,7 @@
/> />
<input class="pf-c-button pf-m-primary" type="submit" value="Delete" /> <input class="pf-c-button pf-m-primary" type="submit" value="Delete" />
</form> </form>
</div>
<table> <table>
<tr> <tr>

View file

@ -7,40 +7,98 @@
rel="stylesheet" rel="stylesheet"
/> />
<link href="style.css" rel="stylesheet" /> <link href="style.css" rel="stylesheet" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link <link
href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0-beta1/dist/css/bootstrap.min.css"
rel="stylesheet" rel="stylesheet"
href="https://unpkg.com/@patternfly/patternfly/patternfly.css" integrity="sha384-0evHe/X+R7YkIZDRvuzKMRqM+OrBnVFBL6DOitfPri4tjfHxaWutUpFmBp4vmVor"
crossorigin="anonymous" crossorigin="anonymous"
/> />
</head> </head>
<body> <body>
<form id="insertTree" onSubmit="return insertCallback()"> <div class="container px-5 py-5">
<div class="row">
<div class="col-auto">
<form class="row" id="insertTree" onSubmit="return insertCallback()">
<div class="col-auto">
<input <input
class="form-control"
id="insertInput" id="insertInput"
type="text" type="text"
placeholder="Number to insert" placeholder="Number to insert"
maxlength="4"
size="14"
autofocus autofocus
/> />
<input class="pf-c-button pf-m-primary" type="submit" value="Insert" /> </div>
<div class="col-auto">
<button class="btn btn-primary" type="submit">Insert</button>
</div>
</form> </form>
<form id="deleteTree" onSubmit="return deleteCallback()"> </div>
<div class="col-auto">
<form class="row" id="deleteTree" onSubmit="return deleteCallback()">
<div class="col-auto">
<input <input
class="form-control"
id="deleteInput" id="deleteInput"
type="text" type="text"
placeholder="Number to delete" placeholder="Number to delete"
maxlength="4"
size="14"
/> />
<input class="pf-c-button pf-m-primary" type="submit" value="Delete" /> </div>
<div class="col-auto">
<input class="btn btn-primary" type="submit" value="Delete" />
</div>
</form> </form>
</div>
<p>Current operation: <span id="comment"></span></p> <h4 class="col-auto">Choose a tree:</h4>
<div id="graph" style="text-align: center"></div> <div class="btn-group col-auto" role="group">
<input
type="radio"
class="btn-check"
name="treeSelection"
id="wavlTreeBtn"
checked
autocomplete="off"
onclick="switchTree(WAVLTree)"
/>
<label class="btn btn-outline-primary" for="wavlTreeBtn">WAVL</label>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script> <input
type="radio"
class="btn-check"
name="treeSelection"
id="avlTreeBtn"
autocomplete="off"
onclick="switchTree(AVLTree)"
/>
<label class="btn btn-outline-primary" for="avlTreeBtn">AVL</label>
<input
type="radio"
class="btn-check"
name="treeSelection"
id="ravlTreeBtn"
autocomplete="off"
onclick="switchTree(RAVLTree)"
/>
<label class="btn btn-outline-primary" for="ravlTreeBtn">rAVL</label>
</div>
</div>
<div class="row py-3">
<div class="col-3"></div>
<div class="col alert alert-info" role="alert">
<h5 class="alert-heading">Current operation</h5>
<p id="comment"></p>
</div>
<div class="col-3"></div>
</div>
<div class="row py-3" id="graph" style="text-align: center"></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>
@ -56,4 +114,10 @@
<script src="recorder.js"></script> <script src="recorder.js"></script>
<script src="visualization.js"></script> <script src="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>

View file

@ -33,6 +33,13 @@ function deleteCallback() {
return false; return false;
} }
function switchTree(TreeType) {
tree = new TreeType();
tree.recorder = recorder;
recorder.clear();
tree.record("");
}
function render() { function render() {
recorder.render(); recorder.render();
setTimeout(render); setTimeout(render);