Step toward a one-page application
[vchess.git] / public / javascripts / utils / misc.js
index f2927c3..287c0ea 100644 (file)
@@ -27,3 +27,21 @@ function getRandString()
        return (Date.now().toString(36) + Math.random().toString(36).substr(2, 7))
                .toUpperCase();
 }
+
+// Used both on index and variant page, to switch language
+function setLanguage(e)
+{
+       setCookie("lang", e.target.value);
+       location.reload(); //to include the right .pug file
+}
+
+// Shortcut for an often used click (on a modal)
+function doClick(elemId)
+{
+       document.getElementById(elemId).click(); //or ".checked = true"
+}
+
+function translate(msg)
+{
+       return translations[msg];
+}