From 82665293ee7a58642c9604682c6ead7a8a699201 Mon Sep 17 00:00:00 2001 From: Qumarth Jash Date: Thu, 16 Jul 2026 18:05:58 +0100 Subject: [PATCH] Filter out any stages we aren't covering --- plugin-api.js | 44 ++++++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/plugin-api.js b/plugin-api.js index 2e27c27..af2be45 100644 --- a/plugin-api.js +++ b/plugin-api.js @@ -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);