storageselect.js 15 KB

1
  1. var __storageselect=function(a){var z=function(b){function t(f){if(!f)return alert("UI load error."),!1;if("CERT_STORAGE"===b.type)a.ESVS.TargetObj.innerHTML=f;else{var c=document.createElement("div");document.body.insertBefore(c,document.body.firstChild);c.innerHTML=f}return!0}function r(f,c,b){if(a.CONST.__USFB_M_DISK.device>f||!c||!b)return!1;var e=a.loadUI("driveselect")({type:"DEVICE_REMOVABLE_DISK",args:c,onConfirm:function(a){g=f;m=c.list[a-1].index;e.dispose();x(y);b.focus()},onCancel:function(){e.dispose();b.focus()}});e.show()}function p(f,c,b){var e=a.loadUI("sectokenselect")({type:f,args:c,onConfirm:function(a){g=f;m=a;w=c.list[a-1].name;e.dispose();x(y);b.focus()},onCancel:function(){e.dispose();b.focus()}});e.show()}function u(f,c,b){if(a.CONST.__USFB_M_DISK.device>f||!c||!b)return!1;var e=a.loadUI("driveselect")({type:"DEVICE_SAVE_TOKEN",args:c,onConfirm:function(a){g=f;m=a;e.dispose();x(y);b.focus()},onCancel:function(){e.dispose();b.focus()}});e.show()}function C(f,c){var l=null;m=g=0;if(4&a.ESVS.Mode)if(null!=a.Whale()&&A)a.Whale().getDiskList(function(c,b,h){b=0;h&&(b=h.length);if(0==c&&0<b){c=[];for(var d=0,e=0;d<b;d++)if("MacIntel"!=navigator.platform||"Macintosh HD"!=h[d]){var k={};k.index=d+1;k.name=h[d];c[e++]=k}l={list:c}}else a.uiUtil().loadingBox(!1,"us-div-list-load");r(a.CONST.__USFB_M_DISK.device,l,f)});else if(a.nimservice())b.args&&"BACKUP_DRIVE"==b.args.drivetype?a.nimservice().GetBackupedDriveList(function(e,k,h){if(0==e&&h)if(k=h.length,0<k){e=[];for(var d=0;d<k;d++){var g={};g.index=d+1;g.name=h[d];e[d]=g}l={list:e}}else a.uiUtil().loadingBox(!1,"us-div-list-load"),a.uiUtil().msgBox(c.IDS_MSGBOX_NOT_INSERT_BACKUPEDDISK,e),b.onCancel();else a.uiUtil().loadingBox(!1,"us-div-list-load"),a.uiUtil().msgBox(c.IDS_MSGBOX_NOT_INSERT_BACKUPEDDISK,e),b.onCancel();r(a.CONST.__USFB_M_DISK.device,l,f)}):a.nimservice().GetDiskList(function(c,b,h){b=0;h&&(b=h.length);if(0==c&&0<b){c=[];for(var d=0,e=0;d<b;d++)if("MacIntel"!=navigator.platform||"Macintosh HD"!=h[d]){var g={};g.index=d+1;g.name=h[d];c[e++]=g}l={list:c}}else a.uiUtil().loadingBox(!1,"us-div-list-load"),a.nimservice().GetLastErrorCode();r(a.CONST.__USFB_M_DISK.device,l,f)});else return a.uiUtil().msgBox(__text.IDS_MSGBOX_NIM_ERROR_UNLOAD),!1;return!0}function D(b,c){var f=null;m=g=0;if(4&a.ESVS.Mode)if(a.nimservice())a.nimservice().GetHSMList(1,function(c,g,h){g=0;h&&(g=h.length);if(0==c&&0<g){c=0;for(var d=[],e=0;e<g;e++){var l={},k=h[e].split("|");l.index=e+1;l.name=k[0];l.driver=k[1];l.passage=k[2];l.validity=k[3];d[c++]=l}f={list:d}}else a.uiUtil().loadingBox(!1,"us-div-list-load"),a.nimservice().GetLastErrorCode();p(a.CONST.__USFB_M_HSMKEY.device,f,b)});else return a.uiUtil().msgBox(__text.IDS_MSGBOX_NIM_ERROR_UNLOAD),!1;return!0}function n(b,c){if(!b||!c)return!1;a.uiUtil().MsgBox(c.IDS_MSGBOX_NOT_SUPPORTED_MEDIA);return!0}function x(f){if(a.CONST.__USFB_M_DISK.device>g||(a.CONST.__USFB_M_DISK.device===g||a.CONST.__USFB_M_HSMKEY.device===g)&&1>m)return a.uiUtil().msgBox(f.IDS_MSGBOX_ERROR_PLEASE_SELECT_STORAGE),!1;if("CERT_COPY"==b.type&&b.args.sourceDevice===g&&b.args.sourceDrive===m)return a.uiUtil().msgBox(f.IDS_MSGBOX_ERROR_WARNING_SAME_STORAGE),!1;if(("CERT_COPY"===b.type||"CERT_IMPORT"===b.type||"CERT_STORAGE"===b.type)&&a.CONST.__USFB_M_SMARTCARD.device===g&&0===m&&!confirm(f.IDS_CONFIRMBOX_WARNING_CHANGE_CERT))return!1;if(g==a.CONST.__USFB_M_SECUREDISK.device)a.nimservice().IsSDInstalled(function(c,l){a.uiUtil().loadingBox(!1,"us-div-list-load");if(0!=c)a.ERROR.Code=31001,a.ERROR.Message=f.IDS_MSGBOX_NOT_INSTALL_SD,confirm(f.IDS_CONFIRMBOX_NOT_INSTALL_SD)&&(document.getElementById("us-storage-select-cancel-btn").click(),null==("firefox"==a.browserName?window.open(a.ESVS.SDInstallURL,"securedisk_url","scrollbars=1, op=100px, left=100px, height=500px, width=380px"):window.open(a.ESVS.SDInstallURL,"securedisk_url","top=100px, left=100px, height=500px, width=380px"))&&a.uiUtil().msgBox(f.IDS_MSGBOX_BLOCK_POPUP_WINDOW));else return b.onConfirm(g,m,w),!0});else if(g==a.CONST.__USFB_M_MOBILETOKEN.device)a.nimservice().IsInstalledUSIMModule(2,!0,function(c,l){a.uiUtil().loadingBox(!1,"us-div-list-load");if(0==c)a.nimservice().SetUSIMOptions(a.usimEnv.sitecode,a.usimEnv.modecode,a.usimEnv.siteURL,a.usimEnv.serviceIP,a.usimEnv.servicePort,a.usimEnv.downloadURL,function(a){b.onConfirm(g,m,w)});else if(4847E4==c||4117E4==c)a.ERROR.Code=21002,a.ERROR.Message=f.IDS_MSGBOX_NOT_INSTALL_SMARTCERT,confirm(f.IDS_CONFIRMBOX_NOT_INSTALL_SMARTCERT)&&(document.getElementById("us-storage-select-cancel-btn").click(),"firefox"==a.browserName?(c=window.open(a.usimEnv.downloadURL,"usim_url","scrollbars=1, op=100px, left=100px, height=500px, width=380px"),null==c&&a.uiUtil().msgBox(__textObjtext.IDS_MSGBOX_BLOCK_POPUP_WINDOW)):(c=window.open(a.usimEnv.downloadURL,"usim_url","top=100px, left=100px, height=500px, width=380px"),null==c&&a.uiUtil().msgBox(f.IDS_MSGBOX_BLOCK_POPUP_WINDOW)))});else if(g==a.CONST.__USFB_M_MOBILE.device)a.nimservice().IsUBIkeyInstalled(function(c,l){if(0!=c)a.ERROR.Code=11003,a.ERROR.Message=f.IDS_MSGBOX_NOT_INSTALL_MOBILE,confirm(f.IDS_CONFIRMBOX_NOT_INSTALL_MOBILE)&&(document.getElementById("us-storage-select-cancel-btn").click(),null==("firefox"==a.browserName?window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","scrollbars=1, op=100px, left=100px, height=500px, width=500px"):window.open(a.ubiKeyEnv.downloadURL,"ubikey_url","top=100px, left=100px, height=500px, width=500px"))&&a.uiUtil().msgBox(f.IDS_MSGBOX_BLOCK_POPUP_WINDOW));else b.onConfirm(g,m,w)});else return b.onConfirm(g,m,w),!0}function q(b){if(!b)return!1;for(var c=a.ESVS.Media.list.split("|"),f=0;f<c.length;f++){var e=a.CONST.medias[c[f]];void 0!=e&&null!=e&&(e=document.getElementById("us-btn-storage-"+e.name),void 0!=e&&null!=e&&"us-layout-storage-btn-none"!=e.className&&(e.className=b===e?"us-layout-storage-btn-on":"us-layout-storage-btn-off"))}return!0}function z(b){if(null==b||void 0==b)return!1;var c=!a.uiUtil().isItSupportingThisStorage(b);0==c&&null!=a.ESVS.Media&&null!=a.ESVS.Media.list&&0>a.ESVS.Media.list.indexOf(b.name)&&(c=!0);if(c)return!1;c=document.getElementById("us-btn-storage-btn-list");var f=document.createElement("li");f.setAttribute("id","us-storage-btn-li-"+b.name,0);f.setAttribute("mediaIndex",b.mediaIndex,0);7==b.mediaIndex&&(f.className="line-first");"hidden"===b.visibility?(f.style.display="none",f.style.visibility="hidden"):(f.style.display="block",f.style.visibility="visible");var e=document.createElement("button");e.setAttribute("type","button",0);e.setAttribute("id","us-btn-storage-"+b.name,0);e.setAttribute("title",b.label,0);e.setAttribute("tabindex",b.tabIndex,0);b.disabled?(e.onclick=function(){a.uiUtil().msgBox(y.IDS_MSGBOX_NOT_SUPPORTED_MEDIA)},e.className="us-layout-storage-btn-none"):(e.onclick=b.onclick,e.className=b.device===g?"us-layout-storage-btn-on":"us-layout-storage-btn-off");f.appendChild(e);var k=document.createElement("span");k.className="us-img-storage";var h=document.createElement("img");h.setAttribute("id","us-img-storage-"+b.name,0);h.setAttribute("alt",b.label,0);"browsersign"==b.name?"unkown"==a.browserName?b.disabled?h.setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/media_"+b.name+"_d.png",0):h.setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/media_"+b.name+".png",0):b.disabled?h.setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/browser/"+a.browserName+"_d.png",0):h.setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/browser/"+a.browserName+".png",0):b.disabled?h.setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/media_"+b.name+"_d.png",0):h.setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/media_"+b.name+".png",0);k.appendChild(h);e.appendChild(k);k=document.createElement("span");k.setAttribute("id","us-lbl-storage-"+b.name,0);k.className="us-layout-lbl-storage";k.appendChild(document.createTextNode(b.label));e.appendChild(k);f.appendChild(e);c.appendChild(f);return!0}var E=function(){var b=window.XMLHttpRequest?new window.XMLHttpRequest:new ActiveXObject("MSXML2.XMLHTTP.3.0");b.open("GET",a.ESVS.SRCPath+"unisignweb/rsrc/layout/storageselect.html?version="+a.ver,!1);b.send(null);return b.responseText},B=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+"/storageselect_"+a.ESVS.Language+".js?version="+a.ver,!1);b.send(null);return b.responseText},y=a.CustomEval(B,!0),v=a.ESVS.TabIndex,g=a.CONST.__USFB_M_DISK.device,m=0,w="",A=!1;null!=a.ESVS.Media&&null!=a.ESVS.Media.defaultdevice?g=a.uiUtil().getMediaDevice(a.ESVS.Media.defaultdevice):2==a.ESVS.Mode&&(g=a.CONST.__PF_M_LS.device);return function(){var f=a.CustomEval(E),c=a.CustomEval(B,!0);t(f());b&&b.args&&!0===b.args.possibleWhale&&(A=!0);f=document.getElementById("us-storage-select-lbl-title");f.appendChild(document.createTextNode(c.IDS_STORAGE_SELECTION));f.setAttribute("tabindex",v++,0);document.getElementById("us-storage-select-cls-btn-img").setAttribute("src",a.ESVS.SRCPath+"unisignweb/rsrc/img/x-btn.png",0);var l=document.getElementById("us-storage-select-notice-lbl");"CERT_STORAGE"===b.type?l.appendChild(document.createTextNode(c.IDS_SAVE_NOTICE)):l.appendChild(document.createTextNode(c.IDS_COPY_NOTICE));for(var e=0,k=a.ESVS.Media.list.split("|"),h=0;h<k.length;h++){var d=a.CONST.medias[k[h]];if(void 0!=d&&null!=d){switch(d.device){case a.CONST.__USFB_M_DISK.device:d.label=c.IDS_STORAGE_REMOVABLE;d.disabled=2==a.ESVS.Mode||"CERT_COPY"==b.type&&b.args.sourceDevice==a.CONST.__USFB_M_SECUREDISK.device;d.onclick=function(){C(this,c);q(this)};break;case a.CONST.__USFB_M_HSMKEY.device:d.label=c.IDS_STORAGE_SECTOKEN;d.disabled="win"!=a.osName||b.args&&"BACKUP_DRIVE"==b.args.drivetype;d.onclick=function(){D(this,c);q(this)};break;case a.CONST.__USFB_M_SMARTCARD.device:d.label=c.IDS_STORAGE_SAVETOKEN;d.disabled="win"!=a.osName||b.args&&"BACKUP_DRIVE"==b.args.drivetype||"CERT_COPY"==b.type&&b.args.sourceDevice==a.CONST.__USFB_M_SECUREDISK.device;d.onclick=function(){m=g=0;var b=[],d={};d.index=a.CONST.__USFB_M_SMARTCARD.device;d.name=c.IDS_SAVETOKEN_SMART_CARD;b[0]=d;u(a.CONST.__USFB_M_SMARTCARD.device,{list:b},this);q(this)};break;case a.CONST.__USFB_M_MOBILE.device:d.label=c.IDS_STORAGE_MOBILEPHONE;d.disabled="CERT_STORAGE"==b.type?!0:"win"!=a.osName||2==a.ESVS.Mode||b.args&&"BACKUP_DRIVE"==b.args.drivetype||"CERT_COPY"==b.type&&b.args.sourceDevice==a.CONST.__USFB_M_SECUREDISK.device;d.onclick=function(){g=a.CONST.__USFB_M_MOBILE.device;this.focus();q(this)};break;case a.CONST.__USFB_M_HDD.device:d.label=c.IDS_STORAGE_HARDDISK;d.disabled=2==a.ESVS.Mode||b.args&&"BACKUP_DRIVE"==b.args.drivetype||"CERT_COPY"==b.type&&b.args.sourceDevice==a.CONST.__USFB_M_SECUREDISK.device;d.onclick=function(){g=a.CONST.__USFB_M_HDD.device;this.focus();q(this)};break;case a.CONST.__USFB_M_MOBILETOKEN.device:d.label=c.IDS_STORAGE_MOBILETOKEN;d.disabled="CERT_STORAGE"==b.type?!0:"win"!=a.osName||2==a.ESVS.Mode||b.args&&"BACKUP_DRIVE"==b.args.drivetype||"CERT_COPY"==b.type&&b.args.sourceDevice==a.CONST.__USFB_M_SECUREDISK.device;d.onclick=function(){g=a.CONST.__USFB_M_MOBILETOKEN.device;this.focus();q(this)};break;case a.CONST.__USFB_M_SECUREDISK.device:d.label=c.IDS_STORAGE_SECUREDISK;d.disabled="win"!=a.osName||2==a.ESVS.Mode||b.args&&"BACKUP_DRIVE"==b.args.drivetype||"CERT_COPY"==b.type&&b.args.sourceDevice==a.CONST.__USFB_M_SECUREDISK.device;d.onclick=function(){g=a.CONST.__USFB_M_SECUREDISK.device;m=1;this.focus();q(this)};break;case a.CONST.__PF_M_LS.device:d.label=c.IDS_STORAGE_LS;d.disabled="CERT_STORAGE"==b.type||"CERT_COPY"==b.type?!0:1==a.ESVS.Mode;d.onclick=function(){g=a.CONST.__PF_M_LS.device;this.focus();q(this)};break;case a.CONST.__PF_M_SS.device:d.label=c.IDS_STORAGE_SS;d.disabled="CERT_COPY"==b.type?!0:1==a.ESVS.Mode;d.onclick=function(){g=a.CONST.__PF_M_SS.device;this.focus();q(this)};break;case a.CONST.__PF_M_TOUCHSIGN.device:d.label=c.IDS_STORAGE_TOUCHSIGN;d.disabled=!0;d.onclick=function(){n(this,c)};break;case a.CONST.__PF_M_SMARTSIGN.device:d.label=c.IDS_STORAGE_SMARTSIGN;d.disabled=!0;d.onclick=function(){n(this,c)};break;case a.CONST.__PF_M_WEBSECTOKEN.device:d.label=c.IDS_STORAGE_WEBSECTOKEN;d.disabled=!0;d.onclick=function(){n(this,c)};break;case a.CONST.__PF_M_WEBSOFTTOKEN.device:d.label=c.IDS_STORAGE_WEBSOFTTOKEN;d.disabled=!0;d.onclick=function(){n(this,c)};break;case a.CONST.__PF_M_CLOUDSIGN.device:d.label=c.IDS_STORAGE_CLOUDSIGN;d.disabled="CERT_STORAGE"==b.type||"CERT_IMPORT"==b.type||"CERT_COPY"==b.type?!0:1==a.ESVS.Mode;d.onclick=function(){g=a.CONST.__PF_M_CLOUDSIGN.device;this.focus();q(this)};break;default:d.label=c.IDS_STORAGE_ETC,d.disabled=!0,d.onclick=function(){n(this,c)}}d.tabIndex=v;d.mediaIndex=e+1;d.visibility="visible";z(d)&&(v++,e++,1==e&&document.getElementById("us-btn-storage-"+d.name))}}e=document.getElementById("us-storage-select-warning-lbl");e.appendChild(document.createTextNode(c.IDS_WARNING));a.uiUtil().isIraq()&&(e.style.visibility="hidden");e=document.getElementById("us-storage-select-confirm-btn");e.setAttribute("value",c.IDS_CONFIRM,0);e.setAttribute("title",c.IDS_CONFIRM+c.IDS_BUTTON,0);e.setAttribute("tabindex",v++,0);e.onclick=function(){x(c)};k=document.getElementById("us-storage-select-cancel-btn");k.setAttribute("value",c.IDS_CANCEL,0);k.setAttribute("title",c.IDS_CANCEL+c.IDS_BUTTON,0);k.setAttribute("tabindex",v++,0);k.onclick=function(){b.onCancel()};h=document.getElementById("us-storage-select-cls-img-btn");h.setAttribute("tabindex",v++,0);h.onclick=function(){b.onCancel()};a.uiUtil().setRotationTabFocus(k,e,f);a.uiUtil().setRotationTabFocus(f,k,l);return document.getElementById("us-div-storage-select")}()};return function(b){var t=a.uiLayerLevel,r=a.uiUtil().getOverlay(t),p=z({type:b.type,args:b.args,onConfirm:b.onConfirm,onCancel:b.onCancel});p.style.zIndex=t+1;a.ESVS.TargetObj.insertBefore(r,a.ESVS.TargetObj.firstChild);var u=window.onresize;return{show:function(){a.ActiveUI=this;draggable(p,document.getElementById("us-div-storage-select-title"));r.style.display="block";var b=document.getElementById("us-div-cert-select"),t=document.getElementById("us-div-cert-manage"),n=null;b?(n=document.getElementById("us-div-list"),n=b.offsetTop+n.offsetTop+"px"):t&&(n=document.getElementById("us-div-cert-manage-list"),n=t.offsetTop+n.offsetTop+"px");a.uiUtil().offsetResize(p);n&&(p.style.top=n);window.onresize=function(){a.uiUtil().offsetResize(p);u&&u()};a.uiLayerLevel+=10;a.ESVS.TabIndex+=30;setTimeout(function(){var a=p.getElementsByTagName("p");if(0<a.length)for(var b=0;b<a.length;b++)"us-storage-select-lbl-title"==a[b].id&&a[b].focus()},10)},hide:function(){r.style.display="none";p.style.display="none"},dispose:function(){window.onresize=function(){u&&u()};"CERT_STORAGE"===b.type?p.parentNode.removeChild(p):p.parentNode.parentNode.removeChild(p.parentNode);r.parentNode.removeChild(r);a.uiLayerLevel-=10;a.ESVS.TabIndex-=30}}}};