From a278c9931654b0d16d286e473813f3d4703289c1 Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Sat, 3 Mar 2018 14:40:57 +0000 Subject: [PATCH] fix game data upload button :| add padding to bottom of sections properly --- includes/script.js | 33 +++++++++++++++++++++++++-------- includes/style.css | 1 + 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/includes/script.js b/includes/script.js index 91cba22..0521e57 100644 --- a/includes/script.js +++ b/includes/script.js @@ -217,21 +217,26 @@ $(document).ready(function() { $('input[name="id"][value="' + palette.id + '"]').siblings(':radio').trigger('click'); } - function readFile(input) { + function readFile(input, callback) { if (input.files && input.files[0]) { var reader = new FileReader(); - reader.onload = function (e) { - $croppie.croppie('bind', { - url: e.target.result, - zoom: 0 - }); - }; + reader.onload = callback; reader.readAsDataURL(input.files[0]); } } + function readTextFile(input, callback) { + if (input.files && input.files[0]) { + var reader = new FileReader(); + + reader.onload = callback; + + reader.readAsText(input.files[0]); + } + } + function render() { $croppie.croppie('result', { type: 'rawcanvas', @@ -424,7 +429,19 @@ $(document).ready(function() { handleBitsyGameData(); $('#imageUpload').on('change', function () { - readFile(this); + readFile(this, function (e) { + $croppie.croppie('bind', { + url: e.target.result, + zoom: 0 + }); + }); + }); + + $('input.game-data').on('change', function() { + readTextFile(this, function (e) { + $bitsyData.val(e.target.result); + handleBitsyGameData(); + }); }); // these inputs get added and removed from the DOM so the event handler needs to be on the document diff --git a/includes/style.css b/includes/style.css index ada7461..bdeafe2 100644 --- a/includes/style.css +++ b/includes/style.css @@ -84,6 +84,7 @@ input { background-color: #d3cbd0; color: #594a54; width: 256px; + padding-bottom: 1em; } #brightness { width: 256px;