-
Notifications
You must be signed in to change notification settings - Fork 4
/
broadcast.html
50 lines (46 loc) · 1.65 KB
/
broadcast.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
---
layout: default
title: Broadcast
description: Broadcasting Hackatron's meetings
---
<div id="broadcast">
<h2>Meeting broadcast</h2>
<p>
Next broadcast is scheduled for <span id="next_broadcast"></span> and will start in <br/><span id="timer"></span>.
</p>
</div>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script src="/javascripts/moment.min.js"></script>
<script>
function plural(singular, n) {
return singular + (n > 1 || n <= 0 ? 's' : '');
}
$(document).ready(function() {
$.ajax({
type: 'GET',
dataType: 'jsonp',
cache: false,
url: 'http://hackatron-hubot.herokuapp.com/hubot/topic/hackatron',
success: function(topic) {
timeString = topic.replace(/[^\:]+\: /, '').replace(/ @.+/, '');
$('#next_broadcast').html(timeString);
time = moment(timeString + '+0200', 'dddd, MMMM DD.., hh:mm A ZZ');
time.year(new Date().getFullYear());
timerId = setInterval(function(target) {
delta = Math.floor(target.unix() - (new Date().getTime() / 1000));
seconds = delta % 60;
delta = Math.floor(delta / 60);
minutes = delta % 60;
delta = Math.floor(delta / 60);
hours = delta % 24;
days = Math.floor(delta / 24);
timerString = days + ' ' + plural('day', days) + ', ' +
hours + ' ' + plural('hour', hours) + ', ' +
minutes + ' ' + plural('minute', minutes) + ', ' +
seconds + ' ' + plural('second', seconds);
$('#timer').html(timerString);
}, 300, time);
}
});
});
</script>