forked from jeremybmerrill/mozfestnow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
178 lines (172 loc) · 5.76 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
<!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;
}
ul {
list-style-type: none;
padding-left: 0;
}
.note {
font-style: italic;
}
a.sesh-title {
color : brown;
text-decoration: none;
}
li {
color: #334971;
}
@media (min-width: 480px) {
.column {
float: left;
width: 30%;
padding: 1%;
border-right:solid 1px black;
}
.next {
border: none;
}
}
</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>Already started</h2>
<p class="note">Sessions started more than 10 mins ago</p>
<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>
<p class="note">Sessions starting in the next 20 minutes, or started less than 10 mins ago</p>
<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 next">
<h2>After that</h2>
<p class="note">Sessions starting between 20 and 80 minutes from now
<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 ) {
// events which started between ten hours ago and ten minutes ago
if (timeframe === 'previously') {
window.lookbehindMinutes = 600;
window.lookaheadMinutes = -10;
};
// events which started up to 10 minutes ago, or are starting in the next 20 minutes
if (timeframe === 'now') {
window.lookbehindMinutes = 10;
window.lookaheadMinutes = 20;
}
// events which are at least 20 but less than 80 minutes away
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 < lookbehindMinutes minutes ago
sesh.startp < (now + (window.lookaheadMinutes * 60 * 1000)) && // and if it starts in < lookaheadMinutes minutes from now
sesh.endp > now // and hsan't ended yet
){
console.log(sesh);
var html = '<li>'
html += '<strong><a class="sesh-title" href="http://schedule.mozillafestival.org/#session/' + sesh.id + '">' + sesh.title + '</a></strong> '
html += '— <span class="theme">' + sesh.theme + '</span> '
html += '<span class="details" style="text-align: left;">'
html += '<span class="time"> ' + sesh.start.toString().slice(11, 16) +" - " + sesh.end.slice(11, 16) + '</span>'
html += ' @ <em>' + sesh.location + '</em>'
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>