-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
155 lines (148 loc) · 4.97 KB
/
index.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
<!DOCTYPE>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" value="width=device-width, initial-scale=1, maximum-scale=1" />
<script type="text/javascript" src="jquery-2.1.1.min.js" ></script>
<style type="text/css">
body{
font-family: "Comic Sans MS", "Marker Felt", cursive, serif;
}
@media (min-width: 480px) {
.column {
float: left;
width: 30%;
}
}
</style>
</head>
<body>
<h1>What's Happening at #MozFest Right Now?</h1>
<a href="#" id="rerender">what about now? (refresh)</a>
<br><br>
<a href="http://schedule.mozillafestival.org/">official schedule</a>
<p style="font-size: small;">Wanna make this better? Send us a <a href="https://github.com/jeremybmerrill/mozfestnow">Pull Request</a> </p>
<hr />
<p><a href="#" id="toggle_descr" style="display:none">Toggle Descriptions/Facilitators</a></p>
<div class="column">
<h2>Previously</h2>
<ul id="previously">
<li>(Your internet is slow, but the schedule is loading... Bear with me here. We'll store it locally for next time.)</li>
</ul>
</div>
<div class="column">
<h2>Coming up</h2>
<ul id="now">
<li>(Your internet is slow, but the schedule is loading... Bear with me here. We'll store it locally for next time.)</li>
</ul>
</div>
<div class="column">
<h2>After that</h2>
<ul id="next">
<li>(Your internet is slow, but the schedule is loading... Bear with me here. We'll store it locally for next time.)</li>
</ul>
</div>
<script type="text/javascript">
var url = "http://schedule.mozillafestival.org/api/sessions";
// if(window.location.href.indexOf("localhost") > -1)
// url = "sked.json";
window.lookbehindMinutes = 10;
window.lookaheadMinutes = 20;
window.lsKey = 'mozfestSked';
window.render = function(){
$.each([ 'now', 'next','previously' ], function( index, timeframe ) {
if (timeframe === 'previously') {
window.lookbehindMinutes = 70;
window.lookaheadMinutes = -10;
};
if (timeframe === 'now') {
window.lookbehindMinutes = 10;
window.lookaheadMinutes = 20;
}
if (timeframe === 'next') {
window.lookbehindMinutes = -20;
window.lookaheadMinutes = 80;
}
$('ul#' + timeframe).empty();
var now = +new Date();
window.data.sort(function(sesh_a, sesh_b) {
var a = sesh_a.location.toLowerCase();
var b = sesh_b.location.toLowerCase();
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
});
for(i=0; i<window.data.length; i++){
var sesh = window.data[i];
sesh.startp = Date.parse(sesh.start)
sesh.endp = Date.parse(sesh.end)
if(sesh.startp > (now - (window.lookbehindMinutes * 60 * 1000)) && // if it started < 10 minutes ago
sesh.startp < (now + (window.lookaheadMinutes * 60 * 1000)) && // and if it starts in < 20 minutes from now
sesh.endp > now // and hsan't ended yet
){
console.log(sesh);
var html = '<li>'
html += '<strong>' + sesh.title + '</strong> '
html += '— <span class="theme">' + sesh.theme + '</span> '
html += '<br /><span class="details" style="text-align: left;">'
html += '<span class="time">' + sesh.start.toString().slice(11, 16) +" - " + sesh.end.slice(11, 16) + '</span><br>'
html += 'Location: <em>' + sesh.location + '</em>'
html += ' <a href="http://schedule.mozillafestival.org/#session/' + sesh.id + '">(link)</a>'
html += '</span>'
html += '<div class="facilitators" style="display:none">Facilitators: '
if (!!sesh.facilitators) {
for(j=0; j<sesh.facilitators.length; j++){
html += sesh.facilitators[j].name
if (j < sesh.facilitators.length-1) {
html += ", "
}
}
}
html += '</div>'
html += '<div class="description" style="display:none">Description: ' + sesh.description + '</div>'
html += '</li>'
$('ul#' + timeframe).append(html)
}
}
});
$("#toggle_descr").show();
}
window.data = null;
window.getSked = function(){
$.ajax({
dataType: "jsonp",
jsonpCalback: "jsonp",
url: url,
success: function(data){
window.data = data;
if (localStorage){
localStorage.setItem(window.lsKey, JSON.stringify(data));
console.log('wrote to localstorage')
}
window.render();
}
});
}
$('#rerender').on('click', function(){ window.render(); window.getSked(); });
$(function(){
// if(! localStorage.)
if (localStorage){
if(localStorage.getItem(window.lsKey)){
console.log('got from localstorage')
window.data = JSON.parse(localStorage.getItem(window.lsKey));
window.render();
window.getSked();
}else{
console.log('not in localstorage')
window.getSked();
}
}else{
window.getSked();
}
});
$("#toggle_descr").click(function() {
$(".column li .facilitators").slideToggle();
$(".column li .description").slideToggle();
return false;
});
</script>
</body>
</html>