From 002863b88a6e5afa7c7985f54637cad6742f9424 Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Sun, 24 Dec 2017 20:36:39 +0000 Subject: [PATCH] don't change current palette when editing a different palette --- includes/script.js | 8 ++++++-- readme.md | 1 - 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/includes/script.js b/includes/script.js index 251e429..7669558 100644 --- a/includes/script.js +++ b/includes/script.js @@ -324,14 +324,18 @@ $(document).ready(function() { // these inputs get added and removed from the DOM so the event handler needs to be on the document $(document).on('change', '#palette input', function() { + var id = parseInt($(this).closest('.palette').find('input[name="id"]').val()); + // if this is a colour input, update the palette if ($(this).attr('type') === 'color') { - palette[$(this).attr('name')] = hexToColour($(this).val()); + if (id === palette.id) { + palette[$(this).attr('name')] = hexToColour($(this).val()); + } } // if this is a radio button, pick this palette if ($(this).attr('type') === 'radio') { - palette.id = parseInt( $(this).closest('.palette').find('input[name="id"]' ).val()); + palette.id = id; palette.background = hexToColour($(this).closest('.palette').find('input[name="background"]').val()); palette.tile = hexToColour($(this).closest('.palette').find('input[name="tile"]' ).val()); // sprite colour is not currently used diff --git a/readme.md b/readme.md index fcf4c62..6edfe06 100644 --- a/readme.md +++ b/readme.md @@ -41,7 +41,6 @@ if (src.match(/^(file|https)?:\/\/|^\/\//)) { ## known bugs * keyup on game data input sets palette to pal 0 even if game data has not changed -* changing the colour of a different palette will change the current palette ## to do