settings: {},
lang: ""
},
- socketCloseListener: null,
initialize() {
const headers = {
"Content-Type": "application/json;charset=UTF-8",
// Default: random asymmetric
this.state.settings.randomness = 2;
const supportedLangs = ["en", "es", "fr"];
- const navLanguage = navigator.language.substr(0,2);
+ const navLanguage = navigator.language.substr(0, 2);
this.state.lang =
localStorage["lang"] ||
(supportedLangs.includes(navLanguage) ? navLanguage : "en");
"Database error: stop private browsing, or update your browser": "Database error: stop private browsing, or update your browser",
Delete: "Delete",
Deterministic: "Deterministic",
- "Discord invitation": "Discord invitation",
Download: "Download",
Draw: "Draw",
"Draw offer only in your turn": "Draw offer only in your turn",
"Name or Email": "Name or Email",
Next_p: "Next",
Next_g: "Next",
- Next_n: "Next",
"New connexion detected: tab now offline": "New connexion detected: tab now offline",
"New correspondance game:": "New correspondance game:",
"New game": "New game",
"Database error: stop private browsing, or update your browser": "Error de la base de datos: detener la navegación privada, o actualizar su navegador",
Delete: "Borrar",
Deterministic: "Determinista",
- "Discord invitation": "Invitación Discord",
Download: "Descargar",
Draw: "Tablas",
"Draw offer only in your turn": "Oferta de tablas solo en tu turno",
"Name or Email": "Nombre o Email",
Next_p: "Siguiente",
Next_g: "Siguiente",
- Next_n: "Siguiente",
"New connexion detected: tab now offline": "Nueva conexión detectada: pestaña ahora desconectada",
"New correspondance game:": "Nueva partida por correspondencia:",
"New game": "Nueva partida",
"Database error: stop private browsing, or update your browser": "Erreur de base de données : arrêtez la navigation privée, ou mettez à jour votre navigateur",
Delete: "Supprimer",
Deterministic: "Déterministe",
- "Discord invitation": "Invitation Discord",
Download: "Télécharger",
Draw: "Nulle",
"Draw offer only in your turn": "Proposition de nulle seulement sur votre temps",
"Name or Email": "Nom ou Email",
Next_p: "Suivant",
Next_g: "Suivante",
- Next_n: "Suivante",
"New connexion detected: tab now offline": "Nouvelle connexion détectée : onglet désormais hors ligne",
"New correspondance game:": "Nouvelle partie par corespondance :",
"New game": "Nouvelle partie",
// In case of incomplete information variant:
boardDiv.style.visibility = "hidden";
this.atCreation();
- } else
+ }
+ else
// Same game ID
this.nextIds = JSON.parse(this.$route.query["next"] || "[]");
}
"(" + id + ",?," + Date.now() + "," + obj.move.idx + ")";
db.run(query, JSON.stringify(obj.move.squares));
finishAndSendQuery();
- } else cb({ errmsg: "Wrong move index" });
- } else {
+ }
+ else cb({ errmsg: "Wrong move index" });
+ }
+ else {
if (ret.maxIdx < 2) cb({ errmsg: "Time not over" });
else {
// We also need the game cadence
}
}
});
- } else finishAndSendQuery();
+ }
+ else finishAndSendQuery();
// NOTE: chat and delchat are mutually exclusive
if (!!obj.chat) {
const query =
"INSERT INTO Chats (gid, msg, name, added) VALUES ("
+ id + ",?,'" + obj.chat.name + "'," + Date.now() + ")";
db.run(query, obj.chat.msg);
- } else if (obj.delchat) {
+ }
+ else if (obj.delchat) {
const query =
"DELETE " +
"FROM Chats " +
const name = req.body.name;
const email = req.body.email;
const notify = !!req.body.notify;
- if (UserModel.checkNameEmail({name: name, email: email})) {
+ if (UserModel.checkNameEmail({ name: name, email: email })) {
UserModel.create(name, email, notify, (err, ret) => {
if (!!err) {
const msg = err.code == "SQLITE_CONSTRAINT"
? "User name or email already in use"
: "User creation failed. Try again";
- res.json({errmsg: msg});
+ res.json({ errmsg: msg });
}
else {
const user = {
id: ret.id,
name: name,
- email: email,
+ email: email
};
setAndSendLoginToken("Welcome to " + params.siteURL, user, res);
res.json({});
// NOTE: slightly too permissive RegExp
if (ids.match(/^([0-9]+,?)+$/)) {
UserModel.getByIds(ids, (err, users) => {
- res.json({ users:users });
+ res.json({ users: users });
});
}
});
router.put('/update', access.logged, access.ajax, (req,res) => {
const name = req.body.name;
const email = req.body.email;
- if (UserModel.checkNameEmail({name: name, email: email})) {
+ if (UserModel.checkNameEmail({ name: name, email: email })) {
const user = {
id: req.userId,
name: name,
router.get('/sendtoken', access.unlogged, access.ajax, (req,res) => {
const nameOrEmail = decodeURIComponent(req.query.nameOrEmail);
const type = (nameOrEmail.indexOf('@') >= 0 ? "email" : "name");
- if (UserModel.checkNameEmail({[type]: nameOrEmail})) {
+ if (UserModel.checkNameEmail({ [type]: nameOrEmail })) {
UserModel.getOne(type, nameOrEmail, (err,user) => {
access.checkRequest(res, err, user, "Unknown user", () => {
setAndSendLoginToken("Token for " + params.siteURL, user, res);
router.get('/authenticate', access.unlogged, access.ajax, (req,res) => {
if (!req.query.token.match(/^[a-z0-9]+$/))
- return res.json({errmsg: "Bad token"});
+ return res.json({ errmsg: "Bad token" });
UserModel.getOne("loginToken", req.query.token, (err,user) => {
access.checkRequest(res, err, user, "Invalid token", () => {
// If token older than params.tokenExpire, do nothing
if (Date.now() > user.loginTime + params.token.expire)
- res.json({errmsg: "Token expired"});
+ res.json({ errmsg: "Token expired" });
else {
// Generate session token (if not exists) + destroy login token
UserModel.trySetSessionToken(user.id, (token) => {
id: user.id,
name: user.name,
email: user.email,
- notify: user.notify,
+ notify: user.notify
});
});
}
router.get('/variants', access.ajax, function(req, res) {
VariantModel.getAll((err,variants) => {
- res.json(err || {variantArray:variants});
+ res.json(err || { variantArray:variants });
});
});
-const url = require('url');
-
// Node version in Ubuntu 16.04 does not know about URL class
-// NOTE: url is already transformed, without ?xxx=yyy... parts
function getJsonFromUrl(url) {
const query = url.substr(2); //starts with "/?"
let result = {};