importfile.js 4.4 KB

1
  1. var __importfile=function(a){function g(a,d){a=document.getElementsByClassName(a);for(var c=0;c<a.length;c++)a[c].classList.contains(d)||a[c].classList.add(d)}function d(a,d){a=document.getElementsByClassName(a);for(var c=0;c<a.length;c++)a[c].classList.remove(d)}function p(a,d){return document.getElementsByClassName(a)[0].classList.contains(d)}var t=function(h){function n(a){if(!a)return alert("UI load error."),!1;var b=document.createElement("div");document.body.insertBefore(b,document.body.firstChild);b.innerHTML=a;return!0}function c(a,e){a=document.getElementById(a);a.appendChild(document.createTextNode(e));a.setAttribute("tabindex",t++,0);return a}function f(a,e){a=document.getElementById(a);for(var k=0;k<a.children.length;k++)a.children[k].appendChild(document.createTextNode(e[k]));return a}function q(b,e){b=document.getElementById(b);b.setAttribute("src",a.ESVS.SRCPath+e,0);return b}var w=function(){var b=window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP.3.0");b.open("GET",a.ESVS.SRCPath+"unisignweb/rsrc/layout/importFileWithDD.html?V="+a.ver,!1);b.send(null);return b.responseText},x=function(){var b=window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP.3.0");b.open("GET",a.ESVS.SRCPath+"unisignweb/rsrc/lang/"+a.ESVS.Language+"/importfile_"+a.ESVS.Language+".js?V="+a.ver,!1);b.send(null);return b.responseText},l=null,t=a.ESVS.TabIndex,m={},r=0,u=0;m.filelist=[];var v=function(a){if(10485760<u+a.size)alert(l.IDS_ERROR.FILE_SIZE_OVER);else{u+=a.size;var b=new FileReader;b.onload=function(k){m.filelist.push({name:a.name,data:k.target.result.toBase64()});if(r==m.filelist.length){d("us-filelist-sublist","hide");g("view-panel","hide");d("file-info","hide");k=document.getElementsByClassName("us-filelist-sublist");var b="<li class='title'>"+l.IDS_FILE_NAME;b+="</li>";for(var c=0;c<m.filelist.length;c++)b+="<li> - ",b+=m.filelist[c].name,b+="</li>";k[0].innerHTML=b;d("us-cert-import-content","drop-here");d("us-cert-import-content","drag");g("us-cert-import-content","drop")}};b.readAsArrayBuffer(a)}};return function(){var b=a.CustomEval(w);l=a.CustomEval(x,!0);n(b());b=document.getElementById("us-div-import-cert");c("us-import-cert-lbl-title",l.IDS_TITLE);q("us-cls-btn-img","unisignweb/rsrc/img/x-btn.png").onclick=function(){h.onCancel()};f("us-content-basic-notice-ul",l.IDS_CONTENT_NOTICE_UL);f("us-content-drop-plz-ul",l.IDS_CONTENT_DROP_UL);var e=document.getElementById("us-btn-cert-import");e.value=l.IDS_CONFIRM;e.onclick=function(a){a.preventDefault();a.returnValue=!1;a.cancelBubble=!0;h.onConfirm(m.filelist)};e=document.getElementById("us-btn-cancel");e.value=l.IDS_CANCEL;e.onclick=function(a){h.onCancel()};e=document.getElementsByClassName("us-cert-import-content")[0];e.onclick=function(a){a.preventDefault();p("file-info","hide")&&(document.getElementById("us-cert-import-file").click(),document.getElementById("us-cert-import-file").onchange=function(a){r=a.target.files.length;for(var b=0;b<a.target.files.length;b++)v(a.target.files[b])})};e.ondragleave=function(a){a.preventDefault()};e.ondragover=function(a){p("file-info","hide")&&(g("us-cert-import-content","drop-here"),d("us-cert-import-content","drag"),g("view-panel","hide"),d("drop-plz","hide"));a.preventDefault()};e.ondrop=function(a){a.preventDefault();if(p("file-info","hide")){d("us-cert-import-content","drop-here");g("us-cert-import-content","drag");g("view-panel","hide");d("basic","hide");var b=a.dataTransfer.files;r=a.dataTransfer.files.length;for(a=0;a<b.length;a++)v(b[a])}return!1};d("basic","hide");return b}()};return function(h){var n=a.uiLayerLevel,c=a.uiUtil().getOverlay(n),f=t({type:h.type,args:h.args,onConfirm:h.onConfirm,onCancel:h.onCancel});f.style.zIndex=n+1;a.ESVS.TargetObj.insertBefore(c,a.ESVS.TargetObj.firstChild);c.ondragleave=function(a){null==a.relatedTarget&&p("file-info","hide")&&(d("us-cert-import-content","drop-here"),g("us-cert-import-content","drag"),g("view-panel","hide"),d("basic","hide"));a.preventDefault()};var q=window.onresize;return{show:function(){c.style.display="block";a.uiUtil().offsetResize(f);a.uiLayerLevel+=10;a.ESVS.TabIndex+=30;setTimeout(function(){var a=f.getElementsByTagName("p");if(0<a.length)for(var c=0;c<a.length;c++)"us-lbl-title"==a[c].id&&a[c].focus()},10)},hide:function(){c.style.display="none";f.style.display="none"},dispose:function(){window.onresize=function(){q&&q()};f.parentNode.parentNode.removeChild(f.parentNode);c.parentNode.removeChild(c);a.uiLayerLevel-=10;a.ESVS.TabIndex-=30}}}};