| end: 0 | end: 0 | ||||
| }, | }, | ||||
| run: { | run: { | ||||
| "upload_handler": 0 | |||||
| "upload_handler": 0, | |||||
| "upload_status": 0 | |||||
| } | } | ||||
| }; | }; | ||||
| upload_handler(); | upload_handler(); | ||||
| } | } | ||||
| if (conf.run.upload_status == 0) { | |||||
| upload_status(); | |||||
| } | |||||
| } | } | ||||
| function upload_handler() { | function upload_handler() { | ||||
| var stop = 1; | |||||
| conf.run.upload_handler = 1; | conf.run.upload_handler = 1; | ||||
| console.log("upload_handler"); | console.log("upload_handler"); | ||||
| if (temp.documentid == null) { | if (temp.documentid == null) { | ||||
| reader.readAsArrayBuffer(file.obj); | reader.readAsArrayBuffer(file.obj); | ||||
| } | } | ||||
| } | } | ||||
| stop = 0; | |||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| setTimeout(function () { upload_handler(); }, 1000); | |||||
| if (stop) { | |||||
| conf.run.upload_handler = 0; | |||||
| } | |||||
| else { | |||||
| setTimeout(function () { upload_handler(); }, 2000); | |||||
| } | |||||
| } | } | ||||
| function upload_read_event(e) { | function upload_read_event(e) { | ||||
| url: conf.openapi + "/documents/" + temp.documentid + "/data", | url: conf.openapi + "/documents/" + temp.documentid + "/data", | ||||
| data: e.target.result, | data: e.target.result, | ||||
| contentType: temp.upload[e.data].obj.type, | contentType: temp.upload[e.data].obj.type, | ||||
| // context: { id: 0 + (function () { var x = e.data; console.log("upload_id", x); return x; }()) }, | |||||
| context: { id: e.data }, | context: { id: e.data }, | ||||
| processData: false, | processData: false, | ||||
| xhr: function () { | xhr: function () { | ||||
| } | } | ||||
| function upload_status() { | function upload_status() { | ||||
| var stop = 1; | |||||
| conf.run.upload_status = 1; | |||||
| $.each(temp.upload, function (id, file) { | $.each(temp.upload, function (id, file) { | ||||
| if (!$('.autodoc_upload_status_' + id).length) { | if (!$('.autodoc_upload_status_' + id).length) { | ||||
| var obj = $(".autodoc_template_progress").children().clone(); | var obj = $(".autodoc_template_progress").children().clone(); | ||||
| $(obj).addClass('autodoc_upload_status_' + id); | $(obj).addClass('autodoc_upload_status_' + id); | ||||
| $('.autodoc_upload_status').append(obj); | $('.autodoc_upload_status').append(obj); | ||||
| stop = 0; | |||||
| } | } | ||||
| var obj = $('.autodoc_upload_status_' + id).children(); | var obj = $('.autodoc_upload_status_' + id).children(); | ||||
| if (file.error != null) { | if (file.error != null) { | ||||
| else if (file.progress < 50) { | else if (file.progress < 50) { | ||||
| $(obj).html(file.obj.name + ': ' + 'reading file'); | $(obj).html(file.obj.name + ': ' + 'reading file'); | ||||
| $(obj).css('width', file.progress + '%'); | $(obj).css('width', file.progress + '%'); | ||||
| stop = 0; | |||||
| } | } | ||||
| else { | else { | ||||
| $(obj).html(file.obj.name + ': ' + 'sending file'); | $(obj).html(file.obj.name + ': ' + 'sending file'); | ||||
| $(obj).css('width', file.progress + '%'); | $(obj).css('width', file.progress + '%'); | ||||
| stop = 0; | |||||
| } | } | ||||
| }); | }); | ||||
| setTimeout(function () { upload_status(); }, 100); | |||||
| if (stop) { | |||||
| conf.run.upload_status = 0; | |||||
| } | |||||
| else { | |||||
| setTimeout(function () { upload_status(); }, 100); | |||||
| } | |||||
| } | } |