-
Notifications
You must be signed in to change notification settings - Fork 1
/
ctrl.html
288 lines (247 loc) · 8.39 KB
/
ctrl.html
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
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
<!DOCTYPE html>
<html>
<head>
<link href="lib/tabs.css" media="all" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="lib/coffee-script.js"></script>
<script type="text/coffeescript" src="app/isk.debug.js.coffee"></script>
<script type="text/coffeescript" src="app/isk.local_message_broker.js.coffee"></script>
<style type='text/css'>
@font-face{
font-family: 'CustomFont';
src: url('/fonts/Franklin_Gothic_Heavy-Regular.ttf');
}
</style>
<title>ISK-Display Local Controller</title>
</head>
<body>
<div id="DPYCTRL">
<div class="tabs" style="height: 650px">
<div id="tab1">
<a href="#tab1">Presentation</a>
<div id="presroot">
<h2>Display name: <span/></h1>
<h4>Presentation name: <span/></h1>
<h4>Overrides: <span/></h1>
<h4>Slides: <span/></h1>
<h4>Current: <span/></h1>
<script type="text/coffeescript">
isk?.local_broker?.register 'presentation_changed', (data) ->
fields= document.querySelectorAll('#presroot * span')
fields[0].innerHTML=data?.name
fields[1].innerHTML=data?.presentation?.name
fields[2].innerHTML=data?.override_queue?.length
fields[3].innerHTML=data?.presentation?.total_slides
</script>
</div>
</div>
<div id="tab2">
<a href="#tab2">Super Override</a>
<div>
<div style='display:inline-block'>
<textarea id="o_editor" style="resize: none; font: 12pt CustomFont;" cols=30 rows=16></textarea>
<br />
<button id="o_update">Update</button>
<button id="o_show">Show</button>
<button id="o_hide">Hide</button>
</div>
<img height=240 width=380 id="o_preview"></img>
<script type="text/coffeescript">
svgNS = "http://www.w3.org/2000/svg"
xmlNS = "http://www.w3.org/XML/1998/namespace"
edit=document.querySelector('#o_editor')
preview=document.querySelector('#o_preview')
preview.src='/backgrounds/empty.png'
img=document.createElement('img')
img.src='/backgrounds/empty.png'
canvas=document.createElement('canvas')
ctx=canvas.getContext('2d')
[canvas.width,canvas.height]=[1920,1080]
drawStroked = (args...) ->
ctx.textBaseline = 'top'
ctx.font = "100pt CustomFont"
ctx.fillStyle = '#FFF'
ctx.strokeStyle = '#000'
ctx.lineWidth = 4
ctx.miterLimit = 2
ctx.fillText(args...)
ctx.strokeText(args...)
drawMultilineText = (text, x, y, h) ->
lines=text.split /\r\n|\n|\r/
for line, index in lines
if line == ""
y+=30
else
drawStroked line, x, y
y+=120
set = (text) ->
ctx.drawImage img, 0, 0
drawMultilineText text, 40, 40
canvas.toBlob (blob)->
durl=URL.createObjectURL blob
preview.ready = ->
URL.revokeObjectURL durl
preview.src=durl
document.querySelector('#o_update').addEventListener 'click', ->
console.debug 'Update Super Override'
set edit.value
document.querySelector('#o_show').addEventListener 'click', ->
console.debug 'Show Super Override'
isk?.local_broker?.trigger 'show superoverride', preview.src
document.querySelector('#o_hide').addEventListener 'click', ->
console.debug 'Hide Super Override'
isk?.local_broker?.trigger 'hide superoverride'
</script>
</div>
</div>
<div id="tab_video">
<a href="#tab_video">Video player</a>
<div>
<div id=player>
<h1>Library</h1>
<select id=select multiple size=10>
<option value='videos/bunny.mp4'>bunny</option>
<option value='videos/sintel.mp4'>sintel</option>
<option value='videos/test.webm'>test</option>
</select>
<br/>
<input type="file" accept="video/*"/>
<br/>
</div>
<h1>Queue</h1>
<table>
<thead>
<tr>
<th style="min-width:10em">name</th>
<th style="min-width:20em">
buffer<br/>
progress
</th>
<th>state</th>
</tr>
</thead>
<template id="queue_line">
<tr class="line">
<td class="name">Test name</td>
<td align=center>
<progress class="buffer" max="1"></progress><br/>
<progress class="position" max="1"></progress><br/>
<span class=ctime>###</span> (-<span class=ltime>###</span>) / <span class=time>###</span>
</td>
<td class="state"></td>
</tr>
</template>
<tbody id="queue"></tbody>
</table>
</div>
<script type="text/coffeescript">
player=document.querySelector '#player'
input=document.querySelector '#player input'
selector=document.querySelector '#player select#select'
time=document.querySelectorAll '#player #time *'
buffer=document.querySelectorAll '#player #buffer *'
queue=document.querySelector 'table #queue'
template=document.querySelector 'template#queue_line'
add_line_to_queue = (id, name) ->
l=document.importNode template.content, true
l.querySelector '.name'
.textContent=name
l.querySelectorAll 'span'
.textContent=""
l.children[0].id=id
queue.appendChild l
undefined
isk?.local_broker?.register 'video canplaythrough', (id) ->
queue.querySelector("##{id} .state").classList.add 'canplaythrough'
isk?.local_broker?.register 'video ended', (id) ->
queue.querySelector("##{id}").remove()
setTimeout play_next, 3000
isk?.local_broker?.register 'video timeupdate', (id, ctime, dur) ->
if dur
left=dur-ctime
if ctime > 0.01
queue.querySelector("##{id} .state").classList.add 'playing'
if left < 0.01
queue.querySelector("##{id} .state").classList.add 'ended'
queue.querySelector("##{id} .ctime").textContent=ctime.toFixed(1)
queue.querySelector("##{id} .time").textContent=dur.toFixed(1)
queue.querySelector("##{id} .ltime").textContent=left.toFixed(1)
queue.querySelector("##{id} .position").value=ctime/dur
isk?.local_broker?.register 'video progress', (id, ctime, dur) ->
if dur
left=dur-ctime
if left<=0.01
queue.querySelector("##{id} .state").classList.add 'finished'
queue.querySelector("##{id} .buffer").value=ctime/dur
input.addEventListener 'change', ->
file=input.files[0]
if file
furl=URL.createObjectURL file
o=document.createElement 'option'
o.value=furl
o.innerHTML=file.name
selector.appendChild o
button=(name, click) ->
e=document.createElement 'button'
e.innerHTML=name
e.onclick=click
player.appendChild e
e
play_next= ->
selected=document.querySelector '#queue .line'
if selected?
isk?.local_broker?.trigger 'video play', selected.id
else
isk?.local_broker?.trigger 'hide superoverride'
play= ->
isk?.local_broker?.trigger 'show superoverride', 'poster.png'
setTimeout play_next, 5000
@b=
maxid: 0
queue: button 'queue', ->
selected=document.querySelectorAll '#select option:checked'
id="vid" + b.maxid++
add_line_to_queue id, selected[0].textContent
isk?.local_broker?.trigger 'video prepare', id, selected[0].value
play: button 'play queued', play
pause: button 'toggle pause', ->
isk?.local_broker?.trigger 'video pause'
</script>
</div>
<div id="tab3">
<a href="#tab3">Shader editor</a>
<div>
<textarea id='s_code' rows=40 cols=80></textarea>
<br/>
<select id='s_name'>
</select>
<select id='s_type'>
<option>fs</option>
<option>vs</option>
</select>
<button id='s_load'>Load</button>
<button id='s_apply'>Apply</button>
<script type="text/coffeescript">
shaders=undefined
sname=document.querySelector('#s_name')
stype=document.querySelector('#s_type')
scode=document.querySelector('#s_code')
isk?.local_broker?.register 'return shaders', (data) ->
shaders=data
sname.innerHTML=""
for name, value of shaders
o=document.createElement('option')
o.innerHTML=name
sname.appendChild(o)
document.querySelector('#s_load').addEventListener 'click', ->
scode.value = shaders[sname.value][stype.value]
document.querySelector('#s_apply').addEventListener 'click', ->
shaders[sname.value][stype.value] = scode.value
isk?.local_broker?.trigger 'set shaders', shaders
isk?.local_broker?.trigger 'get shaders'
</script>
</div>
</div>
</div>
</div>
</body>
</html>