diff options
| author | Louis Burda <quent.burda@gmail.com> | 2024-04-17 02:38:10 +0200 |
|---|---|---|
| committer | Louis Burda <quent.burda@gmail.com> | 2024-04-17 02:38:41 +0200 |
| commit | 67484e60f9627d69e406a533afd4bb2be9480c21 (patch) | |
| tree | 18f048aacca8902c9ba095699d34d86502727cfd /solve/static/app.js | |
| parent | 727aaf505985fdbcf3ceaf5148df8ce8fb427ed0 (diff) | |
| download | cscg2024-wsbx-master.tar.gz cscg2024-wsbx-master.zip | |
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; |
