From: Benjamin Auder Date: Sat, 5 Dec 2020 23:16:44 +0000 (+0100) Subject: Update TODO + cosmetics X-Git-Url: https://git.auder.net/css/vendor/doc/current/gitweb.js?a=commitdiff_plain;h=937c24ab2871b31a7e531226603fc75acab7edb8;p=vchess.git Update TODO + cosmetics --- diff --git a/TODO b/TODO index 9ae357cd..09f538b9 100644 --- a/TODO +++ b/TODO @@ -1,3 +1,6 @@ +getRepetitionStatus() lose or draw... (for some variants) +Chakart: king remote capture, is an option if short range + WON'T IMPLEMENT: Simultaneous games: view Game + Simultaneous, using component (One)Game Storage: just key ID => IDs of actual games (in indexedDB) diff --git a/client/src/utils/array.js b/client/src/utils/array.js index d02552c1..3d7f7ae4 100644 --- a/client/src/utils/array.js +++ b/client/src/utils/array.js @@ -1,5 +1,6 @@ // Remove item(s) in array (if present) export const ArrayFun = { + remove: function(arr, rfun, all) { const index = arr.findIndex(rfun); if (index >= 0) { @@ -21,4 +22,5 @@ export const ArrayFun = { range: function(max) { return [...Array(max).keys()]; } + }; diff --git a/client/src/utils/compgameStorage.js b/client/src/utils/compgameStorage.js index 4f5181ef..c8463047 100644 --- a/client/src/utils/compgameStorage.js +++ b/client/src/utils/compgameStorage.js @@ -37,6 +37,7 @@ function dbOperation(callback) { } export const CompgameStorage = { + add: function(game) { dbOperation((err, db) => { if (err) return; @@ -90,4 +91,5 @@ export const CompgameStorage = { } }); } + }; diff --git a/client/src/utils/gameStorage.js b/client/src/utils/gameStorage.js index 6885ed15..3e3b6840 100644 --- a/client/src/utils/gameStorage.js +++ b/client/src/utils/gameStorage.js @@ -51,6 +51,7 @@ function dbOperation(callback) { } export const GameStorage = { + // Optional callback to get error status add: function(game, callback) { dbOperation((err, db) => { @@ -183,4 +184,5 @@ export const GameStorage = { } }); } + }; diff --git a/client/src/utils/importgameStorage.js b/client/src/utils/importgameStorage.js index 46a60bbb..bcda4fd2 100644 --- a/client/src/utils/importgameStorage.js +++ b/client/src/utils/importgameStorage.js @@ -33,6 +33,7 @@ function dbOperation(callback) { } export const ImportgameStorage = { + // Optional callback to get error status add: function(game, callback) { dbOperation((err, db) => { @@ -110,4 +111,5 @@ export const ImportgameStorage = { } }); } + }; diff --git a/server/config/parameters.js.dist b/server/config/parameters.js.dist index c0640cd6..9ba76182 100644 --- a/server/config/parameters.js.dist +++ b/server/config/parameters.js.dist @@ -1,4 +1,5 @@ module.exports = { + // For mail sending. NOTE: *no trailing slash* siteURL: "http://localhost:8080", @@ -33,4 +34,5 @@ module.exports = { // IDs of users allowed to post news and edit any problem devs: [] + }; diff --git a/server/models/Challenge.js b/server/models/Challenge.js index dea0ac39..a528ca67 100644 --- a/server/models/Challenge.js +++ b/server/models/Challenge.js @@ -14,6 +14,7 @@ const UserModel = require("./User"); */ const ChallengeModel = { + checkChallenge: function(c) { return ( c.vid.toString().match(/^[0-9]+$/) && @@ -76,7 +77,8 @@ const ChallengeModel = { ChallengeModel.remove(id); }); }); - }, -} + } + +}; module.exports = ChallengeModel; diff --git a/server/models/Game.js b/server/models/Game.js index 0d59d6e3..02ef2d16 100644 --- a/server/models/Game.js +++ b/server/models/Game.js @@ -34,8 +34,8 @@ const UserModel = require("./User"); * added: datetime */ -const GameModel = -{ +const GameModel = { + checkGameInfo: function(g) { return ( g.vid.toString().match(/^[0-9]+$/) && @@ -502,6 +502,7 @@ const GameModel = }); }); } -} + +}; module.exports = GameModel; diff --git a/server/models/Problem.js b/server/models/Problem.js index eef4270f..cc740067 100644 --- a/server/models/Problem.js +++ b/server/models/Problem.js @@ -12,6 +12,7 @@ const db = require("../utils/database"); */ const ProblemModel = { + checkProblem: function(p) { return ( p.id.toString().match(/^[0-9]+$/) && @@ -88,7 +89,8 @@ const ProblemModel = { whereClause; db.run(query); }); - }, -} + } + +}; module.exports = ProblemModel; diff --git a/server/models/User.js b/server/models/User.js index 6a070e25..ebda4c32 100644 --- a/server/models/User.js +++ b/server/models/User.js @@ -17,6 +17,7 @@ const sendEmail = require('../utils/mailer'); */ const UserModel = { + checkNameEmail: function(o) { return ( (!o.name || !!(o.name.match(/^[\w-]+$/))) && @@ -177,7 +178,8 @@ const UserModel = { } }); }); - }, -} + } + +}; module.exports = UserModel; diff --git a/server/models/Variant.js b/server/models/Variant.js index 85abf5ae..d01d2a27 100644 --- a/server/models/Variant.js +++ b/server/models/Variant.js @@ -8,6 +8,7 @@ const db = require("../utils/database"); */ const VariantModel = { + getAll: function(callback) { db.serialize(function() { const query = @@ -15,9 +16,10 @@ const VariantModel = { "FROM Variants"; db.all(query, callback); }); - }, + } //create, update, delete: directly in DB -} + +}; module.exports = VariantModel; diff --git a/server/utils/access.js b/server/utils/access.js index bf6430ca..88aab68c 100644 --- a/server/utils/access.js +++ b/server/utils/access.js @@ -1,6 +1,7 @@ var UserModel = require("../models/User"); module.exports = { + // Prevent access to "users pages" logged: function(req, res, next) { const callback = () => { @@ -55,4 +56,5 @@ module.exports = { res.json({ errmsg: msg }); } else cb(); } + };