From 4d6c2b2ca47bfc184e9d0ec43a2d05e08425a57f Mon Sep 17 00:00:00 2001 From: Tobias Reich Date: Sat, 16 Aug 2014 20:44:11 +0200 Subject: [PATCH] Don't close upload when an error occurred #203 --- assets/js/upload.js | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/assets/js/upload.js b/assets/js/upload.js index 70a5e6c..51d6066 100755 --- a/assets/js/upload.js +++ b/assets/js/upload.js @@ -36,16 +36,18 @@ upload = { }, - notify: function(title) { + notify: function(title, text) { var popup; + if (!text||text==="") text = "You can now manage your new photo(s)."; + if (!window.webkitNotifications) return false; if (window.webkitNotifications.checkPermission()!==0) window.webkitNotifications.requestPermission(); if (window.webkitNotifications.checkPermission()===0&&title) { - popup = window.webkitNotifications.createNotification("", title, "You can now manage your new photo(s)."); + popup = window.webkitNotifications.createNotification("", title, text); popup.show(); } @@ -56,6 +58,7 @@ upload = { local: function(files) { var albumID = album.getID(), + error = false, process = function(files, file) { var formData = new FormData(), @@ -68,8 +71,19 @@ upload = { $("#upload_files").val(""); - upload.close(); - upload.notify("Upload complete"); + if (error===false) { + + // Success + upload.close(); + upload.notify("Upload complete"); + + } else { + + // Error + $(".upload_message a.close").show(); + upload.notify("Upload complete", "Failed to upload one or more photos."); + + } if (album.getID()===false) lychee.goto("0"); else album.load(albumID); @@ -135,6 +149,9 @@ upload = { .html("Server returned the status code " + xhr.status) .show(); + // Set global error + error = true; + // Throw error lychee.error("Upload failed. Server returned the status code " + xhr.status + "!", xhr, xhr.responseText);