-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvc.js
122 lines (107 loc) · 2.89 KB
/
vc.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
window.view = {
nodes : {
timer : null,
timer_sec : null,
monitor : null,
code : null,
do_nothing_button : null
},
enable : function(bt) {
var node = this.nodes[bt];
if (node) {
node.disabled = false;
}
},
disable : function(bt) {
var node = this.nodes[bt];
if (node) {
node.disabled = true;
}
},
caption : function(bt,str) {
var node = this.nodes[bt];
if (node) {
node.innerHTML = str;
}
},
value : function(node) {
var node = this.nodes[node];
return (node) ? node.value : null;
}
};
window.controller = {
states : {},
state : function(sys, v) {
if (v == null) {
return this.states[sys];
} else {
this.states[sys] = ~~v;
}
},
'swit4' : function(sys) {
var non = sys + "_switch";
var fc = this[non];
if (fc) {
this[non]();
}
},
monitor_switch : function() {
var is = this.state('monitor');
this.state( 'monitor', !is );
if (is) {
progress.stop();
view.enable('timer');
view.caption('monitor','Start');
view.caption('timer','Start');
} else {
progress.collect();
view.disable('timer');
view.caption('timer','Stop');
view.caption('monitor','Stop');
}
},
timer_switch : function() {
var is = this.state( 'timer' );
this.state( 'timer', !is );
if (is) {
view.caption( 'timer', 'Start' );
timer.stop();
} else {
view.caption( 'timer', 'Stop' );
var sec = view.value('timer_sec');
if (!sec || isNaN( sec )) {
timer.collect();
} else {
view.disable('timer');
timer.collect(Number(sec), function() {
controller.timer_switch();
view.enable( 'timer' );
});
}
}
},
intercept : function() {
var code = view.value('code');
eval( code );
},
nothing : function() {
var is = this.state('nothing');
this.state('nothing', !is);
view.caption('nothing', is ? 'Do Nothing' : 'Do Something');
},
flashback_switch : function() {
var is = this.state('flashback');
this.state('flashback', !is);
if (is) {
flashback.stop();
view.caption("flashback", "Start");
view.enable("timer");
view.enable("monitor");
} else {
flashback.collect();
view.caption("flashback", "Stop");
view.disable("timer");
view.disable("monitor");
}
}
}