-
Notifications
You must be signed in to change notification settings - Fork 2
/
programm.html
347 lines (285 loc) · 8.69 KB
/
programm.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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link href="css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<style type="text/css">
li:hover{cursor:pointer;}
.list-group-item:hover{background-color:#f5f5f5;}
</style>
<script type="text/javascript">
var KEY = '1NY3YC1AWC8xotzD2X0dMZuBSGS5ErjEtkYboGwKuZWc';
var WORKSHEETS = 'https://spreadsheets.google.com/feeds/worksheets/' + KEY + '/public/basic?alt=json';
var TITLE_VERSIONS = 'Versioning';
var tracks = new Array();
var num_tracks = -1, loaded_tracks = 0;
function append(nodename, innerhtml, parent) {
var e = document.createElement(nodename);
if (innerhtml)
e.innerHTML = innerhtml;
if (!parent)
parent = document.getElementById('container');
return parent.appendChild(e);
}
function toggle(parent) {
var i, n;
for (i = 0; i < parent.childNodes.length && !n; i++)
if ('P' == parent.childNodes[i].nodeName) {
n = parent.childNodes[i];
n.style.display = ('none' == n.style.display ? 'block' : 'none');
}
}
function status(str) {
var s = document.getElementById('status');
if (str)
s.innerHTML = str;
return s;
}
function errmsg(msg) {
m = "Sorry, that didn't work. :\\ Please try reloading the page.";
m += '<hr/>';
m += '<span class="label label-danger">Error</span> ' + msg;
status(m).setAttribute('class', 'alert alert-danger');
return false;
}
function httpreq() {
var noreq = 'Local error: XMLHTTP not available.';
if (typeof(window.XMLHttpRequest) != 'undefined') {
try {
return new XMLHttpRequest();
} catch(e) {
return errmsg(noreq);
}
}
if (window.ActiveXObject) {
try {
return new ActiveXObject("Msxml2.XMLHTTP");
} catch(f) {
try {
return new ActiveXObject("Microsoft.XMLHTTP");
} catch(g) {
return errmsg(noreq);
}
}
}
return errmsg(noreq);
}
function httpget(url, func, wait) {
var req = httpreq();
if (!req)
return false;
req.onreadystatechange = function() {
if (req.readyState !== 4)
return;
if (req.status == 200)
func(req, url);
else
errmsg('XHR ' + req.status + ' ' + req.statusText + ' ');
}
req.open('GET', url, !wait);
req.send('');
return true;
}
function rowcol(entry) {
var rc = /^R([0-9]*)C([0-9]+)$/;
var a1 = /^([A-Z]+)([0-9]+)$/;
var ret = new Object;
var mat = rc.exec(entry.title.$t);
if (mat) {
ret.row = parseInt(mat[1]);
ret.col = parseInt(mat[2]);
} else {
mat = a1.exec(entry.title.$t);
if (!mat)
return mat;
ret.row = parseInt(mat[2]);
ret.col = mat[1];
}
return ret;
}
function feed_json(req, name) {
var resp = req.responseText;
if (!resp)
return errmsg('No data available for ' + name + ' feed.');
try {
var ws = JSON.parse(resp + '');
} catch(e) {
return errmsg('Can not parse ' + name + ' feed response.<br/>' + e);
}
if (!ws.feed)
return errmsg('No ' + name + ' feed received.');
ws.feed.linkhref = function(entry, anchor) {
for (var i = 0; i < this.entry[entry].link.length; i++)
if ('http://schemas.google.com/spreadsheets/2006#' + anchor == this.entry[entry].link[i].rel)
return this.entry[entry].link[i].href + '?alt=json';
return false;
}
ws.feed.make_table = function() {
var i, lastrc, rc, r;
this.rows = new Array;
this.cols = new Object;
this.cell = function(row, col, debug) {
var c = this.cols[col] ? this.cols[col] : col;
if (this.rows[row].c[c])
return this.entry[this.rows[row].c[c]].content.$t.trim();
return '';
}
for (i = 0; rowcol(this.entry[i]).row == 1; i++)
this.cols[this.entry[i].content.$t] = rowcol(this.entry[i]).col;
for (lastrc = rowcol(this.entry[i - 1]); i < this.entry.length; i++) {
rc = rowcol(this.entry[i]);
if (rc.row != lastrc.row) {
if (r)
this.rows.push(r);
r = new Object;
r.c = new Object;
}
r.c[rc.col] = i;
lastrc = rc;
}
if (r)
this.rows.push(r);
return this;
}
return ws.feed;
}
function track_done(ret) {
if (num_tracks == -1)
return ret;
++loaded_tracks;
var loaded = loaded_tracks.toString();
var tracks = ' track' + (1 == num_tracks ? '' : 's') + '.';
if (loaded_tracks < num_tracks) {
loaded += ' of ' + num_tracks;
tracks += '..'
}
var s = status();
if (s.getAttribute('class') != 'alert alert-danger') {
status('Loaded ' + loaded + tracks);
if (loaded_tracks == num_tracks) {
s.setAttribute('class', 'alert alert-success');
setTimeout("status('').setAttribute('style', 'display:none')", 500);
}
}
return ret;
}
function get_track(name, cellsfeed, pos) {
httpget(cellsfeed, function(req) {
var i;
var time, title, abstract, gn, fn, speaker, org;
var html, li, p;
var t = feed_json(req, name).make_table();
if (!t)
return track_done(t);
for (i = 0; i < t.rows.length; i++) {
time = t.cell(i, 'Time');
title = t.cell(i, 'Session Topic');
abstract = t.cell(i, 'Abstract of talk or project');
gn = t.cell(i, 'Given Name');
fn = t.cell(i, 'Family Name');
if (gn && fn)
speaker = gn + ' ' + fn;
else if (gn)
speaker = gn;
else if (fn)
speaker = fn;
else
speaker = '';
org = t.cell(i, 'Organization');
if (title == speaker)
speaker = '';
if (title == org)
org = '';
if (speaker == org)
org = '';
html = '<div class="row">';
html += '<div class="col-xs-1"><span class="label label-primary">' + time + '</span></div>';
html += '<div class="col-xs-11">' + title;
if (speaker || org) {
html += ' - ';
if (speaker) {
html += speaker;
if (org)
html += ', ';
}
if (org)
html += org;
}
html += '</div>';
li = append('li', html, tracks[pos]);
li.setAttribute('class', 'list-group-item');
li.setAttribute('onclick', 'toggle(this)');
p = append('p', abstract, li);
p.setAttribute('class', 'list-group-item-text');
p.setAttribute('style', 'display:none');
}
return track_done();
});
}
function got_versions(req) {
var i, name = 'Versioning', col;
var t = feed_json(req, name).make_table();
if (!t)
return t;
if (!t.cols['Track'] || !t.cols['GID']) {
if (!t.cols['Track'] && !t.cols['GID'])
col = 'Track and no column named GID';
else if (!t.cols['Track'])
col = 'Track';
else
col = 'GID';
return errmsg('Worksheet ' + name + ' has no column named ' + col + '.');
}
num_tracks = t.rows.length;
if (num_tracks)
status('Loaded 0 of ' + num_tracks + ' track' + (num_tracks != 1 ? 's' : '') + '...');
else
status('Loaded 0 tracks.').setAttribute('class', 'alert alert-warning');
for (i = 0; i < num_tracks; i++) {
tracks[i] = append('ul');
tracks[i].setAttribute('class', 'list-group');
tracks[i].setAttribute('gid', t.cell(i, 'GID'));
append('h3', t.cell(i, 'Track'), tracks[i]);
}
}
function got_worksheets(req) {
var i, j, re;
var name = 'worksheets';
var t = feed_json(req, name);
if (!t)
return t;
for (i = 0; i < t.entry.length; i++)
if (TITLE_VERSIONS == t.entry[i].title.$t)
break;
if (i == t.entry.length)
return errmsg('No ' + TITLE_VERSIONS + ' worksheet found.');
httpget(t.linkhref(i, 'cellsfeed'), got_versions, true);
for (i = 0; i < num_tracks; i++) {
re = new RegExp('\\?gid=' + tracks[i].getAttribute('gid') + '&');
for (j = 0; j < t.entry.length; j++) {
if (!re.test(t.linkhref(j, 'exportcsv')))
continue;
get_track(tracks[i].childNodes[0].innerHTML, t.linkhref(j, 'cellsfeed'), i);
break;
}
if (j == t.entry.length)
return errmsg('Worksheet for ' + tracks[i].childNodes[0].innerHTML + ' (gid=' + tracks[i].getAttribute('gid') + ') not found.');
}
}
function go() {
status('Loading...');
httpget(WORKSHEETS, got_worksheets);
}
</script>
</head>
<body onload="go()">
<div class="container" id="container">
<div class="jumbotron" style="text-align:center">
<h2>OpenTechSummit 2015</h2>
<p>Thursday, May 14<br/>Kalkscheune, Johannisstraße 2, 10117 Berlin</p>
</div>
<div id="status" class="alert alert-info">
<noscript>Please enable JavaScript to view the program.</noscript>
</div>
</div>
</body>
</html>