Commit 5a228b9e authored by Marco Mancini's avatar Marco Mancini
Browse files

Cleaned; d3js no longer used in indico

parent aba69d71
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -18,13 +18,7 @@ function read_indico_timetable(url, nb_event)
alert("unable to read the event " + nb_event + " from " + url);
},
complete: function(data){
// console.log(data);
// parse(data.responseJSON, nb_event);
IndicoPlanning.parse(data.responseJSON, nb_event,'indico');
//IndicoPlanning.newMarkUp_Indico('indico',data.responseJSON.results['940'])
}
});
......
......@@ -8,38 +8,32 @@ Script to parse JSON arriving from indico "timetable" and to insert
(function(exports){
function transform_data_keys(data){
var newdata = {};
for (let ii in data){
//days
let locentry = {};
let a = data[ii];
//Session
for(let jj in a){
let bb = a[jj];
if(bb.entryType === 'Session'){
if(Object.keys(bb.entries).length >0){
//console.log(a[jj])
let newentries = {};
let entries = a[jj].entries;
for(let kk in entries){
newentries[entries[kk].startDate.time + '_' + kk] = entries[kk];
}
bb.entries = newentries;
}
}
locentry[a[jj].startDate.time + '_' + jj] = bb;
function serialize_Indico(base, level, obj)
{
// convert object into array
let sortable = [];
for(let key in obj){
if(obj[key].hasOwnProperty('startDate')){
let newkey = base + ':' + obj[key]['startDate']['time'];
obj[key].level = level;
sortable.push([newkey, obj[key]]); // each item is an array in format [key, value]
}
if(obj[key].hasOwnProperty('entries')){
obj[key]['entries'] = serialize_Indico(base, level+1, obj[key]['entries']);
}
newdata[ii] = locentry;
}
return newdata;
// sort items by value
sortable.sort(function(a, b){
let x=a[0].toLowerCase(),
y=b[0].toLowerCase();
return x<y ? -1 : x>y ? 1 : 0;
});
return sortable; // array in format [ [ key1, val1 ], [ key2, val2 ], ... ]
}
function newMarkUp_Indico(key,data,where){
function MakeUp_Indico(key,data,where){
var element = document.getElementById(where);
// day level
moment.locale('fr');
......@@ -171,122 +165,6 @@ Script to parse JSON arriving from indico "timetable" and to insert
function serialize_Indico(base, level, obj)
{
// convert object into array
let sortable = [];
for(let key in obj){
if(obj[key].hasOwnProperty('startDate')){
let newkey = base + ':' + obj[key]['startDate']['time'];
obj[key].level = level;
sortable.push([newkey, obj[key]]); // each item is an array in format [key, value]
}
if(obj[key].hasOwnProperty('entries')){
obj[key]['entries'] = serialize_Indico(base, level+1, obj[key]['entries']);
}
}
// sort items by value
sortable.sort(function(a, b){
let x=a[0].toLowerCase(),
y=b[0].toLowerCase();
return x<y ? -1 : x>y ? 1 : 0;
});
return sortable; // array in format [ [ key1, val1 ], [ key2, val2 ], ... ]
}
function makeup_Indico(key,event_array,where){
// level 0 : parsing days
moment.locale('fr');
let m = moment(key, ['YYYYMMDD']).format('dddd DD MMMM YYYY');
// where to append the result
let element = document.getElementById(where);
let day = d3.select('#'+ element.id)
.append('div')
.attr('class','indico indico_event')
.attr('id','indico_' + key)
;
day.append('div')
.attr('class','indico_date')
.html(m);
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')
;
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;
});
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, where){
let event = data.results[nb_event];
// loop on days
......@@ -296,13 +174,11 @@ Script to parse JSON arriving from indico "timetable" and to insert
let day_event = serialize_Indico(key, 1, event[key]);
// for any day the div is created and appended in where element
newMarkUp_Indico(key,day_event,where);
MakeUp_Indico(key,day_event,where);
}
}
/* Exported fuctions */
exports.parse = parse_indico_json;
exports.transform_data_keys = transform_data_keys;
exports.newMarkUp_Indico = newMarkUp_Indico ;
})(this.IndicoPlanning = {});
......@@ -241,7 +241,6 @@
{% endif %}
</section>
</div>
<script src="/js/d3.min.js"></script>
<script src="/theme/js/jquery.min.js"></script>
<script src="/theme/js/jquery.dropotron.js"></script>
<script src="/theme/js/config.js"></script>
......
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