| @@ -185,39 +185,40 @@ function upload_zone_normal(e) { | |||
| function upload_zone_drop(e) { | |||
| var ev = e.originalEvent; | |||
| console.log(ev.dataTransfer.files); | |||
| $.each(ev.dataTransfer.files, function(id,file) { | |||
| console.log(file); | |||
| var fileid = temp.upload.length; | |||
| temp.upload.push({ | |||
| progress: 0, | |||
| error: null, | |||
| obj: file | |||
| }); | |||
| }); | |||
| if ( temp.documentid == null ) { | |||
| $.post(conf.openapi + "/documents", {}, function(data) { | |||
| temp.upload = []; | |||
| temp.documentid = data.id; | |||
| upload_status(); | |||
| handle_uploads(ev); | |||
| upload_handler(); | |||
| }); | |||
| } | |||
| else { | |||
| handle_uploads(ev); | |||
| upload_handler(); | |||
| } | |||
| } | |||
| function handle_uploads(ev) { | |||
| function upload_handler() { | |||
| console.log(ev.dataTransfer.files); | |||
| console.log(temp.upload); | |||
| $.each(ev.dataTransfer.files, function(id,file) { | |||
| console.log(handle_uploads, file); | |||
| var fileid = temp.upload.length; | |||
| temp.upload.push({ | |||
| name: file.name, | |||
| type: file.type, | |||
| size: file.size, | |||
| progress: 0, | |||
| error: null | |||
| }); | |||
| if ( file.type != 'application/pdf' && file.type != 'image/png' && file.type != 'image/jpeg' ) { | |||
| temp.upload[fileid]['progress']=1; | |||
| temp.upload[fileid]['error']='invalid file type'; | |||
| $.each(temp.upload, function(id,file) { | |||
| console.log(upload_handler, file); | |||
| if ( file.obj.type != 'application/pdf' && file.obj.type != 'image/png' && file.obj.type != 'image/jpeg' ) { | |||
| temp.upload[id]['progress']=1; | |||
| temp.upload[id]['error']='invalid file type'; | |||
| } | |||
| else { | |||
| var reader = new FileReader(); | |||
| @@ -228,7 +229,6 @@ function handle_uploads(ev) { | |||
| }, file.type) | |||
| }; | |||
| reader.readAsArrayBuffer(data); | |||
| } | |||
| }); | |||
| return true; | |||
| @@ -256,7 +256,7 @@ function upload_status() { | |||
| console.log(obj); | |||
| $('.autodoc_upload_status').append(obj); | |||
| }); | |||
| if ( !finished ) { | |||
| if ( !finished || temp.upload.length == 0 ) { | |||
| setTimeout(upload_status, 1000); | |||
| } | |||
| } | |||