From: Benjamin Auder Date: Fri, 3 Dec 2021 07:12:32 +0000 (+0100) Subject: Fix 'undefined C' issue X-Git-Url: https://git.auder.net/images/assets/img/%7B%7B%20targetUrl%20%7D%7D?a=commitdiff_plain;h=e5f9342704d2a453c3cd2f84e31b1ea384b2d03d;p=xogo.git Fix 'undefined C' issue --- diff --git a/app.js b/app.js index d871940..a6ee234 100644 --- a/app.js +++ b/app.js @@ -103,6 +103,7 @@ function showNewGameForm() { toggleVisible("newGameForm"); import(`/variants/${vname}/class.js`).then(module => { window.V = module.default; + V.Aliases.forEach(e => window[e.key] = e.val); prepareOptions(); }); } @@ -447,6 +448,7 @@ function initializeGame(obj) { const options = obj.options || {}; import(`/variants/${obj.vname}/class.js`).then(module => { window.V = module.default; + V.Aliases.forEach(e => window[e.key] = e.val); // Load CSS. Avoid loading twice the same stylesheet: const allIds = [].slice.call($.styleSheets).map(s => s.id); const newId = obj.vname + "_css"; diff --git a/base_rules.js b/base_rules.js index 9100173..9444e7b 100644 --- a/base_rules.js +++ b/base_rules.js @@ -7,6 +7,10 @@ import Move from "/utils/Move.js"; // NOTE: ChessRules is aliased as window.C, and variants as window.V export default class ChessRules { + static get Aliases() { + return [{'C': ChessRules}]; + } + ///////////////////////// // VARIANT SPECIFICATIONS @@ -380,8 +384,6 @@ export default class ChessRules { // Fen string fully describes the game state constructor(o) { - window.C = ChessRules; //easier alias - this.options = o.options; this.playerColor = o.color; this.afterPlay = o.afterPlay; diff --git a/common.css b/common.css index d1a1311..c65559d 100644 --- a/common.css +++ b/common.css @@ -151,7 +151,7 @@ button:hover, button.block-btn:hover { button.block-btn { display: block; background-color: #01786F; - margin: 0 auto 20px auto; + margin: 0 auto 20px auto; /*TODO: margin-bottom 30px ? */ font-size: 2rem; padding: 15px 32px; }