Browse Source

[feature] convert newlines to <br> + cleanup

master
r0 2 years ago
parent
commit
42f99c5c01
  1. 22
      programme.js

22
programme.js

@ -110,8 +110,6 @@ function preparePage(data) {
for (let eventIndex in place) {
let event = place[eventIndex];
let cleanedEvent = event;
cleanedEvent.place = placeName;
//edge-cases : no author/description
['author', 'description'].forEach(function(item) {
if (cleanedEvent[item] == null) {
@ -119,6 +117,9 @@ function preparePage(data) {
}
})
cleanedEvent.place = placeName;
cleanedEvent.description = cleanedEvent.description.replace('\n', '<br>');
if (currentDay.length > 0) {
for (let sortedEventIndex in currentDay) {
let sortedEvent = currentDay[sortedEventIndex];
@ -134,14 +135,7 @@ function preparePage(data) {
}
sortedData[dayName] = sortedData[dayName].reverse();
}
fillTimetables(sortedData);
document.querySelector('h1').innerHTML = "Demandez le programme!";
document.querySelector('div#modal button').addEventListener('click', function(ev) {
document.querySelector('div#modal').classList.remove('upfront');
})
return sortedData;
}
window.addEventListener("DOMContentLoaded", function(event) {
@ -151,7 +145,13 @@ window.addEventListener("DOMContentLoaded", function(event) {
xhr.onload = function() {
if (xhr.status == 200) {
preparePage(xhr.response);
let data = preparePage(xhr.response);
fillTimetables(data);
document.querySelector('h1').innerHTML = "Demandez le programme!";
document.querySelector('div#modal button').addEventListener('click', function(ev) {
document.querySelector('div#modal').classList.remove('upfront');
});
} else {
document.querySelector('h1').innerHTML = "Erreur : " + xhr.status;
}

Loading…
Cancel
Save