Experimental game upload added
[vchess.git] / client / src / main.js
index 6714939..3577b15 100644 (file)
@@ -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");