source: trunk/MobileIndico/indico.js@ 18646

Last change on this file since 18646 was 18640, checked in by tbretz, 8 years ago
Allow to specify the Indico URL on the command line
File size: 8.9 KB
Line 
1var default_url = "https://indico.scc.kit.edu/indico/";
2var default_event = 215;
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 = [];
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 = [];
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]; });
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 = [];
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'>";
85
86
87 // -------------------------------------------------------
88 list += "<span class='date'>"+e.startDate.time.substr(0,5)+" ";
89 list += "<a class='title' href='"+e.url+"'>"+e.title+"</a>";
90 list += "</span>";
91 // -------------------------------------------------------
92
93
94 // -------------------------------------------------------
95 list += "<span class='presenters'>";
96 var p = e.presenters;
97 for (var j=0; j<p.length; j++)
98 {
99 list += p[j].name;
100 if (p[j].affiliation.length>0)
101 list += " ["+p[j].affiliation+"]";
102 if (p[j].email.length>0)
103 list += " <a class='email' href='email:"+p[j].email+"'>"+p[j].email+"</a>";
104 list += "<br/>";
105 }
106 list += "</span>";
107 // -------------------------------------------------------
108
109
110 list += "<span class='description'>"+e.description+"</span>";
111
112
113 // -------------------------------------------------------
114 list += "<span class='material'>";
115 var m = e.material;
116 for (var j=0; j<m.length; j++)
117 {
118 list += "<span class='title'>"+m[j].title+": </span>";
119
120 list += "<span class='resources'>";
121 var r = m[j].resources;
122 for (var k=0; k<r.length; k++)
123 {
124 list += "<a class='url' href='"+r[k].url+"'>"+r[k].name+"</a>";
125 if (r[k].description.length>0)
126 list += "<span class='description'>" + m[k].description + "</span>";
127 }
128 list += "</span>";
129
130 if (m[j].description.length>0)
131 list += "<span class='description'> ["+m[j].description+"]</span>";
132
133 }
134 list += "</span>"; // indico-contribution-material
135 // -------------------------------------------------------
136
137
138 list += "</div>"; // indico-contribution
139 // =======================================================
140 }
141
142 list += "</div>"; // indico-session-body
143 // =======================================================
144
145
146 list += "</div>"; // collapsible "indico-session"
147
148 /*
149
150 "material": [
151 {
152 "_type": "Slides",
153 "description": "",
154 "title": "Slides",
155 "_fossil": "materialMinimal",
156 "protectionURL": "https://indico.scc.kit.edu/indico/event/215/manage/session/3/contribution/28/material/?returnURL=",
157 "type": "",
158 "id": "slides",
159 "resources": [
160 {
161 "_type": "LocalFile",
162 "name": "Auger-HEAT.pdf",
163 "url": "https://indico.scc.kit.edu/indico/event/215/session/3/contribution/28/material/slides/0.pdf",
164 "_fossil": "localFileMinimal",
165 "protectionURL": "https://indico.scc.kit.edu/indico/event/215/manage/session/3/contribution/28/material/?returnURL=",
166 "description": ""
167 }*/
168
169 // HERE WE NEED TO LOOP OVER THE CONTRIBUTIONS
170
171 //alert(JSON.stringify(slots[s][1]));
172 //break;
173
174 // entryType "Session" "Contribution" "Break"
175 // isPoster,
176 // startDate { date, tz }
177 // endDate { date, tz }
178 // duration
179 // contribDuration,
180 // color
181 // textColor,
182 // title
183 // slotTitle
184 // location
185 // room,
186 // conveners []
187 // material []
188 // entries { }
189 // url,
190 // pdf
191 //
192 // sessionSlotId
193 // conferenceId
194 // inheritRoom
195 // uniqueid
196 // _fossil "linedTimeSchEntry"
197 // _type "LinkedTimeSchEntry"
198 // sessionCode,
199 // sessionid,
200 // inheritLoc,
201 }
202
203 //list += "</div>"; // collapsible-set "day"
204 list += "</div>"; // collapsible
205 }
206
207 $('#list').append(list);
208 $('#list').collapsibleset('refresh');
209}
210
211function read(json)
212{
213 var ID = Object.keys(json.results);
214
215 process(ID, json);
216
217 $('#footer').css("position", "relative");
218 $.mobile.loading('hide');
219}
220
221function onReady()
222{
223 $.mobile.loading('show', {
224 text: "Loading timetable...",
225 textVisible: true,
226 /* theme: "a", */
227 });
228
229 /*---------------------------------------------------------------------------------------------
230 Request the timetabel of the indico event we are interested in
231 ----------------------------------------------------------------------------------------------*/
232
233 var cmd = window.location.href.split("?")[1];
234
235 var ID = cmd ? cmd.split("&").find(function(str){ return str.split("=")[0]=="id"; }) : null;
236 var URL = cmd ? cmd.split("&").find(function(str){ return str.split("=")[0]=="url"; }) : null;
237
238 if (ID)
239 default_event = ID.split("=")[1];
240 if (URL)
241 default_url = URL.split("=")[1];
242
243 $.getJSON(default_url+"/export/timetable/"+default_event+".jsonp?callback=?");
244 //$.getJSON(indico_url+"/export/event/"+ID+".jsonp?callback=?");
245 // json.results[0].title
246}
247
248$('document').ready(onReady);
Note: See TracBrowser for help on using the repository browser.