Removed support for old uploader and fixed URL import

This commit is contained in:
Tobias Reich 2014-05-12 21:40:25 +02:00
parent 21d8b22a3a
commit 47afc5c74b
2 changed files with 94 additions and 95 deletions

View File

@ -197,38 +197,41 @@ build = {
},
uploadModal: function(icon, text, html) {
uploadModal: function(title, files) {
var modal = "";
if (html!==null||html!==undefined) {
modal += "<div class='upload_overlay fadeIn'>";
modal += "<div class='upload_message center'>";
modal += "<h1>" + text + "</h1>";
modal += "<a class='close icon-remove-sign'></a>";
modal += html;
modal += "</div>";
modal += "</div>";
modal += "<h1>" + title + "</h1>";
modal += "<div class='rows'>";
return modal;
for (var i = 0; i < files.length; i++) {
if (files[i].supported===true) {
modal += "<div class='row'>"
modal += "<a class='name'>" + lychee.escapeHTML(files[i].name) + "</a>"
modal += "<a class='status'></a>"
modal += "</div>";
} else {
modal += "<div class='upload_overlay fadeIn'>";
modal += "<div class='upload_message center'>";
modal += "<a class='icon-" + icon + "'></a>";
modal += "<div class='row'>"
modal += "<a class='name'>" + lychee.escapeHTML(files[i].name) + "</a>"
modal += "<a class='status error'>Not supported</a>"
modal += "</div>";
if (text!==undefined) modal += "<p>" + text + "</p>";
else modal += "<div class='progressbar'><div></div></div>";
}
}
modal += "</div>";
modal += "</div>";
modal += "</div>";
return modal;
}
},
contextMenu: function(items) {

View File

@ -7,12 +7,10 @@
upload = {
show: function(icon, text, html) {
if (icon===undefined) icon = "upload";
show: function(title, files) {
upload.close(true);
$("body").append(build.uploadModal(icon, text, html));
$("body").append(build.uploadModal(title, files));
},
@ -56,9 +54,7 @@ upload = {
local: function(files) {
var albumID = album.getID(),
html = "";
var process = function(files, file) {
process = function(files, file) {
var formData = new FormData(),
xhr = new XMLHttpRequest(),
@ -95,6 +91,8 @@ upload = {
if (wait===false) {
window.onbeforeunload = null;
$("#upload_files").val("");
if (album.getID()===false) lychee.goto("0");
@ -119,6 +117,10 @@ upload = {
if (progress>=100) {
/*$(".upload_message .rows").animate({
scrollTop: $(".upload_message .rows .row:nth-child(" + (file.num+1) + ")").offset().top - 200
}, 0);*/
$(".upload_message .rows .row:nth-child(" + (file.num+1) + ") .status").html("Processing");
if (file.next!==null) process(files, file.next);
@ -136,12 +138,11 @@ upload = {
if (files.length<=0) return false;
if (albumID===false) albumID = 0;
html = "<div class='rows'>";
for (var i = 0; i < files.length; i++) {
files[i].num = i;
files[i].ready = false;
files[i].supported = true;
if (i < files.length-1) files[i].next = files[i+1];
else files[i].next = null;
@ -149,25 +150,15 @@ upload = {
if (files[i].type!=="image/jpeg"&&files[i].type!=="image/jpg"&&files[i].type!=="image/png"&&files[i].type!=="image/gif") {
files[i].ready = true;
// Generate html with error
html += "<div class='row'><a class='name'>" + lychee.escapeHTML(files[i].name) + "</a><a class='status error'>Not supported</a></div>";
} else {
// Generate html
html += "<div class='row'><a class='name'>" + lychee.escapeHTML(files[i].name) + "</a><a class='status'></a></div>";
files[i].supported = false;
}
}
html += "</div>";
window.onbeforeunload = function() { return "Lychee is currently uploading!"; };
window.onbeforeunload = null;
upload.show(null, "Uploading", html);
upload.show("Uploading", files);
process(files, files[0]);
@ -179,7 +170,8 @@ upload = {
params,
extension,
buttons,
link;
link,
files = [];
if (albumID===false) albumID = 0;
@ -196,8 +188,12 @@ upload = {
return false;
}
modal.close();
upload.show("cog", "Importing from URL");
files[0] = {
name: link,
supported: true
}
upload.show("Importing URL", files);
params = "importUrl&url=" + escape(encodeURI(link)) + "&albumID=" + albumID;
lychee.api(params, function(data) {