-
Notifications
You must be signed in to change notification settings - Fork 9
/
dev.js
45 lines (32 loc) · 1 KB
/
dev.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/* eslint-disable */
import $buzz from './src/Buzz';
import engine from './src/Engine';
class EngineTester {
_codeTextArea = null;
_runBtn = null;
_clearBtn = null;
init() {
window.$buzz = $buzz;
window.engine = engine;
this.run = this.run.bind(this);
this.clear = this.clear.bind(this);
this._codeTextArea = document.getElementById('code');
this._runBtn = document.getElementById('run');
this._clearBtn = document.getElementById('clear');
this._runBtn.addEventListener('click', this.run);
this._clearBtn.addEventListener('click', this.clear);
this._codeTextArea.value = window.localStorage.getItem('code');
this._codeTextArea.focus();
}
run() {
const code = this._codeTextArea.value;
window.localStorage.setItem('code', code);
eval(code);
}
clear() {
window.localStorage.setItem('code', '');
this._codeTextArea.value = '';
}
}
window.engineTester = new EngineTester();
window.addEventListener('load', () => engineTester.init());