aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--static/scripts/auto_refresh.js16
-rw-r--r--views/index.tpl1
2 files changed, 17 insertions, 0 deletions
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);
+})();
diff --git a/views/index.tpl b/views/index.tpl
index fd26295..f65a1af 100644
--- a/views/index.tpl
+++ b/views/index.tpl
@@ -42,6 +42,7 @@
white-space: nowrap;
}
</style>
+ <script src="/static/scripts/auto_refresh.js" defer></script>
</head>
<body>
<h1>TagRSS</h1>