From: Frédéric Péters Date: Wed, 22 Feb 2017 11:01:22 +0000 (+0100) Subject: allow selection of multiple files X-Git-Url: https://git.0d.be/?p=nanofun.git;a=commitdiff_plain;h=b5bfa95297fbfb901bda739b402d994db3ab9f39;ds=sidebyside allow selection of multiple files --- diff --git a/index.html b/index.html index d4cd50f..55897f2 100644 --- a/index.html +++ b/index.html @@ -14,7 +14,7 @@
- +
diff --git a/nanofun.js b/nanofun.js index 2a2a5df..a1c14b1 100644 --- a/nanofun.js +++ b/nanofun.js @@ -324,21 +324,27 @@ var nanofun = function() { } $('.nanotouch input[type=file]').on('change', function(ev) { - var nanotouch = $(this).parent(); - var sample_idx = $nanopad.children().index(nanotouch); - var reader = new FileReader(); - reader.onload = function(e) { - self.audioCtx.decodeAudioData(this.result, function(buffer) { - sample_buffers[sample_idx] = buffer; - $(nanotouch).find('span.duration').text(parseInt(buffer.duration) + 's'); - $(nanotouch).removeClass('error').addClass('loaded'); - }, function(e) { - $(nanotouch).find('span').text(''); - $(nanotouch).removeClass('loaded').addClass('error'); - }); + var sample_idx = parseInt($(this).parent().data('touch')); + for (var i=0; i