Improved error handling

This commit is contained in:
Tobias Reich 2014-08-16 19:51:21 +02:00
parent b19c472709
commit e9f1c21406
6 changed files with 57 additions and 43 deletions

View File

@ -118,4 +118,15 @@
.upload_message .rows .row a.status.success {
color: rgb(42, 213, 0);
}
}
.upload_message .rows .row p.notice {
display: none;
float: left;
padding: 2px 10px 5px;
width: calc(100% - 20px);
color: rgba(255,255,255,.5);
font-size: 12px;
overflow: hidden;
line-height: 16px;
}

View File

@ -220,21 +220,14 @@ build = {
if (files[i].name.length>40) files[i].name = files[i].name.substr(0, 17) + "..." + files[i].name.substr(files[i].name.length-20, 20);
if (files[i].supported===true) {
modal += "<div class='row'>";
modal += "<a class='name'>" + lychee.escapeHTML(files[i].name) + "</a>";
modal += "<div class='row'>"
modal += "<a class='name'>" + lychee.escapeHTML(files[i].name) + "</a>"
modal += "<a class='status'></a>"
modal += "</div>";
if (files[i].supported===true) modal += "<a class='status'></a>";
else modal += "<a class='status error'>Not supported</a>";
} else {
modal += "<div class='row'>"
modal += "<a class='name'>" + lychee.escapeHTML(files[i].name) + "</a>"
modal += "<a class='status error'>Not supported</a>"
modal += "</div>";
}
modal += "<p class='notice'></p>";
modal += "</div>";
}

View File

@ -69,6 +69,7 @@ upload = {
$("#upload_files").val("");
upload.close();
upload.notify("Upload complete");
if (album.getID()===false) lychee.goto("0");
else album.load(albumID);
@ -112,34 +113,43 @@ upload = {
xhr.onload = function() {
// On success
if (xhr.status===200) {
var wait = false;
var wait;
file.ready = true;
// Set status to finished
// Set status
if (xhr.status===200&&xhr.responseText==="1") {
// Success
$(".upload_message .rows .row:nth-child(" + (file.num+1) + ") .status")
.html("Finished")
.addClass("success");
file.ready = true;
wait = false;
} else {
// Check if there are file which are not finished
for (var i = 0; i < files.length; i++) {
if (files[i].ready===false) {
wait = true;
break;
}
}
// Finish upload when all files are finished
if (wait===false) finish();
// Error
$(".upload_message .rows .row:nth-child(" + (file.num+1) + ") .status")
.html("Error")
.addClass("error");
$(".upload_message .rows .row:nth-child(" + (file.num+1) + ") p.notice")
.html("Server returned the status code " + xhr.status)
.show();
}
// Check if there are file which are not finished
for (var i = 0; i < files.length; i++) {
if (files[i].ready===false) {
wait = true;
break;
}
}
// Finish upload when all files are finished
if (wait===false) finish();
};
xhr.upload.onprogress = function(e) {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long