forked from c3subtitles/L2S2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbeamer.js
More file actions
55 lines (45 loc) · 1.18 KB
/
beamer.js
File metadata and controls
55 lines (45 loc) · 1.18 KB
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
$(function() {
'use strict';
var socket = io(window.location.protocol+'//'+window.location.host);
$.fn.autoScale = function() {
if(!this.data('autoScaleOriginal')) {
this.data('autoScaleOriginal', parseInt(this.css('font-size')));
}
var maxSize = this.data('autoScaleOriginal');
var maxH = this.parent().innerHeight();
var thisH = this.css('font-size', maxSize).outerHeight();
while(thisH > maxH && maxSize > 0) {
thisH = this.css('font-size', --maxSize).outerHeight();
}
return this;
};
// join & rejoin
socket.on('connect', function() {
socket.emit('join', 'Saal 1');
});
// display a line
socket.on('line', function(stamp, line, duration) {
pushLine(stamp, line, duration);
});
// presentation specific
var hideTimeout;
function pushLine(stamp, line, duration) {
$('h1').animate({opacity: 0}, 200, function() {
var $el = $(this);
$el
.text(line)
.autoScale()
.animate({opacity: 1}, 200);
if(hideTimeout) {
clearTimeout(hideTimeout);
}
hideTimeout = setTimeout(function() {
$el.animate({opacity: 0}, 200);
clearTimeout(hideTimeout);
hideTimeout = null;
}, duration*1000);
});
}
});
/* vim: ts=4:sw=4:noet
*/