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