From: Benjamin Auder Date: Sat, 29 Feb 2020 16:43:51 +0000 (+0100) Subject: Fixes X-Git-Url: https://git.auder.net/%7B%7B%20asset%28%27mixstore/css/static/doc/html/index.html?a=commitdiff_plain;h=09d375717c256a2cbd71a5d3b3a4e21aee17c0ec;p=vchess.git Fixes --- diff --git a/client/src/components/UpsertUser.vue b/client/src/components/UpsertUser.vue index 50b702da..ac15324c 100644 --- a/client/src/components/UpsertUser.vue +++ b/client/src/components/UpsertUser.vue @@ -14,22 +14,22 @@ div div(@keyup.enter="onSubmit()") div(v-show="stage!='Login'") fieldset - label(for="username") {{ st.tr["User name"] }} - input#username( + label(for="u_username") {{ st.tr["User name"] }} + input#u_username( type="text" - v-model="st.user.name" + v-model="user.name" ) fieldset - label(for="useremail") {{ st.tr["Email"] }} - input#useremail( + label(for="u_useremail") {{ st.tr["Email"] }} + input#u_useremail( type="email" - v-model="st.user.email" + v-model="user.email" ) fieldset label(for="notifyNew") {{ st.tr["Notifications by email"] }} input#notifyNew( type="checkbox" - v-model="st.user.notify" + v-model="user.notify" ) div(v-show="stage=='Login'") fieldset @@ -67,17 +67,18 @@ export default { logStage: "Login", //or Register infoMsg: "", enterTime: Number.MAX_SAFE_INTEGER, //for a basic anti-bot strategy - st: store.state + st: store.state, + user: {} }; }, watch: { nameOrEmail: function(newValue) { if (newValue.indexOf("@") >= 0) { - this.st.user.email = newValue; - this.st.user.name = ""; + this.user.email = newValue; + this.user.name = ""; } else { - this.st.user.name = newValue; - this.st.user.email = ""; + this.user.name = newValue; + this.user.email = ""; } } }, @@ -102,6 +103,12 @@ export default { if (event.target.checked) { this.infoMsg = ""; this.enterTime = Date.now(); + document.getElementById("u_username").focus(); + this.user = { + name: this.st.user.name, + email: this.st.user.email, + notify: this.st.user.notify + }; } }, toggleStage: function() { @@ -149,7 +156,7 @@ export default { if (this.stage == "Login") { const type = this.nameOrEmail.indexOf("@") >= 0 ? "email" : "name"; error = checkNameEmail({ [type]: this.nameOrEmail }); - } else error = checkNameEmail(this.st.user); + } else error = checkNameEmail(this.user); if (error) { alert(this.st.tr[error]); return; @@ -160,10 +167,15 @@ export default { this.ajaxMethod(), this.stage == "Login" ? { nameOrEmail: this.nameOrEmail } - : this.st.user, + : this.user, () => { this.infoMsg = this.infoMessage(); if (this.stage != "Update") this.nameOrEmail = ""; + else { + this.st.user.name = this.user.name; + this.st.user.email = this.user.email; + this.st.user.notify = this.user.notify; + } }, err => { this.infoMsg = ""; diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 709cccc4..1675c30b 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -248,12 +248,12 @@ export default { break; case "killed": // I logged in elsewhere: - alert(this.st.tr["New connexion detected: tab now offline"]); // TODO: this fails. See https://github.com/websockets/ws/issues/489 //this.conn.removeEventListener("message", this.socketMessageListener); //this.conn.removeEventListener("close", this.socketCloseListener); //this.conn.close(); this.conn = null; + alert(this.st.tr["New connexion detected: tab now offline"]); break; case "askidentity": { // Request for identification (TODO: anonymous shouldn't need to reply) diff --git a/client/src/views/Hall.vue b/client/src/views/Hall.vue index 7a7f911b..5ceb7e32 100644 --- a/client/src/views/Hall.vue +++ b/client/src/views/Hall.vue @@ -19,7 +19,10 @@ main .button-group#buttonsTchall button.acceptBtn(@click="decisionChallenge(true)") {{ st.tr["Accept challenge?"] }} button.refuseBtn(@click="decisionChallenge(false)") {{ st.tr["Refuse"] }} - input#modalNewgame.modal(type="checkbox") + input#modalNewgame.modal( + type="checkbox" + @change="cadenceFocusIfOpened($event)" + ) div#newgameDiv( role="dialog" data-checkbox="modalNewgame" @@ -316,6 +319,10 @@ export default { }, methods: { // Helpers: + cadenceFocusIfOpened: function() { + if (event.target.checked) + document.getElementById("cadence").focus(); + }, send: function(code, obj) { if (this.conn) { this.conn.send(JSON.stringify(Object.assign({ code: code }, obj))); @@ -479,12 +486,12 @@ export default { } case "killed": // I logged in elsewhere: - alert(this.st.tr["New connexion detected: tab now offline"]); // TODO: this fails. See https://github.com/websockets/ws/issues/489 //this.conn.removeEventListener("message", this.socketMessageListener); //this.conn.removeEventListener("close", this.socketCloseListener); //this.conn.close(); this.conn = null; + alert(this.st.tr["New connexion detected: tab now offline"]); break; case "askidentity": { // Request for identification (TODO: anonymous shouldn't need to reply) diff --git a/client/src/views/Problems.vue b/client/src/views/Problems.vue index 2d6ac692..7621fe35 100644 --- a/client/src/views/Problems.vue +++ b/client/src/views/Problems.vue @@ -2,7 +2,7 @@ main input#modalNewprob.modal( type="checkbox" - @change="infoMsg=''" + @change="fenFocusIfOpened($event)" ) div#newprobDiv( role="dialog" @@ -193,6 +193,12 @@ export default { } }, methods: { + fenFocusIfOpened: function(event) { + if (event.target.checked) { + this.infoMsg = ""; + document.getElementById("inputFen").focus(); + } + }, setVname: function(prob) { prob.vname = this.st.variants.find(v => v.id == prob.vid).name; }, diff --git a/client/src/views/Variants.vue b/client/src/views/Variants.vue index 3fccae59..2a3f6cf0 100644 --- a/client/src/views/Variants.vue +++ b/client/src/views/Variants.vue @@ -9,7 +9,7 @@ main ) .variant.col-sm-12.col-md-5.col-lg-4( v-for="(v,idx) in filteredVariants" - :class="{'col-md-offset-1': idx%2==0, 'col-lg-offset-2': idx%2==0}" + :class="getVclasses(filteredVariants, idx)" ) router-link(:to="getLink(v.name)") h4.boxtitle.text-center {{ v.name }} @@ -54,7 +54,15 @@ export default { }, getLink: function(vname) { return "/variants/" + vname; - } + }, + getVclasses: function(varray, idx) { + const idxMod2 = idx % 2; + return { + 'col-md-offset-1': idxMod2 == 0, + 'col-lg-offset-2': idxMod2 == 0, + 'last-noneighb': idxMod2 == 0 && idx == varray.length - 1 + }; + }, } }; @@ -79,4 +87,7 @@ input#prefixFilter .description @media screen and (max-width: 767px) margin-top: 0 + +.last-noneighb + margin: 0 auto diff --git a/server/utils/access.js b/server/utils/access.js index 049e9eb6..df86b756 100644 --- a/server/utils/access.js +++ b/server/utils/access.js @@ -6,7 +6,7 @@ module.exports = logged: function(req, res, next) { const callback = () => { if (!loggedIn) - res.json({errmsg: "Not logged in"}); + res.json({errmsg: "Error: please delete cookies and cross fingers"}); else next(); }; let loggedIn = undefined; @@ -40,7 +40,7 @@ module.exports = // Just a quick heuristic, which should be enough const loggedIn = !!req.cookies.token; if (loggedIn) - res.json({errmsg: "Already logged in"}); + res.json({errmsg: "Error: please delete cookies and cross fingers"}); else next(); },