From e9a0ece5eb81af0e740985b78936d8131f3897b6 Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Fri, 22 Dec 2017 19:45:33 +0000 Subject: [PATCH] allow user to select palettes --- script.js | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/script.js b/script.js index 350a79f..8263c75 100644 --- a/script.js +++ b/script.js @@ -115,11 +115,11 @@ $(document).ready(function() { _.each(bitsyData.palettes, function(palette, name) { $('#palette tbody').append( '' - + '' - + '' + + '' + + '' + '' + '' - + '' + + '' + '' ); }); @@ -188,6 +188,8 @@ $(document).ready(function() { $('#bitsy-data').on('change blur keyup', handleBitsyGameData); + handleBitsyGameData(); + $('#imageUpload').on('change', function () { readFile(this); }); @@ -195,13 +197,15 @@ $(document).ready(function() { $('#palette input').on('change', function() { // if this is a colour input, update the palette if ($(this).attr('type') === 'color') { - console.debug(palette); palette[$(this).attr('name')] = hexToColour($(this).val()); - console.debug(palette); - - renderResult(); } // if this is a radio button, pick this palette + if ($(this).attr('type') === 'radio') { + palette.background = hexToColour($(this).closest('.palette').find('input[type="color"][name="background"]').val()); + palette.tile = hexToColour($(this).closest('.palette').find('input[type="color"][name="tile"]').val()); + } + + renderResult(); }); }); \ No newline at end of file