-
Notifications
You must be signed in to change notification settings - Fork 101
/
index.js
50 lines (46 loc) · 1.37 KB
/
index.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
46
47
48
49
50
import SeempleObject from 'seemple/object';
import Upload from './tabs/upload';
import CopyPaste from './tabs/copy-paste';
import Output from './tabs/output';
import { setUseECMAScriptNext } from './util/use-ecmascript-next';
class Application extends SeempleObject {
constructor() {
super()
.set({
activeTabName: 'upload',
useECMAScriptNext: !!localStorage.useECMAScriptNext
})
.addDataKeys(['upload', 'copyPaste', 'output'])
.instantiate({
upload: Upload,
copyPaste: CopyPaste,
output: Output
})
.bindNode('useECMAScriptNext', '.use-ecmascript-next')
.on('change:useECMAScriptNext', () => {
const { useECMAScriptNext } = this;
setUseECMAScriptNext(useECMAScriptNext);
if (useECMAScriptNext) {
localStorage.useECMAScriptNext = 'y';
} else {
delete localStorage.useECMAScriptNext;
}
}, true)
.on({
'*@change:active': (evt) => {
if (evt.value === true) {
for (const tab of this) {
if (tab !== evt.self) {
tab.active = false;
}
}
}
},
'upload@submitCode copyPaste@submitCode': (code) => {
this.output.active = true;
this.output.inputCode = code;
}
});
}
}
export default new Application();