Added switch to control wether past events are shown or not

This commit is contained in:
Johanna Dorothea Reichmann 2019-03-07 15:45:26 +01:00
parent 7f2957a4b8
commit d4177e7489
Signed by untrusted user who does not match committer: transcaffeine
GPG Key ID: 03624C433676E465

View File

@ -1,5 +1,9 @@
(function(window) { (function(window) {
window.events = {
showPastEvents: false
}
function fetchEvents() { function fetchEvents() {
return new Promise((fullfill, reject) => { return new Promise((fullfill, reject) => {
fetch('./events.json') fetch('./events.json')
@ -69,10 +73,14 @@
window.onload = () => { window.onload = () => {
fetchEvents().then(events => { fetchEvents().then(events => {
const now = Date.now()
events events
.filter(event => !(window.events.showPastEvents && (Date.parse(event.date) - now < 0)))
.sort((a, b) => Date.parse(a.date) - Date.parse(b.date)) .sort((a, b) => Date.parse(a.date) - Date.parse(b.date))
.forEach(event => renderEvent(event)) .forEach(event => renderEvent(event))
}) })
} }
})(window); })(window);
//window.events.showPastEvents = true