Filter out any stages we aren't covering
This commit is contained in:
parent
f750b786af
commit
82665293ee
@ -5,6 +5,8 @@ var now = Date.now();
|
||||
var eventsOnNow = [];
|
||||
var eventsOnNext = [];
|
||||
|
||||
var intervalId = null;
|
||||
|
||||
grist.ready({
|
||||
requiredAccess: 'read table'
|
||||
});
|
||||
@ -12,26 +14,29 @@ grist.ready({
|
||||
grist.onRecords(function (records) {
|
||||
eventsOnNow = [];
|
||||
eventsOnNext = [];
|
||||
now = Date.now() + (60 + 50) * 60 * 1000;
|
||||
now = Date.now();
|
||||
|
||||
var i = 0;
|
||||
|
||||
for (const r of records) {
|
||||
let e = new Event(
|
||||
i++,
|
||||
r["title"],
|
||||
r["venue"],
|
||||
r["video_privacy"],
|
||||
r["Record_override"],
|
||||
r["Comments"],
|
||||
Date.parse(r["start_date"]),
|
||||
Date.parse(r["end_date"])
|
||||
);
|
||||
const venue = r["venue"];
|
||||
if (["Stage A", "Stage B", "Stage C", "Arts", "Arcade Workshop"].includes(venue)) {
|
||||
let e = new Event(
|
||||
i++,
|
||||
r["title"],
|
||||
venue,
|
||||
r["video_privacy"],
|
||||
r["Record_override"],
|
||||
r["Comments"],
|
||||
Date.parse(r["start_date"]),
|
||||
Date.parse(r["end_date"])
|
||||
);
|
||||
|
||||
if (e.hasStarted() && !e.hasEnded()) {
|
||||
eventsOnNow.push(e);
|
||||
} else if (!e.hasStarted() && !e.hasEnded()) {
|
||||
eventsOnNext.push(e);
|
||||
if (e.hasStarted() && !e.hasEnded()) {
|
||||
eventsOnNow.push(e);
|
||||
} else if (!e.hasStarted() && !e.hasEnded()) {
|
||||
eventsOnNext.push(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -46,7 +51,11 @@ grist.onRecords(function (records) {
|
||||
populateList("happeningNow", eventsOnNow, false);
|
||||
populateList("happeningNext", eventsOnNext, true);
|
||||
|
||||
window.setInterval(() => handleCountdown(), 1000);
|
||||
if (intervalId != null) {
|
||||
window.clearInterval(intervalId);
|
||||
}
|
||||
|
||||
intervalId = window.setInterval(() => handleCountdown(), 1000);
|
||||
});
|
||||
|
||||
|
||||
@ -165,6 +174,7 @@ function populateList(elementName, items, getStartsIn) {
|
||||
}
|
||||
|
||||
document.getElementById(elementName).appendChild(listItem);
|
||||
document.getElementById(elementName).appendChild(listItem);
|
||||
}
|
||||
}
|
||||
|
||||
@ -185,6 +195,8 @@ function handleCountdown() {
|
||||
if (countdown == 0) {
|
||||
countdown = MAX_COUNTDOWN;
|
||||
|
||||
// now = Date.now();
|
||||
now = Date.now();
|
||||
refreshLists();
|
||||
populateList("happeningNow", eventsOnNow, false);
|
||||
populateList("happeningNext", eventsOnNext, true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user