Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Dot in playground #53

Merged
merged 2 commits into from
Mar 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ibis/playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
<h1>Ibis - Playground</h1>
<div id="dotImage" min-width="100%" min-height="100%"></div>
<div id="feedback">Waiting...</div>
<button id="submit">Submit</button>
<button id="to_json">Run (to json)</button>
<button id="to_dot">Run (to dot)</button>
<div class="flex-parent input-area">
<textarea class="flex-child" id="input"></textarea>
<textarea class="flex-child" id="output"></textarea>
Expand Down
19 changes: 10 additions & 9 deletions ibis/playground/playground.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {default as ibis, version_info, best_solutions_to_json} from '../pkg/ibis.js';
import {default as ibis, version_info, best_solutions_to_json, best_solutions_to_dot} from '../pkg/ibis.js';

async function loadIbis() {
const feedback = document.getElementById('feedback');
Expand All @@ -19,14 +19,17 @@ async function getDemoContent() {

async function startup() {
const input = document.getElementById('input');
const submit = document.getElementById('submit');
submit.addEventListener("click", loadDot);
const to_json = document.getElementById('to_json');
to_json.addEventListener("click", () => run(best_solutions_to_json,
input => JSON.stringify(JSON.parse(input), undefined, 2)
));
const to_dot = document.getElementById('to_dot');
to_dot.addEventListener("click", () => run(best_solutions_to_dot, x => x));

await Promise.all([loadIbis(), getDemoContent()]);
await loadDot();
}

async function loadDot() {
async function run(ibis_function, formatter) {
const input = document.getElementById('input');
const output = document.getElementById('output');
const feedback = document.getElementById('feedback');
Expand All @@ -38,12 +41,10 @@ async function loadDot() {
}
// update it
const startTime = performance.now()
const result = best_solutions_to_json(inputText);
const resultJson = JSON.parse(result);
const result = ibis_function(inputText);
const endTime = performance.now()
console.log(resultJson);
feedback.innerText = `Done in ${(endTime-startTime)/1000.0} seconds`;
output.value = JSON.stringify(resultJson, undefined, 4);
output.value = formatter(result);
}

window.onload = function() {
Expand Down
48 changes: 0 additions & 48 deletions ibis/wasm_watch.sh

This file was deleted.

43 changes: 0 additions & 43 deletions ibis/watch.sh

This file was deleted.

15 changes: 0 additions & 15 deletions ibis/watch/index.html

This file was deleted.

30 changes: 0 additions & 30 deletions ibis/watch/reload.js

This file was deleted.

6 changes: 0 additions & 6 deletions ibis/watch/styles.css

This file was deleted.