From ea65dac594183d79673e1cdcc54291714caf063b Mon Sep 17 00:00:00 2001 From: e7d Date: Sun, 14 May 2017 11:32:59 +0200 Subject: [PATCH] improved color and zoom parameters reading --- js/gamepad.js | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/js/gamepad.js b/js/gamepad.js index 2a0f649..16b2bec 100644 --- a/js/gamepad.js +++ b/js/gamepad.js @@ -41,6 +41,12 @@ class Gamepad { window.addEventListener("keydown", this.onKeyDown.bind(this)); window.setInterval(this.scanGamepads.bind(this), this.scanGamepadsDelay); + + this.params = { + gamepadColor: $.urlParam('color') || $.urlParam('c') || null, + zoom: $.urlParam('zoom') || $.urlParam('z') || null + }; + this.displayGamepadHelp(); } @@ -177,18 +183,11 @@ class Gamepad { ).done((template) => { this.$gamepad.html(template); - if ($.urlParam('color')) { - this.changeGamepadColor($.urlParam('color')); + if (this.params.gamepadColor) { + this.changeGamepadColor(this.params.gamepadColor); } - if ($.urlParam('c')) { - this.changeGamepadColor($.urlParam('c')); - } - - if ($.urlParam('zoom')) { - this.changeZoom($.urlParam('zoom')); - } - if ($.urlParam('z')) { - this.changeZoom($.urlParam('z')); + if (this.params.zoom) { + this.changeZoom(this.params.zoom); } this.mapping.buttons = [];