summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruvok cheetah2025-09-01 19:48:08 +0200
committeruvok cheetah2025-09-01 19:48:08 +0200
commitaa43ecca893ebda91df538c73b311d141e8d9168 (patch)
tree3f6ac88e205ac03cb028d7d688df90e7b3fe7d53
parentc029e3e7595f0f2cb6f54337c29cd80baf04cfa8 (diff)
Remove newsbanner inline script
-rw-r--r--_layouts/postlist.html29
-rw-r--r--assets/js/newsbanner.js28
2 files changed, 29 insertions, 28 deletions
diff --git a/_layouts/postlist.html b/_layouts/postlist.html
index b6b29ef..24909d1 100644
--- a/_layouts/postlist.html
+++ b/_layouts/postlist.html
@@ -57,31 +57,4 @@ layout: default
</div>
-<script>
- document.addEventListener("DOMContentLoaded", function() {
- {%- assign news_ids = site.data.news | map: 'id' | jsonify %}
-
- const ids = {{ news_ids }};
- for (currId of ids) {
- const currentBanner = document.getElementById(currId);
- if (!currentBanner) {
- continue;
- }
- const closeLink = currentBanner.firstElementChild;
- const currentNewsClosed = localStorage.getItem(currId+"closed");
- if (currentNewsClosed === "true") {
- currentBanner.style.display = "none";
- }
-
- function closeBanner(evt) {
- currentBanner.style.display = "none";
- const storId = evt.currentTarget.closeArg + "closed";
- localStorage.setItem(storId, "true");
- }
-
- closeLink.closeArg=currId;
- closeLink.addEventListener("click", closeBanner);
- }
-
- });
-</script>
+<script src="/assets/js/newsbanner.js"></script>
diff --git a/assets/js/newsbanner.js b/assets/js/newsbanner.js
new file mode 100644
index 0000000..1a06f2b
--- /dev/null
+++ b/assets/js/newsbanner.js
@@ -0,0 +1,28 @@
+---
+---
+ document.addEventListener("DOMContentLoaded", function() {
+ {% assign news_ids = site.data.news | map: 'id' | jsonify %}
+
+ const ids = {{ news_ids }};
+ for (currId of ids) {
+ const currentBanner = document.getElementById(currId);
+ if (!currentBanner) {
+ continue;
+ }
+ const closeLink = currentBanner.firstElementChild;
+ const currentNewsClosed = localStorage.getItem(currId+"closed");
+ if (currentNewsClosed === "true") {
+ currentBanner.style.display = "none";
+ }
+
+ function closeBanner(evt) {
+ currentBanner.style.display = "none";
+ const storId = evt.currentTarget.closeArg + "closed";
+ localStorage.setItem(storId, "true");
+ }
+
+ closeLink.closeArg=currId;
+ closeLink.addEventListener("click", closeBanner);
+ }
+
+ });