From 22170810b718ed67fddeb0a94be4ef013fdc6068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Mon, 27 Apr 2020 00:40:48 +0200 Subject: Made script finding of elements more stable. --- static/script.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/static/script.js b/static/script.js index 6bb55c2f..7cd99bef 100644 --- a/static/script.js +++ b/static/script.js @@ -151,9 +151,12 @@ function new_popup (event) { // if (event.target !== this) return; /* popup = this.children[0].children[0] */ - popup = this.parentElement.parentElement.getElementsByClassName("popup")[0]; + let ev = parents_until(this, {class: "event"}) + popup = ev.getElementsByClassName("popup")[0]; popup.classList.toggle("show") + return; + /* x-axis fix */ /* Popup should neven be wider than viewport */ @@ -218,7 +221,9 @@ window.onload = function () { // } days = document.getElementsByClassName("days")[0] - for (let e of days.getElementsByClassName("body")) { + for (let popup of document.getElementsByClassName("popup")) { + ev = parents_until(popup, {class: "event"}) + e = ev.getElementsByClassName("body")[0] e.onclick = new_popup; e.parentElement.href = "#"; } -- cgit v1.2.3