added color selection from uri

This commit is contained in:
e7d 2016-09-14 00:14:44 +02:00
parent 0a59840516
commit 3358782f55

View File

@ -115,6 +115,10 @@ function mapGamepad(gamepad) {
).done(function(template) { ).done(function(template) {
$gamepad.html(template); $gamepad.html(template);
if ($.urlParam('color')) {
changeGamepadColor($.urlParam('color'));
}
mapping.buttons = []; mapping.buttons = [];
for (var buttonIndex = 0; buttonIndex < gamepad.buttons.length; buttonIndex++) { for (var buttonIndex = 0; buttonIndex < gamepad.buttons.length; buttonIndex++) {
button = gamepad.buttons[buttonIndex]; button = gamepad.buttons[buttonIndex];
@ -189,10 +193,15 @@ function updateVisualStatus() {
requestAnimationFrame(updateVisualStatus); requestAnimationFrame(updateVisualStatus);
} }
function changeGamepadColor() { function changeGamepadColor(gamepadColor) {
activeGamepadColor++; if (!! gamepadColor) {
if (activeGamepadColor > activeGamepadIdentifier.colors.length - 1) { activeGamepadColor = gamepadColor;
activeGamepadColor = 0; } else {
activeGamepadColor++;
if (activeGamepadColor > activeGamepadIdentifier.colors.length - 1) {
activeGamepadColor = 0;
}
} }
$gamepad.attr('data-color', activeGamepadIdentifier.colors[activeGamepadColor]); $gamepad.attr('data-color', activeGamepadIdentifier.colors[activeGamepadColor]);