From 986afaf97fa07832d895e62a48cf5eda07cd0aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= Date: Thu, 30 Apr 2020 22:58:18 +0200 Subject: Escape closes all popups. --- static/script.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'static') diff --git a/static/script.js b/static/script.js index b94e8f06..8617159a 100644 --- a/static/script.js +++ b/static/script.js @@ -222,6 +222,12 @@ function setVar(str, val) { document.documentElement.style.setProperty("--" + str, val); } +function close_all_popups () { + for (let popup of document.getElementsByClassName("popup")) { + popup.classList.remove("show"); + } +} + window.onload = function () { start_time.setTime(document.querySelector("meta[name='start-time']").content * 1000) end_time.setTime(document.querySelector("meta[name='end-time']").content * 1000) @@ -255,4 +261,11 @@ window.onload = function () { e.parentElement.removeAttribute("href"); } + document.onkeydown = function (evt) { + evt = evt || window.event; + if (evt.key.startsWith("Esc")) { + close_all_popups(); + } + } + } -- cgit v1.2.3