diff options
Diffstat (limited to 'solve/static/app.js')
| -rw-r--r-- | solve/static/app.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/solve/static/app.js b/solve/static/app.js new file mode 100644 index 0000000..42b2d07 --- /dev/null +++ b/solve/static/app.js @@ -0,0 +1,20 @@ +import { wrap, proxy } from './comlink-4.3.1.js'; + +report.onclick = () => { location.pathname = '/report' }; + +window.sandbox = new class { + box = wrap(new Worker('sandbox.js', { type: 'module' })); + run(code) { + return new Promise(async (resolve, reject) => { + const errorHandler = proxy(reject); + const result = await this.box.run(code, errorHandler); + resolve(result); + }); + } +}(); + +const query = new URLSearchParams(location.search); +const code = query.get('code') ?? '7*7'; +let tmp = await window.sandbox.run(code); +console.log(tmp); +output.textContent = tmp; |
