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