source: trunk/MobileIndico/indico.js@ 19385

Last change on this file since 19385 was 19230, checked in by tbretz, 6 years ago
Now this also works on my mobile device and respects the changes which came with the new indico version.
File size: 10.4 KB
Line 
1var default_url = "https://indico.scc.kit.edu/indico/";
2var default_event = 390;
3
4function process(ID, result)
5{
6 if (window.location.href.indexOf("debug")>=0)
7 $('#debug').append("<pre>"+JSON.stringify(result,null,2)+"</pre>");
8
9 $("#indico-link").attr("href", default_url+"/event/"+ID)
10
11 var conf = result['results'][ID];
12
13 var list = "";
14
15 // Sort the days into the correct order
16 var days = new Array(0);
17 for (var day in conf)
18 days.push([ day, conf[day] ]);
19 days.sort(function(a, b) { return a[0] > b[0]; });
20
21 for (var d=0; d<days.length; d++)
22 {
23 var day = days[d][0]; // "20161206"
24
25 // Convert "20161206" -> "2016/12/06"
26 var date = day.substr(0, 4)+"&thinsp;/&thinsp;"+day.substr(4, 2)+"&thinsp;/&thinsp;"+day.substr(6,2);
27
28 // Date accordion
29 list += "<div class='indico' data-role='collapsible' data-theme='b' data-inset='false'>";
30 list += "<h1>"+date+"</h1>";
31 //list += "<div id='"+day+"' data-role='collapsible-set' data-filter='true' data-input='#filter' data-mini='true' data-theme='a' data-content-theme='a'>";
32
33 var content = days[d][1];
34
35 // Sort all slots in a days by startDate/time
36 var slots = new Array(0);
37 for (var slot in content)
38 slots.push([ content[slot].startDate.time, content[slot]]);
39 slots.sort(function(a, b) { return a[0]==b[0] ? 0 : (a[0] > b[0] ? 1 : -1) });
40
41 // Loop over all slots (sessions)
42 for (var s=0; s<slots.length; s++)
43 {
44 var e = slots[s][1]; // entry
45
46 // Accordion for each session
47 list += "<div class='session' data-role='collapsible' data-inset='false'>";
48 list += "<h1 class='date'>"+e.startDate.time.substr(0,5)+"&thinsp;-&thinsp;"+e.endDate.time.substr(0,5)+"&ensp;"+e.title+"</h1>";
49 //list += "<h1 class='date'>"+e.startDate.time.substr(0,5)+" ["+e.duration+"'] "+e.title+"</h1>";
50 //list += "<h1 class='date'>"+e.startDate.time.substr(0,5)+" - "+e.endDate.time.substr(0,5)+" ["+e.duration+"'] "+e.title+"</h1>";
51
52
53 // =======================================================
54 list += "<div class='body'>";
55
56
57 // -------------------------------------------------------
58 list += "<span class='type' style='background-color:"+e.color+";'>"+e.entryType;
59 if (e.location.length+e.room.length>0)
60 {
61 list += "<span class='location'>";
62 list += " ["+e.room;
63 if (e.location.length>0 && e.room.length>0)
64 list += ", ";
65 list += e.location+"]";
66 list += "</span>"
67 }
68 list += "</span>";
69 // -------------------------------------------------------
70
71
72 // Sort all entries in a session by startDate/time
73 var entries = new Array(0);
74 for (var entry in e.entries)
75 entries.push([ e.entries[entry].startDate.time, e.entries[entry]]);
76 entries.sort(function(a, b) { return a[0] > b[0]; });
77 // description, title, material, url, entryType, presenters []
78
79 for (var i=0; i<entries.length; i++)
80 {
81 var e = entries[i][1];
82
83 // =======================================================
84 list += "<div class='contribution' data-role='collapsible' data-collapsed-icon='carat-d' and data-expanded-icon='carat-u'>";
85 list += "<h1>";
86
87
88 // -------------------------------------------------------
89 list += "<span class='date'>"+e.startDate.time.substr(0,5)+" ";
90 list += "<a class='title' href='"+e.url+"'>"+e.title+"</a>";
91 list += "</span>";
92 // -------------------------------------------------------
93
94
95 // -------------------------------------------------------
96 list += "<span class='presenters'>";
97 var p = e.presenters;
98 for (var j=0; j<p.length; j++)
99 {
100 list += p[j].name;
101 if (p[j].affiliation && p[j].affiliation.length>0)
102 list += " ["+p[j].affiliation+"]";
103 if (p[j].email && p[j].email.length>0)
104 list += " <a class='email' href='email:"+p[j].email+"'>"+p[j].email+"</a>";
105
106 list += "<br/>";
107 }
108 list += "</span>"; // presenters
109 list += "</h1>";
110 // -------------------------------------------------------
111
112
113 list += "<span class='description'>"+e.description+"</span>"; // Abstract
114
115
116 // -------------------------------------------------------
117 // Old version of Indico
118
119 list += "<span class='material'>";
120 var m = e.material;
121 for (var j=0; j<(m?m.length:0); j++)
122 {
123 list += "<span class='title'>"+m[j].title+": </span>";
124
125 list += "<span class='resources'>";
126 var r = m[j].resources;
127 for (var k=0; k<r.length; k++)
128 {
129 list += "<a class='url' href='"+r[k].url+"'>"+r[k].name+"</a>";
130 if (r[k].description.length>0)
131 list += "<span class='description'>" + m[k].description + "</span>";
132 }
133 list += "</span>";
134
135 if (m[j].description.length>0)
136 list += "<span class='description'> ["+m[j].description+"]</span>";
137
138 }
139 list += "</span>"; // indico-contribution-material
140
141 // -------------------------------------------------------
142 // Newer version of Indico
143
144 list += "<span class='material'>";
145 var fi = e.attachments.files;
146 for (var j=0; j<(fi?fi.length:0); j++)
147 {
148 list += "<span class='resources'>";
149 list += "<a class='url' href='"+fi[j].download_url+"'>"+fi[j].title+"</a>";
150 list += "</span>";
151 }
152
153 var fo = e.attachments.folders;
154 //list += "<span class='title'>"+fo.title+": </span>";
155 for (var j=0; j<(fo?fo.length:0); j++)
156 {
157 var g = fo[j].attachments;
158
159 for (var k=0; k<(g?g.length:0); k++)
160 {
161 list += "<span class='resources'>";
162 list += "<a class='url' href='"+g[k].download_url+"'>"+g[k].title+"</a>";
163 list += "</span>";
164 }
165 }
166 list += "</span>"; // indico-contribution-material
167
168 // -------------------------------------------------------
169
170
171 list += "</div>"; // indico-contribution
172 // =======================================================
173 }
174
175 list += "</div>"; // indico-session-body
176 // =======================================================
177
178
179 list += "</div>"; // collapsible "indico-session"
180
181 /*
182
183 "material": [
184 {
185 "_type": "Slides",
186 "description": "",
187 "title": "Slides",
188 "_fossil": "materialMinimal",
189 "protectionURL": "https://indico.scc.kit.edu/indico/event/215/manage/session/3/contribution/28/material/?returnURL=",
190 "type": "",
191 "id": "slides",
192 "resources": [
193 {
194 "_type": "LocalFile",
195 "name": "Auger-HEAT.pdf",
196 "url": "https://indico.scc.kit.edu/indico/event/215/session/3/contribution/28/material/slides/0.pdf",
197 "_fossil": "localFileMinimal",
198 "protectionURL": "https://indico.scc.kit.edu/indico/event/215/manage/session/3/contribution/28/material/?returnURL=",
199 "description": ""
200 }*/
201
202 // HERE WE NEED TO LOOP OVER THE CONTRIBUTIONS
203
204 //alert(JSON.stringify(slots[s][1]));
205 //break;
206
207 // entryType "Session" "Contribution" "Break"
208 // isPoster,
209 // startDate { date, tz }
210 // endDate { date, tz }
211 // duration
212 // contribDuration,
213 // color
214 // textColor,
215 // title
216 // slotTitle
217 // location
218 // room,
219 // conveners []
220 // material []
221 // entries { }
222 // url,
223 // pdf
224 //
225 // sessionSlotId
226 // conferenceId
227 // inheritRoom
228 // uniqueid
229 // _fossil "linedTimeSchEntry"
230 // _type "LinkedTimeSchEntry"
231 // sessionCode,
232 // sessionid,
233 // inheritLoc,
234 }
235
236 //list += "</div>"; // collapsible-set "day"
237 list += "</div>"; // collapsible
238 }
239
240 $('#list').append(list);
241 $('#list').collapsibleset('refresh');
242}
243
244function read(json)
245{
246 var ID = Object.keys(json.results);
247
248 process(ID, json);
249
250 $('#footer').css("position", "relative");
251 $.mobile.loading('hide');
252}
253
254function onReady()
255{
256 $.mobile.loading('show', {
257 text: "Loading timetable...",
258 textVisible: true,
259 /* theme: "a", */
260 });
261
262 /*---------------------------------------------------------------------------------------------
263 Request the timetabel of the indico event we are interested in
264 ----------------------------------------------------------------------------------------------*/
265
266 var cmd = window.location.href.split("?")[1];
267
268 var ID = cmd ? cmd.split("&").find(function(str){ return str.split("=")[0]=="id"; }) : null;
269 var URL = cmd ? cmd.split("&").find(function(str){ return str.split("=")[0]=="url"; }) : null;
270
271 if (ID)
272 default_event = ID.split("=")[1];
273 if (URL)
274 default_url = URL.split("=")[1];
275
276 $.getJSON(default_url+"/export/timetable/"+default_event+".jsonp?callback=?");
277 //$.getJSON(indico_url+"/export/event/"+ID+".jsonp?callback=?");
278 // json.results[0].title
279}
280
281$('document').ready(onReady);
Note: See TracBrowser for help on using the repository browser.