Added switch to control wether past events are shown or not
This commit is contained in:
parent
7f2957a4b8
commit
d4177e7489
8
timer.js
8
timer.js
@ -1,5 +1,9 @@
|
||||
(function(window) {
|
||||
|
||||
window.events = {
|
||||
showPastEvents: false
|
||||
}
|
||||
|
||||
function fetchEvents() {
|
||||
return new Promise((fullfill, reject) => {
|
||||
fetch('./events.json')
|
||||
@ -69,10 +73,14 @@
|
||||
|
||||
window.onload = () => {
|
||||
fetchEvents().then(events => {
|
||||
const now = Date.now()
|
||||
events
|
||||
.filter(event => !(window.events.showPastEvents && (Date.parse(event.date) - now < 0)))
|
||||
.sort((a, b) => Date.parse(a.date) - Date.parse(b.date))
|
||||
.forEach(event => renderEvent(event))
|
||||
})
|
||||
}
|
||||
|
||||
})(window);
|
||||
|
||||
//window.events.showPastEvents = true
|
Loading…
Reference in New Issue
Block a user