-
Notifications
You must be signed in to change notification settings - Fork 1
/
audience.html
422 lines (347 loc) · 10 KB
/
audience.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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
<!doctype html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>聽眾</title>
<meta name="description" content="HTML5 Presentation" />
<meta name="author" content="1KM" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<link rel="shortcut icon" href="./images/favicon.ico">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- Reveal CSS -->
<link rel="stylesheet" href="css/reveal.min.css" />
<link rel="stylesheet" href="css/theme/night.css" id="theme" />
<!-- Slidebars CSS -->
<link rel="stylesheet" href="css/slidebars/slidebars.css">
<!-- jQuery TE CSS -->
<link type="text/css" rel="stylesheet" href="css/jquery-te-1.4.0.css">
<!-- Sliderbars and TE style CSS -->
<link rel="stylesheet" href="css/slidebars/style.css">
<!-- For syntax highlighting -->
<link rel="stylesheet" href="lib/css/zenburn.css" />
<!-- If the query includes 'print-pdf', include the PDF print sheet -->
<script>
if( window.location.search.match( /print-pdf/gi ) ) {
var link = document.createElement( 'link' );
link.rel = 'stylesheet';
link.type = 'text/css';
link.href = 'css/print/pdf.css';
document.getElementsByTagName( 'head' )[0].appendChild( link );
}
</script>
<!--[if lt IE 9]>
<script src="lib/js/html5shiv.js"></script>
<![endif]-->
<style type="text/css">
#mouse {
position: absolute;
color: #FFF;
z-index: 99999;
}
.mouse_animation {
position: absolute;
top: -25px;
left: -25px;
width: 50px;
height: 50px;
border-radius: 100px;
border: 3px solid #F00;
-webkit-animation: clickEffect 0.75s;
-webkit-animation-timing-function: ease-in;
animation: clickEffect 0.75s;
animation-timing-function: ease-in;
z-index: 99999;
}
@-webkit-keyframes clickEffect {
from {
-webkit-transform: scale(0.2);
opacity: 1;
}
to {
-webkit-transform: scale(1.2);
opacity: 0;
}
}
@keyframes clickEffect {
from {
transform: scale(0.2);
opacity: 1;
}
to {
transform: scale(1.2);
opacity: 0;
}
}
</style>
<!-- QA_field -->
<link rel="stylesheet" type="text/css" href="css/QA_styles.css" />
<link rel="stylesheet" href="css/alertify.core.css" />
<link rel="stylesheet" href="css/alertify.default.css" />
<!-------------->
</head>
<body>
<div class="sb-toggle-right">
<div class="navicon-line"></div>
<div class="navicon-line"></div>
<div class="navicon-line"></div>
</div>
<div class="sb-slidebar sb-right sb-style-overlay sb-width-custom" data-sb-width="20%">
<textarea id="note" class="jqte"></textarea>
<!-- QA_field -->
<div id="QA_field" class="QA_field" style="position:absolute;bottom:20px;right:10px">
<p class="openTop openLeft blue" style="bottom:0px;right:0px;"></p>
</div>
<!-------------->
<audio id="radio" preload="none">
<source src="http://127.0.0.1:5566/" type="audio/mpeg">
Your browser does not support the audio element.
</audio>
</div>
<div id="sb-site" class="reveal">
</div>
<!-- jQuery -->
<script src="js/jquery-1.11.1.min.js" type="text/javascript"></script>
<!-- Reveal -->
<script src="lib/js/head.min.js"></script>
<script src="js/reveal.min.js"></script>
<!-- Slidebars -->
<script src="js/slidebars.min.js"></script>
<!-- jQuery TE -->
<script src="js/jquery-te-1.4.0.js" type="text/javascript" charset="utf-8"></script>
<!-- New Style Alert -->
<script src="js/alertify.js" type="text/javascript"></script>
<!-- socket.io -->
<script src="js/socket.io-1.0.6.min.js" type="text/javascript"></script>
<script src="js/QA_script.js" type="text/javascript"></script>
<script>
var delayInMS = 0;
var timeouts = [];
var vibrateTimer = null;
/**
* setupNote
*/
function setupNote() {
// Save note value on change
var changeId;
var note = $('#note');
var noteEditor = note.parent().prev();
noteEditor.html(localStorage.note);
noteEditor.bind('change keyup paste', function() {
clearTimeout(changeId);
changeId = setTimeout(function() {
console.log(note.val());
localStorage.note = note.val();
}, 100);
});
}
/**
* setupRadio
*/
function setupRadio() {
// 自動撥放聲音串流
var radio = $("#radio").get(0);
radio.play();
delayInMS = Date.now();
radio.addEventListener("canplay", function() {
console.log("canplay");
delayInMS = Date.now() - delayInMS;
});
/*
radio.addEventListener("timeupdate", function() {
console.log({"delay": delayInMS, "currentTime": radio.currentTime});
});
*/
}
/**
* 滑鼠點擊事件
*/
function mouseClicked(mousePos) {
var x = mousePos.x * $(window).width();
var y = mousePos.y * $(window).height();
$('#mouse').hide();
var element = document.elementFromPoint(x, y);
$('#mouse').show();
if ($(element).get(0).tagName == 'VIDEO') {
var v = $(element).get(0);
v.paused ? v.play() : v.pause();
} else if ($(element).is("[clickable]")) {
$(element).click();
}
// 滑鼠點擊動畫
var clickCircle = $("<div class='mouse_animation' style='left:" + (x-25) + "px; top:" + (y-25) + "px'></div>");
$("body").append(clickCircle);
setTimeout(function() { clickCircle.remove() }, 700);
}
/**
* 震動事件
*/
function vibrated(isOpen) {
if (isOpen) {
if (window.navigator && window.navigator.vibrate) {
vibrateTimer = setInterval(function() {
var a = Math.round(Math.random() * 500);
navigator.vibrate([a, 500-a]);
}, 500);
}
} else {
clearInterval(vibrateTimer);
navigator.vibrate(0);
vibrateTimer = null;
}
}
$(document).ready(function() {
// Initialize sliderbars
var mySlidebars = new $.slidebars();
// Initialize jQery TE
$('.jqte').jqte({"source": false});
// Initialize Note
setupNote();
});
$('.reveal').load('slides.html', function() {
var socket = io('http://127.0.0.1:8080/');
Reveal.addEventListener('ready', function( event ) {
Reveal.configure({
controls: false,
keyboard: false,
touch: false
});
});
socket.on('connect', function () {
socket.send('audience_connect');
// message事件
socket.on('message', function (msg) {
console.log(msg);
});
// audience_chs事件
socket.on('audience_chs', function(e) {
if (delayInMS == 0) {
Reveal.slide(e.indexh, e.indexv, e.indexf);
} else {
timeouts.push( setTimeout(function() {
Reveal.slide(e.indexh, e.indexv, e.indexf);
}, delayInMS) );
}
});
// Mousemove事件
socket.on('mousemove', function(mousePos) {
if (delayInMS == 0) {
$("#mouse").css({top: mousePos.y + '%', left: mousePos.x + '%'});
} else {
timeouts.push( setTimeout(function() {
$("#mouse").css({top: mousePos.y + '%', left: mousePos.x + '%'});
}, delayInMS) );
}
});
// Mouseclick事件
socket.on('click', function (mousePos) {
if (delayInMS == 0) {
mouseClicked(mousePos);
} else {
timeouts.push( setTimeout(mouseClicked, delayInMS, mousePos) );
}
});
// 問問題
$("#QA_field").on("click", "#ask_submit", function() {
if (delayInMS == 0) {
socket.emit('QA_ask', $('#QA_content').val());
} else {
timeouts.push( setTimeout(function() {
socket.emit('QA_ask', $('#QA_content').val());
}, delayInMS) );
}
});
// Ask_msg
socket.on('Ask_msg', function(questions) {
if (delayInMS == 0) {
alertify.success(questions);
} else {
timeouts.push( setTimeout(function() {
alertify.success(questions);
}, delayInMS) );
}
});
// start_radio
socket.on('start_radio', function() {
console.log('start_radio');
timeouts = [];
setupRadio();
});
// stop_radio
socket.on('stop_radio', function() {
console.log('stop_radio');
delayInMS = 0;
for (var i = 0; i < timeouts.length; i++) {
clearTimeout(timeouts[i]);
}
timeouts = [];
});
// modify_slides事件
socket.on('modify_slides', function(html) {
if (delayInMS == 0) {
$("#slides").html(html);
} else {
timeouts.push( setTimeout(function() {
$("#slides").html(html);
}, delayInMS) );
}
});
// 震動事件
socket.on('vibrate', function(isOpen) {
if (delayInMS == 0) {
vibrated(isOpen);
} else {
timeouts.push( setTimeout(vibrated, delayInMS, isOpen) );
}
});
// Initialize canvas
socket.on('init_canvas', function(canvas) {
if (delayInMS == 0) {
var $canvas = $(canvas);
if( $(Reveal.getCurrentSlide()).children('.canvas').length == 0 ) {
$canvas.prependTo( Reveal.getCurrentSlide() );
$canvas.css('z-index', '-1');
}
} else {
timeouts.push( setTimeout(function(canvas) {
var $canvas = $(canvas);
if( $(Reveal.getCurrentSlide()).children('.canvas').length == 0 ) {
$canvas.prependTo( Reveal.getCurrentSlide() );
$canvas.css('z-index', '-1');
}
}, delayInMS, canvas) );
}
});
//Add path
socket.on('add_path', function(fhpath) {
if (delayInMS == 0) {
var $canvas = $(Reveal.getCurrentSlide()).children('.canvas');
$canvas.children('svg').append(fhpath);
$canvas.html($canvas.html());
} else {
timeouts.push( setTimeout(function(fhpath) {
var $canvas = $(Reveal.getCurrentSlide()).children('.canvas');
$canvas.children('svg').append(fhpath);
$canvas.html($canvas.html());
}, delayInMS, fhpath) );
}
});
//Remove path
socket.on('remove_path', function(fhpathId) {
if (delayInMS == 0) {
$('#' + fhpathId).remove();
} else {
timeouts.push( setTimeout(function() {
$('#' + fhpathId).remove();
}, delayInMS) );
}
});
});
});
</script>
<div id="mouse" style="left: 50%; top: 50%;"><img src="images/mouse-pointer.png"></div>
</body>
</html>