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