$(function(){var a=0;$("#drag-area").on("drop",function(b){b.preventDefault();b=b.originalEvent.dataTransfer.files;a++;uploadFiles(b,a)}).on("dragenter",function(){return!1}).on("dragover",function(){return!1});$("#uploadbtn").on("click",function(){$('.btn-group input[type="file"]').trigger("click").trigger("change");return!1});$('.btn-group input[type="file"]').on("change",function(){var b=this.files;"function"==typeof FormData&&uploadFiles(b)});"function"!=typeof FormData?($("#uploadbtn").css("display",
"none"),$("#uploaddrop").css("display","none"),$("#uploadinput").css("display","inline"),$("#uploadsubmit").css("display","inline")):($("#uploaddrop").css("display","inline"),$("#uploadbtn").css("display","inline"))});function trimStr(a,b){for(var d=0,e="",g=0,h=a.length;g<h;g++)if(256>a.charCodeAt(g)?d++:d+=2,e+=a.charAt(g),d>=b){e=e.substr(0,g-2)+"...";break}return e}
function uploadFiles(a,b){$("#completeStatus").html("");if(a[0]){var d=a[0].name;d=1==a.length?trimStr(d,30):trimStr(d,26)+"("+a.length+")";for(var e=new FormData,g=a.length,h=0;h<g;h++)e.append("FILE_01",a[h]);$('#uploadform input[type!="file"], #uploadform input[type!="hidden"], #uploadform select, #uploadform textarea').each(function(){e.append(this.name,this.value)});e.append("OG_HTML5","true");$.ajax({url:"upload2.jsp",type:"POST",data:e,processData:!1,contentType:"multipart/form-data",success:function(c){console.log("file uploade success.");
0<c.indexOf("<error>")?(console.log(c),$("#status").html(c)):($("#file"+b).html('<progress max="100" value="100" style="width:100px;" />\u3000\u5b8c\u4e86<span style ="font-size: x-small;">'+d+"</span> "),$("#uploadinfo").append("<br/>"+c),window.parent.FILES&&(window.parent.FILES.location=document.getElementById("RESULTURL").value))},error:function(c,f){console.log("file uploade error.");console.log(c.responseText+"/"+f);$("#uploadinfo").append(c.responseText)},xhr:function(){$("#status").append("<div id = file"+
b+' class = "statusBar">');var c=new window.XMLHttpRequest;c.upload.addEventListener("progress",function(f){f.lengthComputable&&$("#file"+b).html('<progress max="100" value="'+parseInt(parseInt(f.loaded/f.total*100))+'" /> '+parseInt(parseInt(f.loaded/f.total*99))+'<span style ="font-size: x-small;">'+d+"</span>")},!1);c.addEventListener("abort",function(f){},!1);return c}})}};
