| @@ -213,11 +213,11 @@ function upload_handler() { | |||
| }); | |||
| } | |||
| else { | |||
| for (var id = 0; id < temp.upload.length; id++) { | |||
| for(var id=0; id<temp.upload.length; id++) { | |||
| var file = temp.upload[id]; | |||
| if (file.progress != 100) { | |||
| if (file.progress == 0) { | |||
| if ( file.progress != 100 ) { | |||
| if ( file.progress == 0 ) { | |||
| if (file.obj.type != 'application/pdf' && file.obj.type != 'image/png' && file.obj.type != 'image/jpeg') { | |||
| file['progress'] = 100; | |||
| file['error'] = 'invalid file type'; | |||
| @@ -226,12 +226,12 @@ function upload_handler() { | |||
| var reader = new FileReader(); | |||
| file['progress'] = 1; | |||
| $(reader).on('load', id, upload_read_event); | |||
| $(reader).on('load', id, upload_read_event); | |||
| $(reader).on('loadstart', id, upload_read_event); | |||
| $(reader).on('loadend', id, upload_read_event); | |||
| $(reader).on('progress', id, upload_read_event); | |||
| $(reader).on('error', id, upload_read_event); | |||
| $(reader).on('abort', id, upload_read_event); | |||
| $(reader).on('loadend', id, upload_read_event); | |||
| $(reader).on('progress', id, upload_read_event); | |||
| $(reader).on('error', id, upload_read_event); | |||
| $(reader).on('abort', id, upload_read_event); | |||
| reader.readAsArrayBuffer(file.obj); | |||
| } | |||
| @@ -240,20 +240,20 @@ function upload_handler() { | |||
| } | |||
| } | |||
| } | |||
| setTimeout(function () { upload_handler(); }, 1000); | |||
| setTimeout(function() { upload_handler(); }, 1000); | |||
| } | |||
| function upload_read_event(e) { | |||
| if (e.type == 'progress') { | |||
| if (e.lengthComputable) { | |||
| var progress = Math.floor(e.originalEvent.loaded / e.originalEvent.total * 50); | |||
| if (progress < 1) { progress = 1; } | |||
| if (progress > 49) { progress = 49; } | |||
| temp.upload[e.data]['progress'] = progress; | |||
| if ( e.type == 'progress' ) { | |||
| if ( e.lengthComputable ) { | |||
| var progress = Math.floor(e.originalEvent.loaded / e.originalEvent.total * 50); | |||
| if ( progress < 1 ) { progress = 1; } | |||
| if ( progress > 49 ) { progress = 49; } | |||
| temp.upload[e.data]['progress'] = progress; | |||
| } | |||
| } | |||
| else if (e.type == 'load') { | |||
| else if ( e.type == 'load' ) { | |||
| temp.upload[e.data]['progress'] = 50; | |||
| console.log(e.target.result); | |||
| $.ajax({ | |||
| @@ -263,25 +263,25 @@ function upload_read_event(e) { | |||
| contentType: temp.upload[e.data].obj.type, | |||
| context: e.data, | |||
| processData: false, | |||
| xhr: function () { | |||
| xhr: function() | |||
| { | |||
| var xhr = new window.XMLHttpRequest(); | |||
| $(xhr.upload).on('progress', e.data, function (evt, id) { | |||
| if (evt.lengthComputable) { | |||
| xhr.upload.addEventListener("progress", function(evt){ | |||
| if (evt.lengthComputable) { | |||
| var progress = Math.floor(evt.loaded / evt.total * 50); | |||
| if (progress < 1) { progress = 1; } | |||
| if (progress > 49) { progress = 49; } | |||
| temp.upload[id].progress = 50 + progress; | |||
| if ( progress < 1 ) { progress = 1; } | |||
| if ( progress > 49 ) { progress = 49; } | |||
| console.log("upload_progress_this", this); | |||
| console.log("upload_progress_event", evt); | |||
| } | |||
| }); | |||
| }, false); | |||
| return xhr; | |||
| }, | |||
| success: function (data, status, xhr) { | |||
| console.log("upload_complete", data, status, xhr); | |||
| success: function(data, status, xhr){ | |||
| console.log("upload_complete",data, status, xhr); | |||
| } | |||
| }); | |||
| } | |||
| @@ -292,7 +292,7 @@ function upload_status() { | |||
| $.each(temp.upload, function (id, file) { | |||
| if (!$('.autodoc_upload_status_' + id).length) { | |||
| var obj = $(".autodoc_template_progress").children().clone(); | |||
| $(obj).addClass('autodoc_upload_status_' + id); | |||
| $(obj).addClass('autodoc_upload_status_'+id); | |||
| $('.autodoc_upload_status').append(obj); | |||
| } | |||
| var obj = $('.autodoc_upload_status_' + id).children(); | |||
| @@ -318,6 +318,6 @@ function upload_status() { | |||
| } | |||
| }); | |||
| setTimeout(function () { upload_status(); }, 100); | |||
| setTimeout(function() { upload_status(); }, 100); | |||
| } | |||