-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtabmess.h
238 lines (238 loc) · 14.5 KB
/
tabmess.h
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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
fprintf(stdout, " function messlinekey(endletter, keychar, mainclr) {\n");
fprintf(stdout, " var thisline = endletter.parentElement;\n");
fprintf(stdout, " if (endletter && thisline) {\n");
fprintf(stdout, " var wisplet = document.createElement('b');\n");
fprintf(stdout, " var keycode = keychar.charCodeAt(0);\n");
fprintf(stdout, " if (keycode >= 48 && keycode <= 57) {\n");
fprintf(stdout, " wisplet.className = mainclr;\n");
fprintf(stdout, " } else if (keychar == '<' || keychar == '/') {\n");
fprintf(stdout, " wisplet.className = 'clr6';\n");
fprintf(stdout, " } else { wisplet.className = 'clr3'; }\n");
fprintf(stdout, " wisplet.innerHTML = keychar;\n");
fprintf(stdout, " thisline.insertBefore(wisplet, endletter);\n");
// fprintf(stdout, " iosetmod(thisline, 1);\n");
fprintf(stdout, " }\n");
fprintf(stdout, " }\n");
fprintf(stdout, " function messlinekeys(endletter, eatkeys, setkeys, mainclr) {\n");
fprintf(stdout, " if (!endletter)\n");
fprintf(stdout, " { wispmesscolour = '#f00'; return; }\n");
fprintf(stdout, " else { wispmesscolour = ''; }\n");
// fprintf(stdout, " { console.log('no end letter - bad watch array'); return; }\n");
fprintf(stdout, " var prevl = endletter.previousElementSibling;\n");
fprintf(stdout, " while (prevl && prevl.className != 'lnum') {\n");
fprintf(stdout, " if (eatkeys <= 1) { break; }\n");
fprintf(stdout, " var delel = prevl;\n");
fprintf(stdout, " prevl = prevl.previousElementSibling;\n");
fprintf(stdout, " delel.parentElement.removeChild(delel);\n");
fprintf(stdout, " eatkeys--;\n");
fprintf(stdout, " }\n");
fprintf(stdout, " if (endletter) {\n");
fprintf(stdout, " var ski = -1;\n");
fprintf(stdout, " while (++ski < setkeys.length - 1) {\n");
fprintf(stdout, " var skey = setkeys.charAt(ski);\n");
fprintf(stdout, " messlinekey(endletter, skey, mainclr);\n");
fprintf(stdout, " }\n");
fprintf(stdout, " }\n");
fprintf(stdout, " }\n");
fprintf(stdout, " function messsecondtime(seconds, hashours, hassubsecs) {\n");
fprintf(stdout, " var secs = parseInt(seconds);\n");
fprintf(stdout, " var subsecs = parseFloat(seconds) - secs;\n");
fprintf(stdout, " subsecs = Math.floor(subsecs * 10);\n");
fprintf(stdout, " var mins = Math.floor(secs / 60);\n");
fprintf(stdout, " var hrs = Math.floor(mins / 60);\n");
fprintf(stdout, " mins = mins - (hrs * 60);\n");
fprintf(stdout, " secs = secs - (hrs * 60 * 60) - (mins * 60);\n");
fprintf(stdout, " secs = (secs < 10) ? ':0' + secs : ':' + secs;\n");
fprintf(stdout, " mins = (mins < 10 && hashours) ? '0' + mins : '' + mins;\n");
fprintf(stdout, " if (hashours == -1)\n");
fprintf(stdout, " { hashours = (hrs > 0) ? 1 : 0; }\n");
fprintf(stdout, " hrs = (hashours) ? hrs + ':' : '';\n");
fprintf(stdout, " if (hassubsecs == -1)\n");
fprintf(stdout, " { hassubsecs = (subsecs > 0) ? 1 : 0; }\n");
fprintf(stdout, " subsecs = (hassubsecs) ? '.' + subsecs : '';\n");
fprintf(stdout, " return hrs + mins + secs + subsecs;\n");
fprintf(stdout, " }\n");
fprintf(stdout, " function messlinetimecue(linel, mtype) {\n");
fprintf(stdout, " var tmatch = ['<', ':', ':?', '.?'\n");
fprintf(stdout, " , '/', ':', ':?', '.?', '>'];\n");
fprintf(stdout, " var rmatch = ['<', '?:', ':?', '.?'\n");
fprintf(stdout, " , '-', '?:', ':?', '.?', '>'];\n");
fprintf(stdout, " var allow = ['0', '1', '2', '3', '4', '5'\n");
fprintf(stdout, " , '6', '7', '8', '9', 'N', 'a'];\n");
fprintf(stdout, " var twatch = ['', '', false, false\n");
fprintf(stdout, " , '', '', false, false, null, null];\n");
fprintf(stdout, " var rwatch = ['', false, false, false\n");
fprintf(stdout, " , '', false, false, false, null, null];\n");
fprintf(stdout, " var match = (mtype == 'r') ? rmatch : tmatch;\n");
fprintf(stdout, " var watch = (mtype == 'r') ? rwatch : twatch;\n");
fprintf(stdout, " var charid = linel.firstChild;\n");
fprintf(stdout, " var charcount = 0;\n");
fprintf(stdout, " var mci = 0;\n");
fprintf(stdout, " while (charid = charid ? charid.nextSibling : 0) {\n");
fprintf(stdout, " var charcode = wispascii(charid.innerHTML);\n");
fprintf(stdout, " var charval = String.fromCharCode(charcode);\n");
fprintf(stdout, " var mcj = 0, mcich = 0;\n");
fprintf(stdout, " while (mci + mcj < match.length) {\n");
fprintf(stdout, " var option = (match[mci + mcj].charAt(1) == '?');\n");
fprintf(stdout, " if (match[mci + mcj].charAt(0) == charval) {\n");
fprintf(stdout, " mci = mci + mcj + 1;\n");
fprintf(stdout, " watch[mci - 1] = '';\n");
fprintf(stdout, " mcich = 1;\n");
fprintf(stdout, " if (mci == match.length) {\n");
fprintf(stdout, " watch[mci - 1] = ++charcount;\n");
fprintf(stdout, " watch[mci] = charid;\n");
fprintf(stdout, " return watch;\n"); // valid array
fprintf(stdout, " } else { watch[mci - 1] = ''; }\n");
fprintf(stdout, " break;\n");
fprintf(stdout, " } else if (option)\n");
fprintf(stdout, " { mcj++; }\n"); // next match
fprintf(stdout, " else { break; }\n");
fprintf(stdout, " }\n");
fprintf(stdout, " if (mci > 0 && mcich == 0) {\n");
fprintf(stdout, " var aci = -1;\n");
fprintf(stdout, " while (++aci < allow.length)\n");
fprintf(stdout, " { if (allow[aci] == charval) { break; } }\n");
fprintf(stdout, " if (aci == allow.length) {\n");
fprintf(stdout, " while (--mci >= 0) {\n");
fprintf(stdout, " if (match[mci].charAt(1) == '?')\n");
fprintf(stdout, " { watch[mci] = false; }\n");
fprintf(stdout, " else { watch[mci] = ''; }\n");
fprintf(stdout, " } mci++;\n");
fprintf(stdout, " charcount = 0;\n");
fprintf(stdout, " } else { watch[mci - 1] += charval; }\n");
fprintf(stdout, " } else { mcich = 0; }\n");
fprintf(stdout, " if (mci > 0)\n");
fprintf(stdout, " { charcount++; }\n");
fprintf(stdout, " }\n");
fprintf(stdout, " watch[8] = -300;\n");
fprintf(stdout, " return watch;\n");
fprintf(stdout, " }\n");
fprintf(stdout, " function messtimecurrenttime(messtime) {\n");
fprintf(stdout, " var outtime = messtime[0];\n");
fprintf(stdout, " outtime += ':' + messtime[1];");
fprintf(stdout, " outtime += (messtime[2] !== false) ? ':' + messtime[2] : '';\n");
fprintf(stdout, " outtime += (messtime[3] !== false) ? '.' + messtime[3] : '';\n");
fprintf(stdout, " return outtime;\n");
fprintf(stdout, " }\n");
fprintf(stdout, " function messtimetotaltime(messtime) {\n");
fprintf(stdout, " var outtime = messtime[4];\n");
fprintf(stdout, " outtime += ':' + messtime[5];");
fprintf(stdout, " outtime += (messtime[6] !== false) ? ':' + messtime[6] : '';\n");
fprintf(stdout, " outtime += (messtime[7] !== false) ? '.' + messtime[7] : '';\n");
fprintf(stdout, " return outtime;\n");
fprintf(stdout, " }\n");
// fprintf(stdout, " function messlinetimecode(message) {\n");
fprintf(stdout, " function messlinetrytimecue(message) {\n");
fprintf(stdout, " var terms = message.split(' ');\n");
fprintf(stdout, " if (terms.length > 1 && terms[1].charAt(0) == '@') {\n");
fprintf(stdout, " var libox = ionamebreak(terms[1]);\n");
fprintf(stdout, " var inbex = libox[1];\n");
fprintf(stdout, " var linum = ionamebreak(libox[2]);\n");
fprintf(stdout, " var linenum = linum[1];\n");
fprintf(stdout, " var linel = $$('in' + inbex + 'ln' + linenum);\n");
fprintf(stdout, " if (terms[0] == 'CUE') {\n");
fprintf(stdout, " if (!linel) {\n");
fprintf(stdout, " console.log('time cue line mismatch');\n");
fprintf(stdout, " } else {\n");
fprintf(stdout, " seekinbox = inbex;\n");
fprintf(stdout, " seektarget = inbex;\n");
fprintf(stdout, " seeklinum = linenum;\n");
fprintf(stdout, " var twatch = messlinetimecue(linel, 't');\n");
fprintf(stdout, " var tcurnt = messtimecurrenttime(twatch);\n");
fprintf(stdout, " var ttotal = messtimetotaltime(twatch);\n");
fprintf(stdout, " if (terms.length > 2) {\n");
fprintf(stdout, " var hashrs = (twatch[6] !== false);\n");
fprintf(stdout, " var hassub = (twatch[7] !== false);\n");
fprintf(stdout, " if (terms.length > 3) {\n");
fprintf(stdout, " ttotal = messsecondtime(terms[3], -1, hassub);\n");
fprintf(stdout, " }\n"); // CUE @line curtime [totaltime]
fprintf(stdout, " if (terms[2] == '|') {\n");
fprintf(stdout, " tvalue = '<:/' + ttotal + '>';\n");
fprintf(stdout, " messlinekeys(twatch[9], twatch[8], tvalue, 'clr0');\n");
fprintf(stdout, " seekstepper();\n");
fprintf(stdout, " } else {\n");
fprintf(stdout, " tcurnt = messsecondtime(terms[2], hashrs, hassub);\n");
fprintf(stdout, " tvalue = '<' + tcurnt + '/' + '>';\n");
fprintf(stdout, " messlinekeys(twatch[9], twatch[8], tvalue, 'clr1');\n");
fprintf(stdout, " tvalue = ttotal + '>';\n");
fprintf(stdout, " messlinekeys(twatch[9], 1, tvalue, 'clr0');\n");
fprintf(stdout, " seekspinner('s');\n");
fprintf(stdout, " }\n");
//fprintf(stdout, "console.log('tvalue=' + tvalue);\n");
// fprintf(stdout, " var trigline = messlinetrigger(terms[2]);\n");
// fprintf(stdout, " if (trigline) {\n");
// fprintf(stdout, " var trigch = messlinechars('<[:]>');\n");
fprintf(stdout, " }\n");
fprintf(stdout, " }\n");
// fprintf(stdout, " } else if (terms[0] == 'FIN') {\n");
// fprintf(stdout, " var linech = messlinechars('<:/:>');\n");
// read status marker - |, =, /, \, # - stop, repeat, next, prev, random
fprintf(stdout, " }\n");
fprintf(stdout, " }\n");
fprintf(stdout, " }\n");
// fprintf(stdout, " function messtrytimecue() {\n");
// fprintf(stdout, " \n");
// fprintf(stdout, " \n");
// fprintf(stdout, " \n");
// fprintf(stdout, " }\n");
// linenum from substr(4) == @
// search for <, count *s, eat 0: until / check time against message time
// <***1:12:34/2:00:00(?)>
// <****(end tally)> <[1:24.42(time trigger)]> <1:13/2:32(time seek)>
// remembering playlists ... </> </> <-> <(14)> <\> .. na
fprintf(stdout, " var mess = { enabled: false };\n");
fprintf(stdout, " function messhandle(evt) {\n");
// fprintf(stdout, " if (event.origin != event.origin) {\n");
// fprintf(stdout, " evt.stopPropagation();\n");
// fprintf(stdout, " evt.preventDefault();\n");
fprintf(stdout, " srcwindow = evt.source;\n");
fprintf(stdout, " srcdata = evt.data;\n");
fprintf(stdout, " srcorigin = evt.origin;\n");
fprintf(stdout, " if (srcdata.substr(0, 4) == 'CUE ') {\n");
fprintf(stdout, " messlinetrytimecue(srcdata);\n");
// fprintf(stdout, " var cuetime = srcdata.substr(1);\n");
// fprintf(stdout, " console.log(srcdata);\n");
// fprintf(stdout, " } else if (srcdata.substr(0, 4) == 'FIN ') {\n");
// fprintf(stdout, " var fintime = srcdata.substr(1);\n");
// fprintf(stdout, " console.log(fintime);\n");
fprintf(stdout, " } else if (srcdata.substr(0, 4) == 'KEY ') {\n");
fprintf(stdout, " var keycode = srcdata.substr(4);\n");
fprintf(stdout, " var pce = { keyCode: 0, shiftKey: false\n");
fprintf(stdout, " , altKey: false, ctrlKey: false\n");
fprintf(stdout, " , preventDefault: false }\n");
fprintf(stdout, " if (keycode.charAt(0) == '+') {\n");
fprintf(stdout, " pce.shiftKey = true;\n");
fprintf(stdout, " keycode = keycode.substr(1);\n");
fprintf(stdout, " }\n");
fprintf(stdout, " if (keycode.charAt(0) == '-') {\n");
fprintf(stdout, " pce.ctrlKey = true;\n");
fprintf(stdout, " keycode = keycode.substr(1);\n");
fprintf(stdout, " }\n");
fprintf(stdout, " if (keycode.charAt(0) == '=') {\n");
fprintf(stdout, " pce.altKey = true;\n");
fprintf(stdout, " keycode = keycode.substr(1);\n");
fprintf(stdout, " }\n");
fprintf(stdout, " var pcc = parseInt(keycode);\n");
fprintf(stdout, " if (pcc > 0) {\n");
fprintf(stdout, " pce.keyCode = pcc;\n");
fprintf(stdout, " window.onkeydown(pce);\n");
fprintf(stdout, " }\n");
fprintf(stdout, " }\n");
fprintf(stdout, " }\n");
fprintf(stdout, " function messenable() {\n");
// fprintf(stdout, " if ('onmessage' in document.documentElement) {\n");
// fprintf(stdout, " document.addEventListener('message', messhandle, false);\n");
fprintf(stdout, " window.onmessage = function(evt) { messhandle(evt); };\n");
fprintf(stdout, " mess.enabled = true;\n");
// fprintf(stdout, " }\n");
// fprintf(stdout, " alert('messon');\n");
fprintf(stdout, " }\n");
fprintf(stdout, " function messlinerangetest() {\n");
fprintf(stdout, " \n");
// doing this live requires posting a message back
// inevitable latency -- need to be able to submit changes as they happen
// should set initial values from opening line and fix this later
// fprintf(stdout, " var twatch = messlinetimecue(linel, 'r');\n");
// fprintf(stdout, " var tcurnt = messtimecurrenttime(twatch);\n");
// fprintf(stdout, " var ttotal = messtimetotaltime(twatch);\n");
fprintf(stdout, " }\n");