X-Git-Url: https://git.auder.net/assets/icon_infos.svg?a=blobdiff_plain;f=client%2Fsrc%2Fviews%2FHall.vue;h=f4fc172cd4ffdfadc8cd74fea58721ea8f9d2656;hb=e5a5d33164bcba11c1dc07555f327fa98b9db511;hp=4c73df229855abb3cc1cfd07002aeb4b2139d46c;hpb=f2adb3d08cbbb9fcaf81c7e3abc625073c37e2c7;p=vchess.git diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index 4c73df22..f4fc172c 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -280,6 +280,45 @@ export default { pages: [{ path: "/", focus: true }] } ); + const connectAndPoll = () => { + this.send("connect"); + this.send("pollclientsandgamers"); + }; + // Initialize connection + this.connexionString = + params.socketUrl + + "/?sid=" + + this.st.user.sid + + "&id=" + + this.st.user.id + + "&tmpId=" + + getRandString() + + "&page=" + + // Hall: path is "/" (could be hard-coded as well) + encodeURIComponent(this.$route.path); + this.conn = new WebSocket(this.connexionString); + this.conn.onopen = connectAndPoll; + this.conn.onmessage = this.socketMessageListener; + this.conn.onclose = this.socketCloseListener; + }, + mounted: function() { + document.addEventListener('visibilitychange', this.visibilityChange); + ["peopleWrap", "infoDiv", "newgameDiv"].forEach(eltName => { + document.getElementById(eltName) + .addEventListener("click", processModalClick); + }); + document.querySelectorAll("#predefinedCadences > button").forEach(b => { + b.addEventListener("click", () => { + this.newchallenge.cadence = b.innerHTML; + }); + }); + const dispCorr = this.$route.query["disp"]; + const showCtype = + dispCorr || localStorage.getItem("type-challenges") || "live"; + const showGtype = + dispCorr || localStorage.getItem("type-games") || "live"; + this.setDisplay('c', showCtype); + this.setDisplay('g', showGtype); // Ask server for current corr games (all but mines) ajax( "/games", @@ -287,6 +326,15 @@ export default { { data: { uid: this.st.user.id, excluded: true }, success: (response) => { + if ( + response.games.length > 0 && + this.games.length == 0 && + this.gdisplay == "live" + ) { + document + .getElementById("btnGcorr") + .classList.add("somethingnew"); + } this.games = this.games.concat( response.games.map(g => { const type = this.classifyObject(g); @@ -311,6 +359,15 @@ export default { { data: { uid: this.st.user.id }, success: (response) => { + if ( + response.challenges.length > 0 && + this.challenges.length == 0 && + this.cdisplay == "live" + ) { + document + .getElementById("btnCcorr") + .classList.add("somethingnew"); + } // Gather all senders names, and then retrieve full identity: // (TODO [perf]: some might be online...) let names = {}; @@ -357,45 +414,6 @@ export default { } } ); - const connectAndPoll = () => { - this.send("connect"); - this.send("pollclientsandgamers"); - }; - // Initialize connection - this.connexionString = - params.socketUrl + - "/?sid=" + - this.st.user.sid + - "&id=" + - this.st.user.id + - "&tmpId=" + - getRandString() + - "&page=" + - // Hall: path is "/" (could be hard-coded as well) - encodeURIComponent(this.$route.path); - this.conn = new WebSocket(this.connexionString); - this.conn.onopen = connectAndPoll; - this.conn.onmessage = this.socketMessageListener; - this.conn.onclose = this.socketCloseListener; - }, - mounted: function() { - document.addEventListener('visibilitychange', this.visibilityChange); - ["peopleWrap", "infoDiv", "newgameDiv"].forEach(eltName => { - document.getElementById(eltName) - .addEventListener("click", processModalClick); - }); - document.querySelectorAll("#predefinedCadences > button").forEach(b => { - b.addEventListener("click", () => { - this.newchallenge.cadence = b.innerHTML; - }); - }); - const dispCorr = this.$route.query["disp"]; - const showCtype = - dispCorr || localStorage.getItem("type-challenges") || "live"; - const showGtype = - dispCorr || localStorage.getItem("type-games") || "live"; - this.setDisplay("c", showCtype); - this.setDisplay("g", showGtype); }, beforeDestroy: function() { document.removeEventListener('visibilitychange', this.visibilityChange);