X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=public%2Fjavascripts%2Findex.js;h=13004f0edb5b21ac1273aa55fde4d5d9b9bf14de;hb=9a3c9f790aa28fd4708faefe41b4624173922c8e;hp=12bcf64450e3001717d9af98d482bcbd3f4daeed;hpb=ecf44502c1ed7c408b8ea4d1be5234203aa3d314;p=vchess.git diff --git a/public/javascripts/index.js b/public/javascripts/index.js index 12bcf644..13004f0e 100644 --- a/public/javascripts/index.js +++ b/public/javascripts/index.js @@ -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, @@ -24,8 +29,7 @@ new Vue({ }, created: function() { const url = socketUrl; - // random enough (TODO: function) - const sid = (Date.now().toString(36) + Math.random().toString(36).substr(2, 7)).toUpperCase(); + const sid = getRandString(); this.conn = new WebSocket(url + "/?sid=" + sid + "&page=index"); const socketMessageListener = msg => { const data = JSON.parse(msg.data); @@ -70,5 +74,23 @@ new Vue({ } // ...ignore everything else }; + // Show welcome dialog box if "first visit" + const visited = getCookie("visited"); + if (!visited || visited !== "1") + 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 + }, }, });