Commit ed139b3f authored by Marco Mancini's avatar Marco Mancini
Browse files

short advances in indico

parent 157279d9
......@@ -16,6 +16,7 @@
display: flex;
width: 100%;
padding-left:10px;
border-top: 1px solid grey;
}
.indico_times{
......@@ -29,12 +30,12 @@
.indico_desc{
padding-left:20px;
padding-left:30px;
margin: 0;
font-style: italic;
}
.indico_conveners, .indico_loc{
padding-left:20px;
padding-left:30px;
margin: 0;
}
......@@ -20,7 +20,7 @@ function read_indico_timetable(url, nb_event)
complete: function(data){
// console.log(data);
// parse(data.responseJSON, nb_event);
IndicoPlanning.parse(data.responseJSON, nb_event);
IndicoPlanning.parse(data.responseJSON, nb_event,'indico');
}
});
......
"use strict";
/*
Script to parse JSON arriving from indico "timetable" and to insert
these information in a div.
*/
(function(exports){
// function parse_in(event){
......@@ -44,13 +50,14 @@
function makeup_Indico(key,event_array){
function makeup_Indico(key,event_array,where){
// level 0 : parsing days
moment.locale('fr');
let m = moment(key, ['YYYYMMDD']).format('dddd DD MMMM YYYY');
let element = document.getElementById('indico');
//let element = document.createElement('div');
// where to append the result
let element = document.getElementById(where);
let day = d3.select('#'+ element.id)
.append('div')
......@@ -62,41 +69,87 @@
.attr('class','indico_date')
.html(m);
let hours = day.selectAll(".indico")
let hours = day.selectAll(null)
.data(event_array)
.enter()
.append("div")
.attr('class', function(d){
return 'indico_' + d[1].level;
})
});
let headers = hours.append('div')
.attr('class','indico_header')
;
hours.append('div')
.attr('class','indico_header')
headers.append('div')
.attr('class','indico_times')
.html(function(d){
let start = d[1].startDate.time.split(':');
start.pop(); start = start.join(':');
let end = d[1].endDate.time.split(':');
end.pop(); end = end.join(':');
return start + '-' + end;
});
let timeDiv = '<div class="indico_times">' +start + '-' + end + '</div>';
let titleDiv = '<div class="indico_title">' + d[1].title + '</div>';
return timeDiv + titleDiv;})
;
headers.append('div')
.attr('class','indico_title')
.html(function(d){
return d[1].title;
});
hours.append('div')
.attr('class','indico_desc')
.html(function(d){
return d[1].description;
});
hours.append('div')
.attr('class','indico_loc')
.html(function(d){
return (d[1].level<2) ? 'Lieu : ' + d[1].room : '';
});
hours.append('div')
.attr('class','indico_conveners')
.html(function(d){
console.log(d[1]._type,d[1].entryType,d[1])
let result = '';
switch(d[1].entryType){
case 'Contribution' :
if(d[1].presenters.length >0){
result = 'Contributeurs : '+d[1].presenters.map(
function(a) {return a.name;}).join(', ') + '';
}
break;
case 'Session' :
if(d[1].conveners.length >0){
result = 'Conveners : '+d[1].conveners.map(
function(a) {return a.name;}).join(', ') + '';
}
break;
}
return result;
});
}
function parse_indico_json(data, nb_event){
function parse_indico_json(data, nb_event, where){
let event = data.results[nb_event];
// loop on days
for (let key in event){
// any day is serialized
let day_event = serialize_Indico(key, 1, event[key]);
makeup_Indico(key,day_event);
// for any day the div is created and appended in where element
makeup_Indico(key,day_event,where);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment