Commit 021e8d35 by Dányi Bence

one: file upload is delayed, if the client has no valid upload url

parent 21300d42
...@@ -144,6 +144,25 @@ $(function() { ...@@ -144,6 +144,25 @@ $(function() {
} }
/** /**
* Delay the function call for `f` until `g` evaluates true
* Default check interval is 1 sec
*/
function delayUntil(f,g,timeout){
var timeout=timeout|1000;
function check(){
var o=arguments;
if(!g()){
setTimeout(function(){check.apply(null,o)},timeout);
return;
}
f.apply(null,o);
}
return function(){
check.apply(null,arguments);
}
}
/**
* Loads the parent folder * Loads the parent folder
*/ */
self.jumpUp = function() { self.jumpUp = function() {
...@@ -353,7 +372,7 @@ $(function() { ...@@ -353,7 +372,7 @@ $(function() {
/** /**
* Uploads the specified file(s) * Uploads the specified file(s)
*/ */
function readfiles(file) { var readfiles=delayUntil(function(file) {
//1 GB file limit //1 GB file limit
if(file.size > 1024*1024*1024) { if(file.size > 1024*1024*1024) {
$('#upload-zone').hide(); $('#upload-zone').hide();
...@@ -416,7 +435,9 @@ $(function() { ...@@ -416,7 +435,9 @@ $(function() {
} }
xhr.send(formData); xhr.send(formData);
} }
} }, function() {
return self.uploadURL() !== '/';
},200);
/** /**
* Drag'n'drop listeners * Drag'n'drop listeners
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment