From 08637b9ea98b63612f419f580a091d40798a76a1 Mon Sep 17 00:00:00 2001 From: Bobby Wibowo Date: Thu, 26 Apr 2018 13:51:17 +0700 Subject: fixed "add to album" error on uploads (#92) * Updates Fixed the way error when adding album is being handled. * I guess that sounds about right. --- public/js/home.js | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'public/js') diff --git a/public/js/home.js b/public/js/home.js index 383e245..771244a 100644 --- a/public/js/home.js +++ b/public/js/home.js @@ -155,20 +155,21 @@ upload.prepareDropzone = function(){ // Handle the responseText here. For example, add the text to the preview element: - if(response.success === false){ - var span = document.createElement('span'); - span.innerHTML = response.description; - file.previewTemplate.querySelector('.link').appendChild(span); - return; + if (response.success === false) { + var p = document.createElement('p'); + p.innerHTML = response.description; + file.previewTemplate.querySelector('.link').appendChild(p); } - a = document.createElement('a'); - a.href = response.files[0].url; - a.target = '_blank'; - a.innerHTML = response.files[0].url; - file.previewTemplate.querySelector('.link').appendChild(a); - - file.previewTemplate.querySelector('.progress').style.display = 'none'; + if (response.files[0].url) { + a = document.createElement('a'); + a.href = response.files[0].url; + a.target = '_blank'; + a.innerHTML = response.files[0].url; + file.previewTemplate.querySelector('.link').appendChild(a); + + file.previewTemplate.querySelector('.progress').style.display = 'none'; + } }); -- cgit v1.2.3