From: Benjamin Auder Date: Sat, 9 May 2020 14:04:55 +0000 (+0200) Subject: Unused code, style (cosmetics) X-Git-Url: https://git.auder.net/doc/html/vendor/pieces/%7B%7B%20targetUrl%20%7D%7D?a=commitdiff_plain;h=58aedcd1f49272a6f0dfb7adeeb7650d7daeb75e;p=vchess.git Unused code, style (cosmetics) --- diff --git a/client/src/store.js b/client/src/store.js index fa363a38..0bfeeebb 100644 --- a/client/src/store.js +++ b/client/src/store.js @@ -12,7 +12,6 @@ export const store = { settings: {}, lang: "" }, - socketCloseListener: null, initialize() { const headers = { "Content-Type": "application/json;charset=UTF-8", @@ -97,7 +96,7 @@ export const store = { // 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"); diff --git a/client/src/translations/en.js b/client/src/translations/en.js index 0d1f0b94..285b698a 100644 --- a/client/src/translations/en.js +++ b/client/src/translations/en.js @@ -36,7 +36,6 @@ export const translations = { "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", @@ -79,7 +78,6 @@ export const translations = { "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", diff --git a/client/src/translations/es.js b/client/src/translations/es.js index d7fef9b1..67d6a527 100644 --- a/client/src/translations/es.js +++ b/client/src/translations/es.js @@ -36,7 +36,6 @@ export const translations = { "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", @@ -79,7 +78,6 @@ export const translations = { "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", diff --git a/client/src/translations/fr.js b/client/src/translations/fr.js index d66ba0b4..73ff2526 100644 --- a/client/src/translations/fr.js +++ b/client/src/translations/fr.js @@ -36,7 +36,6 @@ export const translations = { "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", @@ -79,7 +78,6 @@ export const translations = { "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", diff --git a/client/src/views/Game.vue b/client/src/views/Game.vue index 075919db..4afac12d 100644 --- a/client/src/views/Game.vue +++ b/client/src/views/Game.vue @@ -256,7 +256,8 @@ export default { // 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"] || "[]"); } diff --git a/server/models/Game.js b/server/models/Game.js index 1d2cd684..0d59d6e3 100644 --- a/server/models/Game.js +++ b/server/models/Game.js @@ -381,8 +381,10 @@ const GameModel = "(" + 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 @@ -399,14 +401,16 @@ const GameModel = } } }); - } 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 " + diff --git a/server/routes/users.js b/server/routes/users.js index a3fa7061..7d886b2c 100644 --- a/server/routes/users.js +++ b/server/routes/users.js @@ -34,19 +34,19 @@ router.post('/register', access.unlogged, access.ajax, (req,res) => { 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({}); @@ -85,7 +85,7 @@ router.get("/users", access.ajax, (req,res) => { // NOTE: slightly too permissive RegExp if (ids.match(/^([0-9]+,?)+$/)) { UserModel.getByIds(ids, (err, users) => { - res.json({ users:users }); + res.json({ users: users }); }); } }); @@ -93,7 +93,7 @@ router.get("/users", access.ajax, (req,res) => { 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, @@ -125,7 +125,7 @@ function setAndSendLoginToken(subject, to, res) { 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); @@ -137,12 +137,12 @@ router.get('/sendtoken', access.unlogged, access.ajax, (req,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) => { @@ -155,7 +155,7 @@ router.get('/authenticate', access.unlogged, access.ajax, (req,res) => { id: user.id, name: user.name, email: user.email, - notify: user.notify, + notify: user.notify }); }); } diff --git a/server/routes/variants.js b/server/routes/variants.js index 3f7417e3..6e0e3af1 100644 --- a/server/routes/variants.js +++ b/server/routes/variants.js @@ -6,7 +6,7 @@ const access = require("../utils/access"); router.get('/variants', access.ajax, function(req, res) { VariantModel.getAll((err,variants) => { - res.json(err || {variantArray:variants}); + res.json(err || { variantArray:variants }); }); }); diff --git a/server/sockets.js b/server/sockets.js index 3a776d1d..9fa09bce 100644 --- a/server/sockets.js +++ b/server/sockets.js @@ -1,7 +1,4 @@ -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 = {};