Added switch to control wether past events are shown or not
This commit is contained in:
parent
7f2957a4b8
commit
d4177e7489
10
timer.js
10
timer.js
@ -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
|
Loading…
Reference in New Issue
Block a user