From ada68d54884cb8ce609d35461bf2ddf3fbcaa120 Mon Sep 17 00:00:00 2001 From: Arjun Satarkar Date: Sun, 30 Jul 2023 01:01:15 +0530 Subject: Add auto-refresh JS --- static/scripts/auto_refresh.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 static/scripts/auto_refresh.js (limited to 'static/scripts') diff --git a/static/scripts/auto_refresh.js b/static/scripts/auto_refresh.js new file mode 100644 index 0000000..dd2bd1d --- /dev/null +++ b/static/scripts/auto_refresh.js @@ -0,0 +1,16 @@ +(() => { + const UPDATE_INTERVAL_MILLISECONDS = 1 * 60 * 1000; // 1 minute + setInterval(async () => { + const response = await fetch(window.location, { + credentials: "same-origin", + }); + if (!response.ok) { + return; + } + const responseText = await response.text(); + + const parser = new DOMParser(); + const newDoc = parser.parseFromString(responseText, "text/html"); + document.querySelector("table").innerHTML = newDoc.querySelector("table").innerHTML; + }, UPDATE_INTERVAL_MILLISECONDS); +})(); -- cgit v1.2.3-57-g22cb