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
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 = "";
}
}
},
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() {
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;
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 = "";
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)
.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"
},
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)));
}
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)
main
input#modalNewprob.modal(
type="checkbox"
- @change="infoMsg=''"
+ @change="fenFocusIfOpened($event)"
)
div#newprobDiv(
role="dialog"
}
},
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;
},
)
.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 }}
},
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
+ };
+ },
}
};
</script>
.description
@media screen and (max-width: 767px)
margin-top: 0
+
+.last-noneighb
+ margin: 0 auto
</style>
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;
// 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();
},