This repository has been archived by the owner on Jun 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
62 lines (58 loc) · 1.44 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
51
52
53
54
55
56
57
58
59
60
61
62
import Moon from 'moonjs';
import domLoaded from 'dom-loaded';
import execute from './exec.js';
window.app = null;
Moon.directive('selectedtab', (el, val) => {
el.classList.remove('is-active', 'nvm');
el.classList.add(app.get('helptopic') === val ? 'is-active' : 'nvm');
el.onclick = () => {
console.log('CLICK');
app.set('helptopic', val);
app.build();
};
});
domLoaded.then(() => {
console.log('Initializing');
app = new Moon({
el: '#app',
data: {
main: true,
help: false,
helptopic: 0,
running: false,
execpromise: null,
rawMessages: ["Welcome to ISUv2!"],
messages: "Welcome to ISUv2!"
},
methods: {
toggle() {
new Promise(() => {
document.getElementsByTagName('html')[0].style.backgroundColor = !this.get('main') ? 'black' : 'inherit';
});
this.set('main', !this.get('main'));
this.set('help', !this.get('help'));
},
runcode() {
this.set('running', true);
this.set('execpromise',execute(document.getElementById('code').value)
.then(() => {
this.set('running', false);
}));
},
terminate() {
this.get('execpromise').cancel();
this.set('running', false);
},
addMessage(mesg) {
this.set('rawMessages', this.get('rawMessages').concat(mesg));
this.set('messages', this.get('rawMessages').join('<br />'));
this.build();
},
clearMessages() {
this.set('rawMessages', []);
this.set('messages', '');
this.build();
}
}
});
});