-
Notifications
You must be signed in to change notification settings - Fork 0
/
ui.js
71 lines (52 loc) · 1.74 KB
/
ui.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
(function(global) {
var debugEnabled = false;
var UI = {
// callbacks
onChartSizeChange : function (n) {},
onMinLengthChange: function (n) {},
onMaxLengthChange: function (n) {},
onFlushRequest : function () {},
// Methods
setResult : function (r) {
if (r != undefined && r != null)
setHTML("result","<a href=http://en.wikipedia.org/wiki/"+r+" target=\"_blank\">"+r+"</a>");
},
setChord : function(c) {
if (debugEnabled)
setHTML("chord",'<b>'+c.join('-')+'</b>');
},
setStats : function(s) {
if (debugEnabled)
setHTML("stats",s);
},
ready : function() {
setHTML("result","Please start playing :)");
},
// UI linking
postChartSize : function(e) {
UI.onChartSizeChange(e.innerHtml);
},
postMinLength: function (e) {
UI.onMinLengthChange(e.innterHtml);
},
postMaxLength: function (e) {
UI.onMaxLengthChange(e.innterHtml);
},
postFlush: function (e) {
setHTML("result","Please start playing :)");
setHTML("stats","");
setHTML("chord","");
UI.onFlushRequest();
},
switchDebug : function() {
if (debugEnabled) {
debugEnabled = false;
setHTML("chord","");
setHTML("stats","");
} else {
debugEnabled = true;
}
}
};
global.UI = UI;
})(this);