X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fsrc%2Fmain.js;h=3577b15577728aa25e17edf041727ac698606664;hb=1ef65040168ab7d55ce921abc9d63644a937d689;hp=6714939b6c544cc982a8dbbbb35740f21fbe97cd;hpb=5f13148449c73de92993b7961c077167563b84e5;p=vchess.git diff --git a/client/src/main.js b/client/src/main.js index 6714939b..3577b155 100644 --- a/client/src/main.js +++ b/client/src/main.js @@ -11,8 +11,25 @@ new Vue({ return h(App); }, created: function() { - window.doClick = (elemId) => { document.getElementById(elemId).click() }; - store.initialize(this.$route.path); - // NOTE: at this point, variants and tr(anslations) might be uninitialized - }, + // Several interactions on clicks on elements: + window.doClick = elemId => { + document.getElementById(elemId).click(); + }; + // Esc key can close some modals: + document.addEventListener("keydown", e => { + if (e.code === "Escape") { + let modalBoxes = document.querySelectorAll("[id^='modal']"); + modalBoxes.forEach(m => { + if ( + m.checked && + !["modalAccept", "modalConfirm", "modalChat", "modalPeople"] + .includes(m.id) + ) { + m.checked = false; + } + }); + } + }); + store.initialize(); + } }).$mount("#app");