Progression in styles + initiate translation process
[vchess.git] / public / javascripts / index.js
index d95f96a..13004f0 100644 (file)
@@ -1,3 +1,4 @@
+// Javascript for index page: mostly counters updating
 new Vue({
        el: "#indexPage",
        data: {
@@ -7,7 +8,11 @@ new Vue({
        },
        computed: {
                sortedCounts: function () {
-                       const variantsCounts = variantArray.map( v => {
+                       const variantsCounts = variantArray
+                       .filter( v => {
+                               return v.name.startsWith(this.curPrefix);
+                       })
+                       .map( v => {
                                return {
                                        name: v.name,
                                        desc: v.description,
@@ -72,6 +77,20 @@ new Vue({
                // Show welcome dialog box if "first visit"
                const visited = getCookie("visited");
                if (!visited || visited !== "1")
-                       document.getElementById("modal-welcome").checked = true;
+                       document.getElementById("modalB4welcome").checked = true;
+       },
+       methods: {
+               showWelcomeMsg: function() {
+                       document.getElementById("modalB4welcome").checked = false;
+                       document.getElementById("modalWelcome").checked = true;
+               },
+               markAsVisited: function() {
+                       setCookie('visited', '1');
+                       document.getElementById('modalWelcome').checked = false;
+               },
+               setLanguage: function(e) {
+                       setCookie("lang", e.target.value);
+                       location.reload(); //to include the right .pug file
+               },
        },
 });