commit/galaxy-central: guerler: Improvements for the upload box
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/2b92d545d02e/ Changeset: 2b92d545d02e User: guerler Date: 2013-10-14 22:35:09 Summary: Improvements for the upload box Affected #: 1 file diff -r 5b95febb92c60babdc94882700124a8467662cf4 -r 2b92d545d02e6db34ce6459fa5d7b681d61021d6 static/scripts/utils/galaxy.uploadbox.js --- a/static/scripts/utils/galaxy.uploadbox.js +++ b/static/scripts/utils/galaxy.uploadbox.js @@ -50,9 +50,6 @@ // xml request element var xhr = null; - // file reader - var reader = null; - // attach to element $.fn.uploadbox = function(options) { @@ -163,7 +160,7 @@ function process() { // log - console.log("Processing queue..." + queue_length + " (" + queue_running + " / " + queue_pause + ")"); + //console.log("Processing queue..." + queue_length + " (" + queue_running + " / " + queue_pause + ")"); // validate if (queue_length == 0 || queue_pause) @@ -176,7 +173,7 @@ queue_running = true; // log - console.log("Looking for file..."); + //console.log("Looking for file..."); // get an identifier from the queue var index = -1; @@ -193,60 +190,21 @@ remove(index) // log - console.log("Initializing ('" + file.name + "')."); + //console.log("Initializing ('" + file.name + "')."); - // start - var data = opts.initialize(index, file); + // identify maximum file size + var filesize = file.size; + var maxfilesize = 1048576 * opts.maxfilesize; - // add file to queue - try + // check file size + if (filesize < maxfilesize) { - // load file read - reader = new FileReader(); - - // identify maximum file size - var filesize = file.size; - var maxfilesize = 1048576 * opts.maxfilesize; - - // set index - reader.index = index; - if (filesize < maxfilesize) - { - // link load - reader.onload = function(e) - { - // file read succesfully - console.log("Preparing submission ('" + file.name + "')."); - - // sending file - send(index, file, data) - }; - - // link error - reader.onerror = function(e) - { - error(index, file, opts.error_default); - }; - - // link abort - reader.onabort = function(e) - { - error(index, file, opts.error_default); - }; - - // reading file - console.log("Reading ('" + file.name + "')."); - - // read data - reader.readAsDataURL(file); - } else { - // skip file - error(index, file, opts.error_filesize); - } - } catch (err) - { - // parse error - error(index, file, err); + // send data + var data = opts.initialize(index, file); + send(index, file, data) + } else { + // skip file + error(index, file, opts.error_filesize); } } @@ -270,7 +228,7 @@ xhr.onreadystatechange = function() { // status change - console.log("Status changed: " + xhr.readyState + "."); + //console.log("Status changed: " + xhr.readyState + "."); // check for request completed, server connection closed if (xhr.readyState != xhr.DONE) @@ -291,20 +249,14 @@ // pass any error to the error option if (xhr.status < 200 || xhr.status > 299) { - // format error + // format status var text = xhr.statusText; - - // format status if (xhr.status == 403) text = opts.error_login; - - // text - if (!text) { - if (xhr.status == 0) - text = opts.error_server; - else - text = opts.error_default; - } + else if (xhr.status == 0) + text = opts.error_server; + else if (!text) + text = opts.error_default; // request error error(index, file, text + " (" + xhr.status + ")"); @@ -322,7 +274,7 @@ xhr.send(formData); // sending file - console.log("Sending file ('" + file.name + "')."); + //console.log("Sending file ('" + file.name + "')."); } // success @@ -392,7 +344,7 @@ // verify browser compatibility function compatible() { - return window.File && window.FileReader && window.FormData && window.XMLHttpRequest && window.FileList; + return window.File && window.FormData && window.XMLHttpRequest && window.FileList; } // export functions Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org