X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=client%2Fclient_OLD%2Fjavascripts%2Findex.js;fp=client%2Fclient_OLD%2Fjavascripts%2Findex.js;h=0000000000000000000000000000000000000000;hb=ee37e2af8fc3ce2273eddfbe66822ce8b6b011d6;hp=0e2a2631dde814d5b701ac4c3620de49ed81895b;hpb=590b75f9860a539d11906521fd25cacad05ab0a8;p=vchess.git diff --git a/client/client_OLD/javascripts/index.js b/client/client_OLD/javascripts/index.js deleted file mode 100644 index 0e2a2631..00000000 --- a/client/client_OLD/javascripts/index.js +++ /dev/null @@ -1,70 +0,0 @@ -// Javascript for index page: mostly counters updating -new Vue({ - el: "#VueElement", - data: { - counts: {}, - curPrefix: "", - conn: null, - display: "variants", - }, - computed: { - sortedCounts: function () { - const capitalizedPrefix = this.curPrefix.replace(/^\w/, c => c.toUpperCase()); - const variantsCounts = variantArray - .filter( v => { - return v.name.startsWith(capitalizedPrefix); - }) - .map( v => { - return { - name: v.name, - desc: v.description, - count: this.counts[v.name] || 0, - }; - }); - return variantsCounts.sort((a,b) => { - if (a.count != b.count) - return b.count - a.count; - // Else, alphabetic ordering - return a.name.localeCompare(b.name); - }); - }, - }, - created: function() { - this.setDisplay(); - window.onhashchange = this.setDisplay; - - const url = socketUrl; - const sid = getRandString(); - this.conn = new WebSocket(url + "/?sid=" + sid + "&page=index"); - const socketMessageListener = msg => { - const data = JSON.parse(msg.data); - if (data.code == "counts") - this.counts = data.counts; - else if (data.code == "increase") - this.counts[data.vid]++; - else if (data.code == "decrease") - this.counts[data.vid]--; - }; - const socketCloseListener = () => { - this.conn = new WebSocket(url + "/?sid=" + sid + "&page=index"); - this.conn.addEventListener('message', socketMessageListener); - this.conn.addEventListener('close', socketCloseListener); - }; - this.conn.onmessage = socketMessageListener; - this.conn.onclose = socketCloseListener; - - // TODO: AJAX call get corr games (all variants) - // si dernier lastMove sur serveur n'est pas le mien et nextColor == moi, alors background orange - // ==> background orange si à moi de jouer par corr (sur main index) - // (helper: static fonction "GetNextCol()" dans base_rules.js) - - }, - methods: { - setDisplay: function() { - if (!location.hash) - location.hash = "#variants"; //default - this.display = location.hash.substr(1); - }, - - }, -});