Commit 86bd7073 authored by Matthieu Boileau's avatar Matthieu Boileau
Browse files

Merge branch 'master' into 'maquette'

# Conflicts:
#   content/js/indico_planning.js
parents 494a6440 b97a3522
tr.focal td{
border-top: 1px solid grey;
line-height: 1.2;
}
td.focal_title{
width: 35%;
}
td.focal_title > a{
text-decoration: none;
}
td.focal_date {
margin-left: 5px;
\ No newline at end of file
......@@ -3,8 +3,8 @@
clear: both;
}
.indico_1{margin-left: 0px;}
.indico_2{margin-left: 110px;}
.indico_1{margin-left: 0px; border-top: 1px solid grey;}
.indico_2{margin-left: 90px; border-top: 1px solid grey;}
.indico_date{
width: 100%;
......@@ -15,34 +15,37 @@
}
.indico_header{
width: 100%;
padding-left:10px;
border-top: 1px solid grey;
/* width: 100%; */
/* padding-left:10px; */
/* border-top: 1px solid grey; */
}
.indico_contain{
display: inline-flex;
}
.indico_time{
width: 100px;
display: table;
/* display: inline; */
}
.indico_title{
/* display: inline; */
padding-left: 20px;
font-weight: bold;
}
.indico_desc{
padding-left: 100px;
margin: 0;
padding-left: 20px;
/* margin: 0; */
font-style: italic;
max-width: 800px;
}
.indico_2 .indico_desc{
padding-left: 60px;
}
.indico_conveners, .indico_loc, .indico_doc{
padding-left: 10px;
/* padding-left: 20px; */
margin: 0;
}
title: Focal data
slug: focal
date: 2018-01-09
type: text
Scripts: focal_manage.js
Styles: focal.css
<div id="focal_data"></div>
"use strict";
function read(data){
return data;
}
function MakeUpFocalElement(json_entry,base){
let newevent = document.createElement('tr');
newevent.className = 'focal';
moment.locale('fr');
let title = json_entry.tra_title,
date = moment(json_entry.tra_dtstart.split('T')[0], ['YYYYMMDD']).format('DD-MM-YYYY'),
urbanArea = json_entry.tra_urbanArea.split(',')[0],
web = json_entry.tra_web,
type = json_entry.tra_type
;
newevent.innerHTML = '' +
'<td class="focal_title"><a href="'+web+'">'+ title + '</a></td>' +
'<td class="focal_date">'+ date + '</td>' +
'<td class="focal_urbanArea">'+ urbanArea + '</td>' +
'<td class="focal_type">'+ type + '</td>'
;
base.appendChild(newevent);
};
function read_focal_data(url, nb_event)
{
$.ajax( {
type: "GET",
url: "http://formation-calcul.fr/api/training/trainings/?format=jsonp",
dataType: "jsonp",
// jsonp: false,
jsonpCallback: "read",
success: function(jsonp) {
},
error: function(event) {
alert("unable to read the event " + nb_event + " from " + url);
},
complete: function(data){
var results = data.responseJSON.results;
var base_element = document.getElementById('focal_data');
for(var ii in results){
MakeUpFocalElement(results[ii],base_element);
}
//FocalParse(data.responseJSON, nb_event,'focal_data');
}
});
}
read_focal_data();
"use strict";
function read(data){
return data;
......
......@@ -8,6 +8,27 @@ Script to parse JSON arriving from indico "timetable" and to insert
(function(exports){
function create_authors_str(collab){
let result = collab.name;
if(collab.affiliation !==''){ result += ' ('+collab.affiliation+')';}
return result;
};
function create_time_str(t_start, t_end){
let start = t_start.time.split(':');
start.pop(); start = start.join(':');
let result = start;
if(t_end){
let end = t_end.time.split(':');
end.pop(); end = end.join(':');
result += '-' + end;
}
return result;
}
function serialize_Indico(base, level, obj)
{
// convert object into array
......@@ -17,6 +38,18 @@ Script to parse JSON arriving from indico "timetable" and to insert
if(obj[key].hasOwnProperty('startDate')){
let newkey = base + ':' + obj[key]['startDate']['time'];
obj[key].level = level;
if(obj[key].hasOwnProperty('presenters')){
obj[key].orators_str = obj[key].presenters.map(create_authors_str).join(', ') + '';
}
if(level === 1){
obj[key].times_str = create_time_str(obj[key].startDate,obj[key].endDate);
}
else{
obj[key].times_str = create_time_str(obj[key].startDate);
}
sortable.push([newkey, obj[key]]); // each item is an array in format [key, value]
}
if(obj[key].hasOwnProperty('entries')){
......@@ -29,12 +62,46 @@ Script to parse JSON arriving from indico "timetable" and to insert
y=b[0].toLowerCase();
return x<y ? -1 : x>y ? 1 : 0;
});
return sortable; // array in format [ [ key1, val1 ], [ key2, val2 ], ... ]
return sortable.map(function(d){return d[1];}); // array
}
function MakeUp_Indico(key,data,where){
var element = document.getElementById(where);
var template = ''+
'{{#data}}'+
'<div class="indico_1">' +
' <div class="indico_contain">'+
' <div class="indico_time">{{times_str}}</div>' +
' <div class="indico_header">' +
' <div class="indico_title">{{title}}</div>' +
' <div class="indico_desc">{{description}}</div>' +
' </div>' +
' </div>' +
' {{#entries}}'+
' <div class="indico_2">'+
' <div class="indico_contain">'+
' <div class="indico_time">{{times_str}}</div>'+
' <div class="indico_header">'+
' <div class="indico_title">{{title}}</div>'+
' <div class="indico_desc">{{description}}</div>'+
' </div>'+
' </div>'+
' {{#orators_str}}'+
' <div class="indico_conveners">Contributeurs : {{orators_str}}</div>'+
' {{/orators_str}}'+
' {{#material}}'+
' <div class="indico_doc"> Document : '+
' <a href="{{resources.0.url}}">{{title}}</a>'+
' </div>'+
' {{/material}}'+
' </div>'+
' {{/entries}}'+
' <div class="indico_loc">Lieu : {{room}}</div>' +
'</div>'+
'{{/data}}';
function MakeUp_Indico(key,data){
// day level
moment.locale('fr');
let m = moment(key, ['YYYYMMDD']).format('dddd DD MMMM YYYY');
......@@ -42,7 +109,7 @@ Script to parse JSON arriving from indico "timetable" and to insert
//date
let newele = document.createElement('div');
newele.className = 'indico_event';
element.appendChild(newele);
let date = document.createElement('div');
date.className = 'indico_date';
......@@ -50,140 +117,31 @@ Script to parse JSON arriving from indico "timetable" and to insert
newele.appendChild(date);
var template = ''+
'<div class="indico_1">' +
' <div class="indico_header">' +
' <span class="indico_time">{{time}}</span>' +
' <span class="indico_title">{{title}}</span>' +
' </div>' +
' <div class="indico_desc">{{description}}</div>' +
'{{subsession}}'+
' <div class="indico_loc">{{location}}</div>' +
'</div>';
for( let hh in data){
let session = data[hh][1];
let values = {};
newele.innerHTML += Mustache.to_html(template,{ data : data});
//time
let start = session.startDate.time.split(':');
start.pop(); start = start.join(':');
let end = session.endDate.time.split(':');
end.pop(); end = end.join(':');
values = {
time : start + '-' + end,
title : session.title,
description : session.description
};
// if(session.entryType == 'Session'){
// if(session.conveners.length >0){
// let conv = document.createElement('div');
// conv.className = 'indico_conveners';
// conv.innerHTML = 'Contributeurs : '+session.conveners.map(
// function(a) {return a.name;}).join(', ') + '';
// sessionDiv.appendChild(conv);
// }
// if(Object.keys(session.entries).length >0){
// for(let ii in session.entries){
// let sub = session.entries[ii][1];
// let subDiv = document.createElement('div');
// subDiv.className = 'indico_2';
// //subelement
// let header = document.createElement('div');
// header.className = 'indico_header';
// //time
// let time = document.createElement('span');
// time.className = 'indico_time';
// time.innerHTML = (function(d){
// let start = d.startDate.time.split(':');
// start.pop(); start = start.join(':');
// return start;
// })(sub);
// header.appendChild(time);
// //title
// let title = document.createElement('span');
// title.className = 'indico_title';
// title.innerHTML = sub.title;
// header.appendChild(title);
// subDiv.appendChild(header);
// let desc = document.createElement('div');
// desc.className = 'indico_desc';
// desc.innerHTML = sub.description;
// //
// subDiv.appendChild(desc);
// if(sub.presenters.length >0){
// let conv = document.createElement('div');
// conv.className = 'indico_conveners';
// conv.innerHTML = 'Contributeurs : '+sub.presenters.map(
// function(a) {return a.name;}).join(', ') + '';
// subDiv.appendChild(conv);
// }
// if(sub.material.length > 0) {
// let material = sub.material[0];
// let doc = document.createElement('div');
// doc.className = 'indico_doc';
// doc.innerHTML = 'Document : <a href="' + material.resources[0].pdf +'">'+material.title+'</a>';
// subDiv.appendChild(doc);
// }
// sessionDiv.appendChild(subDiv);
// }
// }
values.location = session.room;
//
// if(session.material.length > 0) {
// let material = session.material[0];
// let doc = document.createElement('div');
// doc.className = 'indico_doc';
// doc.innerHTML = 'Document : <a href="' + material.resources[0].pdf +'">'+material.title+'</a>';
// sessionDiv.appendChild(doc);
// }
let sessionDiv = document.createElement('div');
var html = Mustache.to_html(template, values);
sessionDiv.innerHTML = html;
newele.appendChild(sessionDiv);
// }
}
return newele;
console.log(data);
}
function parse_indico_json(data, nb_event, where){
let event = data.results[nb_event];
let event = data.results[nb_event],
element = document.getElementById(where),
newdiv = document.createElement('div');
// loop on days
for (let key in event){
// any day is serialized
let day_event = serialize_Indico(key, 1, event[key]);
let day_event = serialize_Indico(key,1,event[key]);
// for any day the div is created and appended in where element
MakeUp_Indico(key,day_event,where);
newdiv.appendChild( MakeUp_Indico(key,day_event));
}
element.appendChild(newdiv);
}
/* Exported fuctions */
......
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