From: Mikael Nordfeldth Date: Tue, 1 Mar 2016 17:20:50 +0000 (+0100) Subject: Iterate through input=file attachments (not multi yet) X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=e3431a2c91d3d4e9d9263b43cbfbdc15fb84f54d;p=quix0rs-gnu-social.git Iterate through input=file attachments (not multi yet) --- diff --git a/js/util.js b/js/util.js index 15bff959ee..b645e8b029 100644 --- a/js/util.js +++ b/js/util.js @@ -848,27 +848,29 @@ var SN = { // StatusNet NDA.change(function (event) { form.find('.attach-status').remove(); - var filename = $(this).val(); - if (!filename) { - // No file -- we've been tricked! - return false; - } - - var attachStatus = $('
'); - attachStatus.find('code').text(filename); - attachStatus.find('button').click(function () { - attachStatus.remove(); - NDA.val(''); - - return false; - }); - form.append(attachStatus); - if (typeof this.files === "object") { + var attachStatus = $(''); + form.append(attachStatus); // Some newer browsers will let us fetch the files for preview. for (i = 0; i < this.files.length; i++) { SN.U.PreviewAttach(form, this.files[i]); } + } else { + var filename = $(this).val(); + if (!filename) { + // No file -- we've been tricked! + return false; + } + + var attachStatus = $('
'); + attachStatus.find('code').text(filename); + attachStatus.find('button').click(function () { + attachStatus.remove(); + NDA.val(''); + + return false; + }); + form.append(attachStatus); } }); }, @@ -964,12 +966,15 @@ var SN = { // StatusNet if (preview) { blobAsDataURL(file, function (url) { + var fileentry = $('
  • '); + fileentry.append($('' + file.name + '')); var img = $('') .attr('title', tooltip) .attr('alt', tooltip) .attr('src', url) .attr('style', 'height: 120px'); - form.find('.attach-status').append(img); + fileentry.append(img); + form.find('.attach-status').append(fileentry); }); } else { var img = $('
    ').text(tooltip);