fs-danaus
2021-05-15 71e46fd20c6bf1ef4200513e1ac452fcad291cb0
提交 | 用户 | age
f7809b 1 var version = 0;// 版本号
a6a76f 2 var pwdCallBack = null;// 密码输入点击确定后回调函数
F 3 var obj22 = null;// 22类型传值对象
4 var shx=false; 
5 var leftWidth="0";
6 var gridId=[];
7 //var uploadObj = null;
8 //var edit='';
9 var pic={};// 格线附件上传参数属性
10 var rsakey={
11     pubkey:"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkRupiYcKVGGUtDBDoR1t/1zm3ZtZgnte39iTJW6hlqjdY0UagKjpNiIv7J6XjtgfX7SgsR4AWnivqQHAICIvdPKfGZZzIs62OQ19MqrDTMoB/LvK5teNWhClv23WMUfRbP+EHgprT6hTw8U5apw1IB6i/y57NkLav792wiYBYRU4X45NoTaT+aiTSLFEflbfm94EXnhSS3vFkBmrZGy5BRNI8gmzafroslGx2Hk90CqlNdeKYxgZQ6xtvj+u33yrszWvPT6F9fsJT8aMjtvH050iYKRVct+x6Q7VRJgCI4MgvAexnTKdxW54YzvXCuO5bDiy5la7CgerWkTAq9dzXwIDAQAB"
12 };
13 //拼接附件url
14 function getAttachmentUrl(staticUrl,formid,unid,domain,dbid,isShowOrgPic,width,height,fileExt,isDownLoad){
15     if(staticUrl!=null &&staticUrl!=""){
16         if(isDownLoad)
17             return unid+"_"+dbid+"_"+formid+"_"+fileExt;
18         else
19             return domain+staticUrl;
20     }
21     width=width||80;
22     height=height||80;
23     isShowOrgPic=isShowOrgPic||false;
24     fileExt="."+fileExt||"";
25     return domain+"/uploads/attachment/"+dbid+"/"+formid+"/"+unid+(isShowOrgPic?("_"+width+"x"+height):"")+fileExt;
26 }
27 //31类型新增sqlWhere设置,拼接sql,在可编辑状态时调用
28 //dysql:select * from gfield where formid=120201 order by statisid desc, sqlWhere: formname='xxx'
29 //返回 select * from gfield where (formid=120201) and (formname='xxx') order by statisid desc
30 // by danaus 2019/12/21 16:46
31 function processDysqlV2(dysql,sqlWhere){
32     if(sqlWhere!=undefined&&sqlWhere!=""){//存在sqlWhere
33         var patt1=new RegExp(/where.*/i);//判断有没where部分
34         var whereArry=patt1.exec(dysql);
35         if(whereArry!=null){//表示原sql有where条件 where formid=120201 order by statisid desc
36             var where=whereArry[0];
37             dysql=dysql.replace(where,"");
38             patt1=new RegExp(/order by.*/i);//判断有没order by部分
39             var orderby=patt1.exec(where);
40             if(orderby!=null){//order by statisid desc
41                 where=" where ("+where.replace(patt1,"").replace(/where/i,"")+") and ("+sqlWhere+") "+orderby[0];
42             }else{
43                 where=" where ("+where.replace(/where/i,"")+") and ("+sqlWhere+") ";
44             }
45             dysql=dysql+where;
46         }else{//是否有order by
47             //直接在原sql上加sqlWhere
48             patt1=new RegExp(/order by.*/i);//判断有没order by部分
49             var orderby=patt1.exec(dysql);
50
51             if(orderby!=null){//order by statisid desc
52
53                 dysql=dysql.replace(orderby,"")+" where (1=1) and ("+sqlWhere+") "+orderby[0];
54             }else{
55                 dysql=dysql+" where (1=1) and ("+sqlWhere+") ";
56             }
57         }
58     }
59     return dysql;
60 }
61 function generateUUID() {
62     var d = new Date().getTime();
63     if (window.performance && typeof window.performance.now === "function") {
64         d += performance.now(); //use high-precision timer if available
65     }
66     var uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
67         var r = (d + Math.random() * 16) % 16 | 0;
68         d = Math.floor(d / 16);
69         return (c == 'x' ? r : (r & 0x3 | 0x8)).toString(16);
70     });
71     return uuid;
72 }
73
74 // 2类型树节点,显示图片
75 function createUploadDiv(colname, value) {
76     if ((";" + nodejs.uploadColName + ";").match(";" + colname + ";")) {
77         $("#uploadDiv_" + colname).empty();
78         var photo = $('<div id="uploadRootDiv_"' + colname + '></div>')
79                 .append(
80                         '<input id="'
81                                 + colname
82                                 + '_up" type="file" multiple class="file" data-overwrite-initial="false" data-min-file-count="1"><input id="'
83                                 + colname + '" name="' + colname
84                                 + '" value="" type="hidden" />');
85         $("#uploadDiv_" + colname).append(photo);
86         onfileiput(formId, colname, panMain[0].panInfo[colname].controltype,
87                "", "", nodejs.usercode, value);
88         picevent(colname);   // 事件
89         $doc(colname).val(value);
90     }
91 }
92
aa5c59 93 //请求加载附件 xin 2021-4-28 08:49:25
X 94 function postFileOrImage(option){
95     $.post(option.url,option.data,function(r){
96         option.success(r);
97     }).error(function(xhr,errorText,errorType){
98         option.onerror(xhr,errorText,errorType);
99     });
100 }
101 //请求附件前的参数配置和渲染控件
102 function loadFileOrImage(formid,id,controlType,docstatus,rowid,usercode,uuid,maxFileSize) {
103     var option = {//加载附件需要到参数信息
104         fieldid: id,
105         controltype: controlType,
106         formid: formid,
107         unid: (uuid == undefined ? $('#' + id).val() : uuid),
108         maxFileSize: maxFileSize,
109         docstatus: docstatus,
110         rowid: rowid,
111         usercode: usercode,
112         doccode: $('#doccode').val(),
113         readerusercodes: $('#readerusercodes').val()
114     };
115     var panelautoSave = "";//标记是否为单据
116     if (formType && (formType == 5 || formType == 9
117         || formType == 15 || formType == 8
118         || formType == 496 || formType == 497
119         || formType == 16 || formType == 17)) {
120         for (var i in panMain) {   // 循环状态值,如果面板有这个0或1就循环下去,没有就直接跳过
121             if (panMain[i].picState[id] != null) {
122                 var ed = panMain[i].picState[id].split(";pb#");
123                 option.headflag = ed[0];
124                 option.editstatus = (ed.length > 1 && ed[1] != null ? ed[1] : ed[0]);
125             }
126         }
127         panelautoSave = "&is16=1";
128     }
129     //加载附件并且渲染控件
130     postFileOrImage({
131         url: "/attachment/getAttachmentList.do",
132         data: {pant: JSON.stringify(option)},
133         success: function (r) {//加载成功后进入
134             if(r!=null) {
135                 //加密用到
136                 var encrypt = new JSEncrypt();
137                 encrypt.setPublicKey(rsakey.pubkey);
138                 //属性
139                 var uplodUrl = "";
140                 var Preview = [];
141                 var PreviewConfig = [];
142                 var Config = {};
143                 for (var i = 0; i < r.length; i++) {//遍历加载到的附件信息
144                     if (r[i].isNewAttachment != 1) {//不是新单进入
145                         Config.caption = r[i].originalFileName;   // 上传的图片名称
146                         Config.filename = r[i].physicalFile;   //物理文件
147                         Config.time = r[i].uploadTimeStr;  //上传开始时间
148                         Config.name = r[i].authorName;  //作者名称
149                         Config.size = r[i].fileSizeStr;   // 上传的图片大小
150                         Config.type = r[i].fileType;   // 上传的图片类型
151                         Config.key = r[i].seq;
152                         Config.downloadUrl = r[i].domain + "/attachment/downLoadAttachment.do?filePath=" +
153                             getAttachmentUrl(r[i].staticUrl, r[i].formid, r[i].unid + "@p@" +
154                                 r[i].seq, "", r[i].dbid, false, 60, 60, r[i].orgFileType, true);   // 附件下载路径
155                         Config.url = r[i].domain + '/attachment/deleteAttachmentV2.do?' + 'type=' + (controlType == 9 ? '1' : '3') +
156                             '&formid=' + r[i].formid + '&doccode=' + option.doccode + '&fieldid=' + id + '&unid=' + r[i].unid + '&seq=' +
157                             r[i].seq + '&docstatus=' + r[i].docstatus + '&ishd=1&readerusercodes=' + option.readerUserCodes + '&usercode=' +
158                             encodeURIComponent(encrypt.encrypt(r[i].authorCode)) + '&dbid=' +
159                             encodeURIComponent(encrypt.encrypt(r[i].dbid)) + '&curUsername=' +
160                             encodeURIComponent(encrypt.encrypt(r[i].userName)) + '&curUsercode=' +
161                             encodeURIComponent(encrypt.encrypt(r[i].userCode));
162                         //图片属性集合
163                         PreviewConfig.push(Config);
164                         //预览框中图片集合
165                         Preview.push('<img src="' + getAttachmentUrl(r[i].staticUrl, formid, r[i].unid + "@p@" + r[i].seq, r[i].domain, r[i].dbid,
166                             false, 60, 60, r[i].orgFileType) + '" style="height: 60px;" ' +
167                             'class="kv-preview-data file-preview-image" title="文件名:' + r[i].originalFileName + ' \n类型:' +
168                             r[i].fileType + ' \n大小:' + r[i].fileSizeStr + ' \n上传者:' + r[i].authorName + ' \n上传时间:' + r[i].uploadTimeStr + '">');
169                     }
170                     //上传附件url
171                     if (i == 0) {//进入一次就可以
172                         uplodUrl = r[i].domain + '/attachment/uploadAttachmentV2.do?type=' + (controlType == 9 ? '1' : '3') + '&formid=' + r[i].formid +
173                             '&doccode=' + option.doccode + '&fieldid=' + id + '&rowid=' + Math.random() +
174                             '&usercode=' + encodeURIComponent(encrypt.encrypt(r[i].userCode)) + '&username=' +
175                             encodeURIComponent(encrypt.encrypt(r[i].userName)) + '&ishd=1' + panelautoSave + '&dbid=' +
176                             encodeURIComponent(encrypt.encrypt(r[i].dbid)) +
177                             '&uuid=' + $('#' + id).val();
178                     }
179                 }
180                 //渲染控件
181                 $('#' + id + '_up').fileinput({
182                     uploadUrl: uplodUrl,   // String,用于上传处理操作的URL(通常是基于Ajax的处理)
183                     // uploadExtraData:function(){},
184                     language: 'zh',   // 语言
185                     uploadAsync: false,   // bool是否多文件批量上传将并行异步/。默认为true
186                     showUpload: true,   // 布尔值,是否显示缩略图中的上传按钮
187                     showRemove: true,   // 布尔值,是否显示缩略图中的删除按钮
188                     // showCaption: true,   // 布尔值,是否显示文件名。默认值为true
189                     // showPreview: true,   // 布尔值,是否显示文件预览。默认值为true
190                     dropZoneEnabled: true,   //是否显示拖拽区域
191                     browseOnZoneClick: false,//isReadOnly,   //布尔值,是否在点击预览区域时触发文件浏览/选择。默认为false
192                     showUploadedThumbs: true,   // 是否在预览窗口中持续显示已经上传的文件缩略图(用于ajax上传),直到按下删除/清除按钮
193                     maxFilesNum: 10,   // 上传最大的文件数量
194                     previewSettings: {   // 设置显示的图片相同的宽度高度
195                         image: {width: "110px", height: "110px"},
196                     },
197                     initialPreview: Preview,   // 字符串或者数组,要显示的初始预览内容
198                     initialPreviewConfig: PreviewConfig,   // 数组,为每个initialPreview条目(就是initialPreview中的每个预览)设置重要属性的配置
199                     maxFileSize: maxFileSize,
200                     maxFileCount: (controlType == 9 ? 1 : 0),   // 为每个多次上载允许的最大文件数。如果设置为0,则意味着允许的文件数是无限的。
201                     isNine: (controlType == 9 ? true : false),   // 19类型就为false,9类型就为true,
202                     validateInitialCount: (controlType == 9 ? true : false),   // 是否包括初始预览文件数(服务器上传文件)验证minfilecount和maxfilecount。默认为false.
203                     overwriteInitial: (controlType == 9 ? false : true)   // 是否要覆盖初始预览内容和标题设置
204                 })
205                 others();
206                 // $('#' + id + '_up').on('fileimageuploaded',function(){
207                 //      others();
208                 // })
209             }
210         },
211         onerror:function (xhr,errorText,errorType) {//错误处理
212
213         }
214     });
215 }
a6a76f 216 // 加载面板附件内容
F 217 function onfileiput(formid,id,controlType,docstatus,rowid,usercode,uuid,maxFileSize){
aa5c59 218     // loadFileOrImage(formid,id,controlType,docstatus,rowid,usercode,uuid,maxFileSize);//引用新方法 xin 2021-4-28 15:17:21
X 219     // return;
a6a76f 220     var picPer=[];var authBtn='';
F 221     // 上传附件需要的参数
222     var picpant={};
223     try{   // 赋值
224         var uid=$('#'+id).val();
225         uid=uid==undefined?"":uid.replace(/^;+/g,"");//处理值是;;;这样1个或多个的情况
226         picpant['fieldid']=id;
227         picpant['controltype']=controlType;
228         picpant['formid']=formid;
229         picpant['unid']=(uuid==undefined?uid:uuid);
230         picpant['maxFileSize']=maxFileSize;
231         picpant['docstatus']=docstatus;
232         picpant['rowid']=rowid;
233         picpant['usercode']=usercode;
234         var readerUserCodes = $('#readerusercodes').val();
235         try{
236             picpant['doccode']=$('#doccode').val();
237             if(picpant.doccode==undefined){
238                 picpant.doccode=panMain[panIndex].panelAuditValue.doccode;
239             }
240             if (picpant['doccode'] && readerUserCodes!=undefined && readerUserCodes!='') {
241                 picpant['readerusercodes']=readerUserCodes;
242             }
243         }catch(e){
244             picpant.doccode=panMain[panIndex].panelAuditValue.doccode;
245         }
246         var isReadOnly = false ;
247         var panelautoSave="";//标记是否为单据
248         if(formType && (formType == 5 || formType == 9
249                 || formType == 15 || formType == 8
250                 || formType == 496|| formType == 497
251                 || formType == 16 || formType == 17)){
252             panelautoSave="&is16=1";
253             for(var i in panMain){   // 循环状态值,如果面板有这个0或1就循环下去,没有就直接跳过
254                 if(panMain[i].picState[id]!=undefined){
255                     var ed = panMain[i].picState[id].split(";pb#");
256                     picpant['headflag'] = ed[0];
257                     picpant['editstatus'] = (ed.length > 1 && ed[1] != null?ed[1] : ed[0]);
258                     if(picpant['editstatus']!=""){
259                         if((";" + picpant['editstatus'] + ";").indexOf(";" + docstatus + ";") > -1){
260                             isReadOnly = false;
261                         }else{
262                             isReadOnly = true;
263                         }
264                     }
265                     //注释:这样获取只读值,只会把控件隐藏起来,不是想要的只读 xin 2021-3-3 10:36:04
266                     // if(panMain[i].panInfo[id].ReadOnly && panMain[i].panInfo[id].ReadOnly == 1){
267                     //     isReadOnly = true ;
268                     // }
269                 }
270             }
271         }
272         var picpants = JSON.stringify(picpant);
273         // 图片显示的方法
274         $.ajax({url:'/attachment/getAttachmentList.do',
275             type:"POST",
276             async:false,
277             data:{pant:picpants},
278             dataType:'json',
279             success :function(data){
280                 var jsons=data;
281                 // 加载图片需要的属性
282                 var encrypt = new JSEncrypt();
283                 encrypt.setPublicKey(rsakey.pubkey);
284                 var picupload={
285                     uploadUrl: '#',   // String,用于上传处理操作的URL(通常是基于Ajax的处理)
286                     language: 'zh',   // 语言
287                     uploadAsync: false,   // bool是否多文件批量上传将并行异步/。默认为true
288                     showUpload: true,   // 布尔值,是否显示缩略图中的上传按钮
289                     showRemove: true,   // 布尔值,是否显示缩略图中的删除按钮
290                     showCaption: true,   // 布尔值,是否显示文件名。默认值为true
291                     showPreview: true,   // 布尔值,是否显示文件预览。默认值为true
3a07f8 292                     dropZoneEnabled: true,   //是否显示拖拽区域
a6a76f 293                     browseOnZoneClick: isReadOnly,   //布尔值,是否在点击预览区域时触发文件浏览/选择。默认为false
F 294                     showUploadedThumbs: true,   // 是否在预览窗口中持续显示已经上传的文件缩略图(用于ajax上传),直到按下删除/清除按钮
295                     maxFilesNum: 10,   // 上传最大的文件数量
296                     maxFileCount: 0,   // 为每个多次上载允许的最大文件数。如果设置为0,则意味着允许的文件数是无限的。默认值为0。
297                     isNine:false,   // 19类型就为false,9类型就为true,下面有判断
298                     validateInitialCount: false,   // 是否包括初始预览文件数(服务器上传文件)验证minfilecount和maxfilecount。默认为false.
299                     overwriteInitial: true,   // 是否要覆盖初始预览内容和标题设置
300                     previewSettings: {   // 设置显示的图片相同的宽度高度
301                         image: {width: "110px", height: "110px"},
302                     },
303                     initialPreview:[],   // 字符串或者数组,要显示的初始预览内容
304                     initialPreviewConfig:[],   // 数组,为每个initialPreview条目(就是initialPreview中的每个预览)设置重要属性的配置
305                     showPreview: true,   // 布尔值,是否显示文件预览。默认值为true
306                     maxFileSize: maxFileSize
307                 }
308                 for(var i=0;i<jsons.length;i++){
309                     if(jsons.length==1&&jsons[0].isNewAttachment==1){//表示返回的新单需要的数据,而不是附件的内容
310                         picpant.domain=jsons[0].domain;
311                         picpant.dbid=jsons[0].dbid;
312                         picpant.usercode=jsons[0].userCode;
313                         picpant.username=jsons[0].userName;
314                         break;
315                     }
316
317                     // 图片属性
318                     if(i==0) {
319                         picpant.domain = jsons[i].domain;
320                         picpant.usercode = jsons[i].userCode;
321                         picpant.username = jsons[i].userName;
322                         picpant.dbid = jsons[i].dbid;
323                     }
324                     var encrypt = new JSEncrypt();
325                     encrypt.setPublicKey(rsakey.pubkey);
326                     var deleToken= 'type='+(controlType == 9?'1':'3')+'&formid='+picpant.formid+'&doccode='+picpant.doccode+'&fieldid='+id+'&unid='+jsons[i].unid+'&seq='+
327                     jsons[i].seq+'&docstatus='+picpant.docstatus+'&ishd=1&usercode='+encodeURIComponent(encrypt.encrypt(jsons[i].authorCode))+'&readerusercodes='+readerUserCodes+'&dbid='+encodeURIComponent(encrypt.encrypt(jsons[i].dbid))+'&curUsername='+encodeURIComponent(encrypt.encrypt(jsons[i].userName))+'&curUsercode='+encodeURIComponent(encrypt.encrypt(jsons[i].userCode));
328                     picupload.initialPreviewConfig.push({
329                         'caption':jsons[i].originalFileName,   // 上传的图片名称
330                         'filename':jsons[i].physicalFile,   //物理文件
aa5c59 331                         'time':jsons[i].uploadTimeStr,  //上传开始时间
a6a76f 332                         'name':jsons[i].authorName,  //作者名称
F 333                         'size':jsons[i].fileSizeStr,   // 上传的图片大小
334                         'type':jsons[i].fileType,   // 上传的图片类型
335                         'key':jsons[i].seq,
336                         'downloadUrl':jsons[i].domain+"/attachment/downLoadAttachment.do?filePath="+getAttachmentUrl(jsons[i].staticUrl,jsons[i].formid,jsons[i].unid+"@p@"+jsons[i].seq,"",jsons[i].dbid,false,60,60,jsons[i].orgFileType,true),   // 附件下载路径
337                         'url':jsons[i].domain+'/attachment/deleteAttachmentV2.do?'+deleToken
338                     });   // 附件删除路径
339                     // 判断是否需要权限,如果要那么就加载权限按钮属性
340                     if(jsons[i].authorCode != null && jsons[i].authorCode == picpant.usercode){   // authorCode 作者
341                         authBtn='<a href="javascript:authorize(\''+jsons[i].unid +'\',\''+jsons[i].seq +'\');" '+
342                             'class="btn btn-kv btn-default btn-outline-secondary" title="授权" style="padding: 0px;">'+
343                             '<i class="glyphicon glyphicon-lock" style="padding-top: 6px;"></i></a>';   // 授权按钮
344                     }
345 //                    var fileSize=null;
346 //                    if(fileSize == null) fileSize = jsons[i].fileSize;   //附件上传参数控制,上传附件大小控制
347 //                    picupload.maxFileSize = (fileSize == 0 || fileSize == null || fileSize == "null")?10240:fileSize;   //附件上传参数控制,上传附件大小控制
348                     // 添加图片权限
349                     picPer.push({key:jsons[i].seq,isAllowDelete:jsons[i].hasDelete,isAllowUpdate:jsons[i].hasUpdate,
350                         isAllowDownload:jsons[i].hasDownload,authBtn:authBtn});
351                     // 图片
352                     picupload.initialPreview.push('<img src="'+getAttachmentUrl(jsons[i].staticUrl,formid,jsons[i].unid+"@p@"+jsons[i].seq,jsons[i].domain,jsons[i].dbid,false,60,60,jsons[i].orgFileType)+'" style="height: 60px;" class="kv-preview-data file-preview-image" title="文件名:'+jsons[i].originalFileName+' \n类型:'+jsons[i].fileType+' \n大小:'+jsons[i].fileSizeStr+' \n上传者:'+jsons[i].authorName+' \n上传时间:'+jsons[i].uploadTimeStr+'">');
353                 }
354                 // 判断如果是9类型就输出,如果是19类型就不输出
355                 if(controlType==9){
356                     picupload.maxFileCount=1;   // 为每个多次上载允许的最大文件数。如果设置为0,则意味着允许的文件数是无限的。默认值为0。
357                     picupload.isNine=true;   // 19类型就为false,9类型就为true
358                     picupload.validateInitialCount= true;   // 是否包括初始预览文件数(服务器上传文件)验证minfilecount和maxfilecount。默认为false.
359                     picupload.overwriteInitial= false;   // 是否要覆盖初始预览内容和标题设置
360                 }
361
362                 // 附件上传路径
363
364                 var upToken = 'type='+(controlType == 9?'1':'3')+'&formid='+picpant.formid+
365                 '&doccode='+picpant.doccode+'&fieldid='+id+'&rowid='+Math.random()+
366                 '&usercode='+encodeURIComponent(encrypt.encrypt(picpant.usercode))+'&username='+encodeURIComponent(encrypt.encrypt(picpant.username))+'&ishd=1'+panelautoSave+'&dbid='+encodeURIComponent(encrypt.encrypt(picpant.dbid))+
367                 '&uuid='+ $('#'+id).val();
368                 picupload.uploadUrl=picpant.domain+'/attachment/uploadAttachmentV2.do?'+upToken;
f7809b 369                 // 加载图片显示
X 370                 var uploadObj = $('#'+id+'_up').fileinput(picupload);
371                 if(isReadOnly){
372                     $(".file-preview ").css("background","#CCC");
3a07f8 373                     $(".file-footer-buttons").find("a").css("background","#CCC");
X 374                     $(".file-footer-buttons").find("button").css("background","#CCC");
f7809b 375                 }
a6a76f 376                 others();
F 377                 picBtn(picPer,picupload,id);
378             }
379         });
380     }catch(e){
381         $.messager.alert("提示", "未能加载附件信息!" + e, "warning");
382     }
383 }
384
385 /******图片在图片框内按宽高比例自动缩放!!!***/
386 // Img:要放图片的img元素,onload时传参可用this
387
388 // maxHeight  :img元素的高度,像素(图片框 最大高度)
389
390 // maxWidth:img元素的宽度,像素(图片框 最大宽度)
391 function AutoSize(Img, maxWidth, maxHeight) {
392     var image = new Image();
393     // 原图片原始地址(用于获取原图片的真实宽高,当<img>标签指定了宽、高时不受影响)
394     image.src = Img.src;
395     // 当图片比图片框小时不做任何改变 
396     if (image.width < maxWidth&& image.height < maxHeight) {
397         Img.width = image.width;
398         Img.height = image.height;
399     }
400     else{ // 原图片宽高比例 大于 图片框宽高比例,则以框的宽为标准缩放,反之以框的高为标准缩放
401         if (maxWidth/ maxHeight  <= image.width / image.height){ // 原图片宽高比例 大于 图片框宽高比例
402             Img.width = maxWidth;   // 以框的宽度为标准
403             Img.height = maxWidth* (image.height / image.width);
404         }
405         else {   // 原图片宽高比例 小于 图片框宽高比例
406             Img.width = maxHeight  * (image.width / image.height);
407             Img.height = maxHeight  ;   // 以框的高度为标准
408         }
409     }
410 }
411
412 // 40类型 查看图片
413 function showModalImg(value,controlType){
414     try{
415         var pant=value.split("?")[1];
416         var pants=pant.split("&");
417         var pic={};
418         for(var i=0;i<pants.length;i++){
419             c=pants[i].split("=");
420             pic[c[0]]=c[1];
421         }
422         var src="#";
423         var results="";
424         if(pic.oldgrid!=undefined){
425             if(pic.oldgrid.indexOf('http')!=-1){   //判断http协议,有无地址
426                 results=pic.oldgrid.split(";")[1]; //显示网址图片
427             }else{
428                 src = pic.oldgrid.replace(".do;",".do?type="+(controlType == 9?"1":"3")+"&uuid=");
429                 var unid=pic.oldgrid.split(";")[1];
430                 var seq=pic.oldgrid.split(";")[2];
431                 var fileExt=pic.oldgrid.split(";")[3];
432                 if(seq!=null&&seq!=undefined&&seq!=""){
433                     unid=unid+"@p@"+seq;
434                 }
435                 results=getAttachmentUrl(pic.staticUrl,pic.formid,unid,pic.domain,pic.dbid,false,80,80,fileExt);
436             }
437         }else{
438             return false;
439         }
440         $("#bimg").attr("src",results);
441         document.getElementById("uploadForm").style.display="none";
442         document.getElementById("bimg").style.display="inline-block";
443         //AutoSize($("#bimg"),600,500);
444         return true ;
445     }catch(e){alert(e);}
446 }
447
448 // 格线执行 附件 进入的函数,主要是9类型
449 function showModal(id,value){
450     var controlType = 9 ;  // 专用于格线
451     var readerUserCodes = $('#readerusercodes').val();
452 // 加载图片需要的属性
453     var picupload={
454         uploadUrl: '#',
455         language: 'zh',
456         uploadAsync: false,
457         showUpload: true,
458         showRemove: true,
459         showCaption: true,
460         showPreview: true,
461         browseOnZoneClick: false,
462         maxFileSize: 10000,   //文件最大不超过...kb
463         showUploadedThumbs: true,
464         maxFilesNum: 10,
465         maxFileCount: 0,   // 为每个多次上载允许的最大文件数。如果设置为0,则意味着允许的文件数是无限的。默认值为0。
466         isNine:false,
467         validateInitialCount: false,   // 是否包括初始预览文件数(服务器上传文件)验证minfilecount和maxfilecount。默认为false.
468         overwriteInitial: true,   // 是否要覆盖初始预览内容和标题设置
469         previewSettings: {   // 设置显示的图片相同的宽度高度
470             image: {width: "110px", height: "110px"},
471         },
472         initialPreview:[],   // 字符串或者数组,要显示的初始预览内容
473         initialPreviewConfig:[],
474         showPreview: true
475     }
476
477 // 定义属性,拆分值
478     document.getElementById("uploadForm").style.display="block";
479     document.getElementById("bimg").style.display="none";
480     picupload.initialPreview=[];
481     var picPer=[];var authBtn='';
482     var c;var unid;var seq;pic={};
483     var pant=value.split("?")[1];
484     var pants=pant.split("&");
485     for(var i=0;i<pants.length;i++){
486         c=pants[i].split("=");
487         pic[c[0]]=c[1];
488     }
489     var encrypt = new JSEncrypt();
490     encrypt.setPublicKey(rsakey.pubkey);
491 // 判断是否存在附件信息 unid有值才执行 by by danaus 2020/4/30 11:34
492     //if ((pic.uuid != undefined&&pic.uuid != '')||(pic.oldgrid!=null && pic.oldgrid != undefined && pic.oldgrid != '') ) {   // pic.oldgrid!=null && pic.oldgrid != undefined && pic.oldgrid != ''
493
494         var picpant={};
495         try{// 赋值
496             if((pic.uuid == undefined||pic.uuid == '')&&(pic.oldgrid!=null && pic.oldgrid != undefined && pic.oldgrid != ''))
497             {
498                 var  unid = pic.oldgrid.split(';');
499                 pic['uuid'] =unid[0]+";"+unid[1];//uuid+seq
500                 // pic['seq'] = unid[1];
501                 picpant['unid']=pic['uuid'].replace("|48|48|","");
502             }
503             picpant['fieldid']=pic["fieldid"];
504             picpant['controltype']=controlType;
505             picpant['formid']=pic["formid"];
506
507             picpant['ishd']=pic['ishd'];
508             var strIs="";
509             if(pic["is1"]!=undefined&&pic["is1"]!=""){
510                 strIs="&is1="+pic['is1']+"&ishd="+pic['ishd'];
511             }else if(pic["is8"]!=undefined&&pic["is8"]!=""){
512                 strIs="&is8="+pic['is8']+"&ishd="+pic['ishd'];
513             }else{
514                 strIs="&ishd="+pic['ishd'];
515             }
516             picpant['docstatus']=pic["docstatus"]==undefined?0:pic["docstatus"];
517             picpant['rowid']=pic["rowid"];
518             picpant['usercode']=pic["usercode"];
519             picpant['doccode']=pic["doccode"];
520             picpant['headflag']=(pic['ishd']==0)?1:0;
521             try{
522                 if(picpant.doccode==undefined){
523                     picpant['doccode']=$('#doccode').val();
524                     if(picpant.doccode==undefined)
525                         picpant.doccode=panMain[panIndex].panelAuditValue.doccode;
526                 }
527                 if (picpant['doccode']&&readerUserCodes!=undefined &&readerUserCodes!='') {
528                     picpant['readerusercodes'] = readerUserCodes ;
529                 }
530
531             }catch(e){
532                 picpant.doccode="";
533             }
534             try{
535                 var picpants = JSON.stringify(picpant);
536             }catch(e){
537                 alert(e);
538             }
539             // 图片显示的方法
540             $.ajax({url:'/attachment/getAttachmentList.do',
541                 type:"POST",
542                 async:false,
543                 data:{pant:picpants},
544                 dataType:'json',
545                 success :function(data) {
546                     try {
547                         var jsons = data;
548                          if ((pic.uuid != undefined&&pic.uuid != '')||(pic.oldgrid!=null && pic.oldgrid != undefined && pic.oldgrid != '') ) {
549                         for (var i = 0; i < jsons.length; i++) {
550                             // 图片属性
551                             if (picpant.usercode == "") {
552                                 picpant.usercode = jsons[i].userCode;
553                             }
554                             if (i == 0) {
555                                 picpant.username = jsons[i].userName;
556                                 picpant.dbid = jsons[i].dbid;
557                                 picpant.domain = jsons[i].domain;
558                             }
559                             var deleToken = 'type=' + (controlType == 9 ? '1' : '3') + '&formid=' + picpant.formid + '&doccode=' + picpant.doccode + '&fieldid=' + id + '&unid=' + jsons[i].unid + '&seq=' +
560                                 jsons[i].seq + '&docstatus=' + picpant.docstatus + '&ishd=' + picpant.ishd + '&usercode=' + encodeURIComponent(encrypt.encrypt(jsons[i].authorCode)) + '&readerusercodes=' + readerUserCodes + '&dbid=' + encodeURIComponent(encrypt.encrypt(jsons[i].dbid)) + '&curUsername=' + encodeURIComponent(encrypt.encrypt(jsons[i].userName)) + '&curUsercode=' + encodeURIComponent(encrypt.encrypt(jsons[i].userCode));
561                             picupload.initialPreviewConfig.push({
562                                 'caption': jsons[i].originalFileName,   // 上传的图片名称
563                                 'filename': jsons[i].physicalFile,   // 上传文件名
564                                 'time': jsons[i].uploadTimeStr,  //上传开始时间
565                                 'name': jsons[i].authorName,  //作者名称
566                                 'size': jsons[i].fileSizeStr,   // 上传的图片大小
567                                 'type': jsons[i].fileType,   // 上传的图片类型
568                                 'key': jsons[i].seq,
569                                 'downloadUrl': jsons[i].domain + "/attachment/downLoadAttachment.do?filePath=" + getAttachmentUrl(jsons[i].staticUrl, jsons[i].formid, jsons[i].unid + "@p@" + jsons[i].seq, "", jsons[i].dbid, false, 60, 60, jsons[i].orgFileType, true),
570                                 'url': jsons[i].domain + '/attachment/deleteAttachmentV2.do?' + deleToken
571                             });   // 附件删除路径
572
573                             // 判断是否需要权限,如果要那么就加载权限按钮属性
574                             if (jsons[i].authorCode != null && jsons[i].authorCode == picpant.usercode) {   // authorCode 作者
575                                 authBtn = '<a href="javascript:authorize(\'' + jsons[i].unid + '\',\'' + jsons[i].seq + '\');" ' +
576                                     'class="btn btn-kv btn-default btn-outline-secondary" title="授权" style="padding: 0px;">' +
577                                     '<i class="glyphicon glyphicon-lock" style="padding-top: 6px;"></i></a>';   // 授权按钮
578                             }
579                             // 添加图片权限
580                             picPer.push({
581                                 key: jsons[i].seq, isAllowDelete: jsons[i].hasDelete, isAllowUpdate: jsons[i].hasUpdate,
582                                 isAllowDownload: jsons[i].hasDownload, authBtn: authBtn
583                             });
584                             // 图片
585                             picupload.initialPreview.push('<img src="' + getAttachmentUrl(jsons[i].staticUrl, jsons[i].formid, jsons[i].unid + "@p@" + jsons[i].seq, jsons[i].domain, jsons[i].dbid, false, 60, 60, jsons[i].orgFileType) + '" style="height: 60px;" class="kv-preview-data file-preview-image" title="文件名:' + jsons[i].originalFileName + ' \n类型:' + jsons[i].fileType + ' \n大小:' + jsons[i].fileSizeStr + ' \n上传者:' + jsons[i].authorName + ' \n上传时间:' + jsons[i].uploadTimeStr + '">');
586 //                            picupload.initialPreview.push('<img src="'+jsons[i].domain+jsons[i].src+'" style="height: 60px;" class="kv-preview-data file-preview-image">');
587                         }
588                         var upToken = 'type=' + (controlType == 9 ? '1' : '3') + '&formid=' + picpant.formid
589                             + '&doccode=' + picpant.doccode + '&fieldid=' + picpant.fieldid
590                             + '&usercode=' + encodeURIComponent(encrypt.encrypt(picpant.usercode)) + '&username=' + encodeURIComponent(encrypt.encrypt(picpant.username)) + '&dbid=' + encodeURIComponent(encrypt.encrypt(picpant.dbid))
591                             +strIs+'&rowid=' + picpant.rowid + '&uuid=' + (picpant.unid == undefined ? "" : picpant.unid);
592                         picupload.uploadUrl = picpant.domain + '/attachment/uploadAttachmentV2.do?' + upToken; // 附件上传路径
593                         // $('#'+id).val(pic.unid);
594                         picupload.maxFileCount = 1;   // 为每个多次上载允许的最大文件数。如果设置为0,则意味着允许的文件数是无限的。默认值为0。
595                         picupload.isNine = true;
596                         picupload.validateInitialCount = true;   // 是否包括初始预览文件数(服务器上传文件)验证minfilecount和maxfilecount。默认为false.
597                         picupload.overwriteInitial = false;   // 是否要覆盖初始预览内容和标题设置
598                         $('#fileUpload_up').fileinput('destroy');   // 销毁文件输入控件并恢复到普通的本地文件输入
599                         var uploadObj = $('#fileUpload_up').fileinput(picupload);   // 加载图片显示
600                         others();
601                         picBtn(picPer, picupload, pic["fieldid"]);   //picupload 控制审核后不能删除
602
603                          }else{
604                              picupload.maxFileSize=jsons[0].allowMaxFileSize;//从后台取数回来 by danaus 2020/8/7 10:47
605                              picupload.initialPreviewConfig.push({
606                                  'caption':'',   // 上传的图片名称
607                                  'filename':'',   // 上传文件名
608                                  'time':'',  //上传开始时间
609                                  'name':'',  //作者名称
610                                  'size':'',   // 上传的图片大小
611                                  'type':'',   // 上传的图片类型
612                                  'key':''
613                              });
614                              picupload.initialPreview=[];   // 字符串或者数组,要显示的初始预览内容
615
616                              picupload.uploadUrl = pic.domain+'/attachment/uploadAttachmentV2.do?type='+(controlType == 9?'1':'3')+'&formid=' + pic.formid
617                                  + '&doccode=' + pic.doccode + '&fieldid=' + pic.fieldid
618                                  + '&usercode='+encodeURIComponent(encrypt.encrypt(pic.usercode))+'&username='+encodeURIComponent(encrypt.encrypt(pic.username))+'&dbid='+encodeURIComponent(encrypt.encrypt(pic.dbid))
619                                  + strIs+'&rowid=' + pic.rowid + '&uuid=' + (pic.unid==undefined?"":pic.unid); // 附件上传路径
620                              //$('#'+id).val(pic.unid);
621                              picupload.maxFileCount=1;   // 为每个多次上载允许的最大文件数。如果设置为0,则意味着允许的文件数是无限的。默认值为0。
622                              picupload.isNine=true;
623                              picupload.validateInitialCount=true;   // 是否包括初始预览文件数(服务器上传文件)验证minfilecount和maxfilecount。默认为false.
624                              picupload.overwriteInitial=false;   // 是否要覆盖初始预览内容和标题设置
625                              $('#fileUpload_up').fileinput('destroy');   // 销毁文件输入控件并恢复到普通的本地文件输入
626                              var uploadObj = $('#fileUpload_up').fileinput(picupload);   // 加载图片显示
627
628                              others();
629                              picBtn(picPer,picupload,id);   //picupload 控制审核后不能删除
630                          }
631                     } catch (e) {
632                         console.log(e);
633                         alert(e);
634                     }
635
636                 }
637             });
638         }catch(e){alert(e);}
639
640 }
641 var uploadKey=[];
642 //图片上传触发事件
643 function picevent(id,isGrid,obj){
644     if(typeof(myFresh)=="undefined") myFresh={};
645     myFresh.mygrid=obj;
646     $('#'+id+'_up').on('fileuploaderror', function(event, data, msg) {
647         var temp=data;
648
649     }).on('filesuccessremove', function(event, id) {   // 使用缩略图删除按钮删除成功上传的缩略图后,会触发此事件
650         var unid=$('#'+id ).find("img").attr("unid");
651         var val=JSON.parse(unid);
652         var uuid=val.key.split(";")[0];
653           var seq=val.key.split(";")[1];
654         $.ajax({
655             type:"POST",
656             dataType:'json',
657             url:'/attachment/deleteOwnerAttachment.do?type='+val.type+'&unid='+uuid+'&seq='+seq,   // 删除路径
658             success: function(data){
659                 var newUid=val.oldKey==""?"":val.oldKey.replace(";"+seq,"");
660                 $('#'+val.filedId).val(newUid);
661             }
662         });    
663 //        $.each(uploadKey,function(i,val) {
664 //            if(val.md5==img_md5){
665 //                var uuid=val.key.split(";")[0];
666 //                var seq=val.key.split(";")[1];
667 //                $.ajax({
668 //                    type:"POST",
669 //                    dataType:'json',
670 //                    url:'/attachment/deleteOwnerAttachment.do?type='+val.type+'&unid='+uuid+'&seq='+seq,   // 删除路径
671 //                    success: function(data){
672 //                        var newUid=val.oldKey==""?"":val.oldKey.replace(";"+seq,"");
673 //                        $('#'+val.filedId).val(newUid);
674 //                    }
675 //                });
676 //            }
677 //        });
678         
679     }).on('filepredelete', function(event, params) {   // 在删除initialPreview内容集中的每个缩略图文件之前触发此事件
680         event.stopImmediatePropagation();
681         if(!confirm("您确定要删除吗?")){
682             //处理不删除图片操作
683             return false;
684         }
685
686     }).on('filedeleted', function(event, key) {   // 在删除initialPreview内容集中的每个缩略图文件之后触发此事件
687         if(isGrid=='grid'){   // 格线
688             try{
689                 if(myFresh.mygrid){
690                     var grid=myFresh.mygrid.id;
691                     var obj="";
692                     grid.SetValue(myFresh.mygrid.row, myFresh.mygrid.col,obj,0);
693                     grid.RefreshCell(myFresh.mygrid.row, myFresh.mygrid.col);
694                 }
695             }catch(e){alert(e);}
696         }else{   // 面板
697             var va =$('#'+id).val();
698             va = va.replace(";"+key,"");
699             if(va.indexOf(";")<0) va="";
700             $('#'+id).val(va);
701             panMain[panIndex].isChange =1;  //解决110101上传后删除附件不成功,而出现多个序号的问题
702         }        
703         $('#'+id+'_up').fileinput({uuidkey:key});
704
705     }).on('filebatchuploadsuccess', function(event, data, previewId, index) {   // 此事件仅在ajax上传且文件批量上传成功之后触发        
706         // get_filemd5sum(data,id);
707         // console.log("tmp.md5:"+tmp.md5);
708         // tmp.md5=$.md5(data.reader.result);
709         var tmp={};
710         var oldKey=$('#'+id).val();   // 旧的值
711          var newKey=data.response.uuid?data.response.uuid+";":"";   // 新的值
712          if(oldKey!=""){
713              var keys=oldKey.split(";");
714              for(var i=1;i<keys.length;i++){
715                  newKey=newKey.replace(";"+keys[i]+";",";");
716              }
717          }
718          tmp.key=newKey;
719          tmp.type=data.response.type;
720          tmp.filedId=id;
721          tmp.oldKey=oldKey;
722         var unid = data.response.uuid?data.response.uuid:"";
723         data.thumb.find("img").attr("unid",JSON.stringify(tmp));
724            this.uuidkey = unid;
725            $('#'+id).val(unid);
726            if(myFresh.mygrid){   // 格线
727                var grid=myFresh.mygrid.id;
728                var obj=unid+";"+data.response.fileType;// by by danaus 2020/4/30 11:32
729                grid.SetValue(myFresh.mygrid.row, myFresh.mygrid.col,obj,0);
730                grid.RefreshCell(myFresh.mygrid.row, myFresh.mygrid.col);
731            }
732
733     }).on('filebatchuploadcomplete', function(event, files, extra) {   // 此事件仅对于ajax上传且完成同步或异步ajax批量上传后触发
734         console.log(event);
735         console.log('File batch upload complete');
736
737     }).on("filebatchselected", function(event, files) {   // 在预览中选择并显示一批文件后触发此事件
738         if(myFresh.mygrid){   // 格线
739             $('#'+id+'_up').fileinput('upload');
740         }
741         else{
742             upSub(id);   // 触发修改(面板有内容改动)
743             $('#'+id+'_up').fileinput('upload',{uuidurl:$('#'+id).val()});   // 触发所选文件的ajax上传。仅适用于uploadUrl已设置的情况。此方法将文件输入元素作为jQuery对象返回,因此可以链式调用其他方法。
744         }
745
746     }).on('filezoomshown', function(event, params) {   // 在模态框已被用户看到之后触发此事件(将等待CSS转换完成)
747         $(".modal-backdrop").attr("class", "");
748         $(".modal-content").css( "zIndex", 999999);
749
750     }).on('filebrowse', function(event) {   // 单击文件浏览按钮以打开文件选择对话框时触发此事件
751         try{
752             if(typeof(fileupload_config)=="undefined"){
753                 if(myFresh.mygrid){
754                     var grid=myFresh.mygrid.id;
755                     if(grid.Cols[myFresh.mygrid.col].CanEdit==0){
756                         event.preventDefault=false;
757                         return false;
758                     }
759                 }
760             }else{
761                 if(!fileupload_config.browseOnZoneClick){
762 //                  if(typeof(event.preventDefault)!=="function")
763                     event.preventDefault();
764 //                    event.preventDefault=false;
765 //                  return false;
766                 }
767             }
768         }catch(e){
769             alert(e);
770         }
771
772     }).on('fileuploaderror', function(event, data, msg) {   // 此事件仅在ajax上传时触发,并且主要针对ajax上传时遇到上载或文件输入验证错误
773         var form = data.form, files = data.files, extra = data.extra,
774             response = data.response, reader = data.reader;
775     });
776 }
777
778 function get_filemd5sum(data, id) {
779     var tmp = {};
780     var file = data.files[0];
781     var tmp_md5;
782     var blobSlice = File.prototype.slice || File.prototype.mozSlice
783             || File.prototype.webkitSlice,
784     // file = this.files[0],
785     chunkSize = 8097152, // Read in chunks of 2MB
786     chunks = Math.ceil(file.size / chunkSize), currentChunk = 0, spark = new SparkMD5.ArrayBuffer();
787     var fileReader = data.reader;
788
789     fileReader.onload = function(e) {
790         // console.log('read chunk nr', currentChunk + 1, 'of', chunks);
791         spark.append(e.target.result); // Append array buffer 追加数组缓冲器
792         currentChunk++;
793         var md5_progress = Math.floor((currentChunk / chunks) * 100);
794         console.log(file.name + "  正在处理,请稍等," + "已完成" + md5_progress + "%");
795         // var handler_info = document.getElementById("handler_info");
796         // var progressbar = document.getElementsByClassName("progressbar")[0];
797         // handler_info.innerHTML = file.name + " 正在处理,请稍等," + "已完成" +
798         // md5_progress + "%"
799         // progressbar.value = md5_progress;
800         if (currentChunk < chunks) {
801             loadNext();
802         } else {
803             tmp.md5 = spark.end();
804             console.log("-------------tmp.md5:" + tmp.md5)
805             var oldKey = $('#' + id).val(); // 旧的值
806             var newKey = data.response.uuid ? data.response.uuid : ""; // 新的值
807             if (oldKey != "") {
808                 var keys = oldKey.split(";");
809                 for (var i = 1; i < keys.length; i++) {
810                     newKey = newKey.replace(";" + keys[i], "");
811                 }
812             }
813             tmp.key = newKey;
814             tmp.type = data.response.type;
815             tmp.filedId = id;
816             tmp.oldKey = oldKey;
817             uploadKey.push(tmp);
818             var unid = data.response.uuid ? data.response.uuid : "";
819             this.uuidkey = unid;
820             $('#' + id).val(unid);
821             if (myFresh.mygrid) { // 格线
822                 var grid = myFresh.mygrid.id;
823                 var obj = data.response.path ? data.response.path : "";
824                 grid.SetValue(myFresh.mygrid.row, myFresh.mygrid.col, obj, 0);
825                 grid.RefreshCell(myFresh.mygrid.row, myFresh.mygrid.col);
826             }
827         }
828     };
829
830     fileReader.onerror = function() {
831         console.warn('oops, something went wrong.');
832     };
833
834     function loadNext() {
835         var start = currentChunk * chunkSize, end = ((start + chunkSize) >= file.size) ? file.size
836                 : start + chunkSize;
837         fileReader.readAsArrayBuffer(blobSlice.call(file, start, end));
838     }
839     loadNext();
840 }
841 function others() {
842     // 上传控件的一些控制
843     $(".file-footer-caption").css("display", "none");
844     $(".file-thumbnail-footer").css("height", "10px");
845     $(".glyphicon-download").css("padding-top", "6px");
846     $(".btn").css("padding", "0px");
847     $(".fileinput-remove").css("display", "none"); // 隐藏控件右上角的清除按钮(叉号)
848     $(".glyphicon-move").css("display", "none"); // 隐藏控件的移动按钮
849     try {
850         $(".file-caption-main").css("display", "none");
851     } catch (e) {
852         alert(e);
853     }
854     
855 }
856 function getReturnValue(str) {
857     if (window.ActiveXObject) { // IE
858         window.returnValue = str;
859         window.close();
860     } else { // 非IE
861         if (window.opener) {
862             window.opener.setValue(str); // 直接调用父页面的方法来操作处理
863             window.close();
864         }
865     }
866 }
867
868 // 9 ,19控件授权
869 function authorize(unid,seq){
870     parent.addTab('',9763,10,'wherePan=unid=\''+unid+'\' and seq='+seq);
871 }
872 // 权限按钮属性显示
873 function picBtn(picPer,uploadObj,fieldid) {
874     var findObj = "#uploadDiv_"+ fieldid + " .kv-file-remove" ;
875     var delBtn = $(findObj); // 删除
876     for (var i = 0; i < delBtn.length; i++) {
877         var dataKey = $(delBtn[i]).attr("data-key");
878         for (var j = 0; j < picPer.length; j++) {
879             if ((dataKey == picPer[j].key && !picPer[j].isAllowDelete )
880                     ||uploadObj.browseOnZoneClick) {   //控制删除按钮在最终审核后,所有人都不能进行删除
881                 $(delBtn[i]).hide();
882             }
883         }
884     }
885     var downBtn = $(".glyphicon-download"); // 下载
886     for (var i = 0; i < downBtn.length; i++) {
887         var a = $(downBtn[i]).parent();
888         var href = $(a).attr("href");
889         if (href == null)
890             continue;
891         for (var j = 0; j < picPer.length; j++) {
892             if (href.indexOf(";" + picPer[j].key) >= 0) {
893                 if (!picPer[j].isAllowDownload ) {
894                     $(a).hide();
895                 }
896                 if (picPer[j].authBtn != "") {
897                     $(a).before(picPer[j].authBtn)
898                 }
899             }
900         }
901     }
902 }
903 function openNewDoc() {
904     var flag = checkSession();// session失效后弹出登录框,flag为true时表示已经失效
905     if(flag){
906         return;
907     }
908     openByType($(this).attr("docType"));
909 }
910 function openByType(type) {
911     try {
912         if(type==undefined) type=$("#tpNewDoc").attr("docType");
913         parent.addTab('', formId, type);
914     } catch (e) {
915         alert(e);
916         showWindow("/app" + spellPath + formId + "/" + type + "/index.jsp");
917     }
918 }
aa5c59 919 function openOldXlsImport(title,doccode){
X 920     //旧版本调用
921     try {
922         var url = "/general/xlsImport.jsp";
923         url+="?title="+title+"&doccode="+doccode+"&formid="+formId+"&formType="+formType;
924         parent.changFrame = inThisFrame;
925         parent.addTab(formId + "数据导入管理", '', '', '', url);
926     } catch (e) {
927         window.open(url);
928     }
929 }
a6a76f 930 $( function() {
F 931     try{top.myFresh.formType=formType;top.myFresh.panel[top.tabindex]=formType;}catch(e){}//关闭页卡排除的窗体类型。
932     $("#loading").css("opacity", '0.8');
933     if (typeof (formId) != "undefined") {
934         if (parent.getTabSelected!=undefined&&parent.getTabSelected().panel!=undefined&&parent.getTabSelected().panel("options").title.indexOf("加载中") != -1) {
935             var title = $("title").html() + "--" + formId;
936             parent.resetTabName(title);
937         }
938     }
939
940     $("#tpNewDoc,#tpDocList").click(openNewDoc);
941     $.getScript("/js/index/query.js"); // 加载查询js
942     setTimeout( function() {
943         closeLoading();
944     }, 400);
945     $("#otherFormat").click(function(){
946         var flag = checkSession(); // session失效后弹出登录框,flag为true时表示已经失效
947         if(flag){
948             return;
949         }
950         var url = "/general/report.jsp?formId=" + formId + "&formType="
951             + formType;
952         try {
953             parent.addTab(formId + "报表格式管理", '', '', '', url);
954         } catch (e) {
955             window.open(url);
956         }
957         moreWindowClose(); // 2、3类型更多按钮的关闭事件
958     });
959
960
961     $("#importXls").click(function() {
aa5c59 962         var url = "/general/xlsImport1.jsp";
X 963         var title = $('#title_top').html();
964         var doccode = $('#doccode').val();
965         doccode = (doccode != null ? doccode : "");
966         url += "?title=" + title + "&doccode=" + doccode + "&formid=" + formId + "&formType=" + formType;
a6a76f 967         try {
aa5c59 968             var xlsContent = layer.open({
X 969                 type: 2,
970                 title: '',
971                 maxmin: false,
972                 skin: 'layui-layer-molv',
973                 shadeClose: true, //点击遮罩关闭层
974                 area: ['700px', '350px'],
975                 content: url
976             });
a6a76f 977         } catch (e) {
aa5c59 978             openOldXlsImport(title, doccode);
a6a76f 979         }
F 980     });
981     $("#tpbuild").click( function() {
982         var flag = checkSession();//session失效后弹出登录框,flag为true时表示已经失效
983         if(flag){
984             return;
985         }
986         var fid = $("#formid").val();
987         if (undefined == fid || fid == null || fid == "") {
988             $.messager.alert("操作提示", "请输入功能号!","warning");
989             return;
990         }
991         try {
992             parent.addTab("生成" + fid, "", "", "", "/buildv2.do?formID=" + fid);
993         } catch (e) {
994         }
995     });
996     $("#tpselect").click( function() { // 选择按钮
997         var flag = checkSession(); // session失效后弹出登录框,flag为true时表示已经失效
998         if(flag){
999             return;
1000         }
1001         if (2 == formType || 20 == formType) {
1002             $(".simpleTree").find(".active").dblclick(); // 获取返回值在simple.tree.js文件执行
1003
1004         } else {
1005             try {
1006                 mygrid.buttonClicked();
1007             } catch (e) {
1008             }
1009         }
1010     });
1011     $("#func").menu( {
1012         onShow : function() {
1013             setBackGournd4ie6("#func");
1014         },
1015         onHide : function() {
1016             hideBackGournd4ie6();
1017         }
1018     });
1019     $("#print").menu( {
1020         onShow : function() {
1021             setBackGournd4ie6("#print");
1022         },
1023         onHide : function() {
1024             hideBackGournd4ie6();
1025         }
1026     });
1027     // parent.openByFormId({formId:9802,formType:9901});
1028 });
1029
1030 function setBackGournd4ie6(id) {
1031     var iframe = $("#bg4ie6");
1032     if (null == iframe.html()) {
1033         iframe = $(
1034             "<iframe id='bg4ie6' style='position:absolute;z-index:3;border:0px;'/>")
1035             .appendTo($("body"));
1036     }
1037     var off = $(id).offset();
1038     var h = $(id).height() + 5;
1039     var w = $(id).width();
1040     var t = off.top;
1041     var l = off.left;
1042     iframe.css( {
1043         width :w,
1044         height :h,
1045         top :t,
1046         left :l
1047     }).show();
1048 }
1049 function hideBackGournd4ie6() {
1050     $("#bg4ie6").hide();
1051 }
1052 var self_datafields=""; // 返回自表字段的值
1053 // f:功能号     t:功能类型    sf:自身字段    lf:外表字段    lk:为1时执行存储过程,0显示界面,3弹出层
1054 // sd:自表字段 ld:外表字段     isp:         ef:where条件语句    mes:提示信息
1055 // clo:1表示关闭
1056 function funcLink(f, t, sf, lf, lk, sd, ld, isp, ef, mes, ref, clo, autoSave,sortid,messageTip) {
1057     var flag = checkSession(); // session失效后弹出登录框,flag为true时表示已经失效
1058     if(flag){
1059         return;
1060     }
1061     showLoading();
1062     self_datafields=sd;
1063     // lqc
1064     if(typeof(f)=="string" && f.toLowerCase()=="formid" && formId!="" && typeof(formId)=="number" ){
1065         f=formId;
1066     }
1067     // end
1068     // 为了兼容以前代码,先判断是否存在以;分隔。没有则按新的处理方式,以@p@分隔
1069     // by danaus 2017-8-21
1070     var sfs =null;
1071     var lfs =null;
1072     var split=";";
1073     if(sf.indexOf("@p@")>0) split="@p@";
1074     lfs=lf.split(";"); // 字段分隔固定用;
1075     sfs=sf.split(split);
1076     if (sfs.length != lfs.length) {
1077         $.messager.alert('警告', "请检查外表字段与自身字段是否设置正确!", 'error');
1078         return;
1079     }
1080     if (mes&&mes.indexOf("&") != -1 && t == "22") {
1081         if (typeof (mygrid) != "undefined") {
1082             var rows = mygrid.getFieldForNew();
1083             var strTi = mes;
1084             var lit = new Array()
1085             var str1 = "";
1086             var tv = "";
1087             var ti = 0;
1088             while (strTi.indexOf("&") != -1) {
1089                 strTi = strTi.substring(strTi.indexOf("&") + 1);
1090                 if (mes.indexOf("&") != -1) {
1091                     str1 = strTi.substring(0, strTi.indexOf("&"));// .trim()
1092                     if (str1 != "") {
1093                         lit[ti] = str1;
1094                         ti++;
1095                         strTi = strTi.substring(strTi.indexOf("&") + 1);
1096                     }
1097                 }
1098             }
1099             for (var i = 0; i < lit.length; i++) {
1100                 tv = getValue((lit[i]).toLowerCase(), null, rows[0]);
1101                 mes = mes.replace("&" + lit[i] + "&", tv);
1102             }
1103
1104         }
1105     }
1106     if (mes && $.trim(mes) != "") { // 有提示信息
1107         //$.messager.defaults = { ok: "是", cancel: "否" };
1108         $.messager.confirm('提示', mes, function(r) {
1109             if (r) {
1110                 funcLink$(f, t, sfs, lfs, lk, sd, ld, isp, ef, ref, clo,
1111                     autoSave,sortid,messageTip);
1112                 $('.panel-tool-close').show(); 
1113             }else {
1114                 closeLoading(); //更新客户状态的取消
1115                 $('.panel-tool-close').show(); 
1116             }
1117         }, "warning");
1118         $('.panel-tool-close').hide(); //取消更新客户状态的弹出框红叉      yang 2020-04-26
1119     } else {
1120         funcLink$(f, t, sfs, lfs, lk, sd, ld, isp, ef, ref, clo, autoSave,sortid,messageTip);
1121     }
1122     // 系统消息
1123     if(messageTip!=null && messageTip.indexOf(",")!=-1){
1124         var value=messageTip.split(",");
1125         if(value[1]=="message"){
1126             $.post("/usrReaded.do",{"messid":value[0]});
1127             // $.messagerTip.close();
1128         }
1129     }
1130     //moreWindowClose(); // 2、3类型更多按钮的关闭事件
1131 }
1132
1133 function funcLink$(f, t, sfs, lfs, lk, sd, ld, isp, ef, ref, clo, autoSave,sortid,messageTip) {
1134     if (isp && isp == "1") {
1135         showPwd(f, t, function() {
1136             funcLink$$(f, t, sfs, lfs, lk, sd, ld, ef, ref, clo, autoSave,sortid,messageTip);
1137         });
1138     } else {
1139         funcLink$$(f, t, sfs, lfs, lk, sd, ld, ef, ref, clo, autoSave,sortid,messageTip);
1140     }
1141 }
1142 var savedExecFunclink;
1143 function funcLink$$(f, t, sfs, lfs, lk, sd, ld, ef, ref, clo, autoSave,sortid,messageTip) {
1144     savedExecFunclink = null;
1145     if (t == "22") {
1146         // autoSave=='1'是要先执行保存
1147         if (typeof (autoSave) != 'undefined' && '1' == autoSave) {
1148             var param = arguments;
1149             if(typeof (sortid) != 'undefined'&&(formType == "16"||formType == "5")){
1150                 savedFunclink16=param[0]+";"+param[1]+";"+sortid+";taobao";
1151                 save(2);
1152             }else{
1153                 savedExecFunclink = $(function(){
1154                     execProc(param[0], param[1], param[2], param[3], param[4],
1155                         param[8], param[9],messageTip);
1156                 });
1157             }
1158         } else {
1159             execProc(f, t, sfs, lfs, lk, ref, clo,messageTip);
1160         }
1161     } else {
1162         // autoSave=='1'是要先执行保存
1163         if (typeof (autoSave) != 'undefined' && '1' == autoSave) {
1164             var param = arguments;
1165             savedExecFunclink = $(function(){
1166                 funclink$$$(param[0], param[1], param[2], param[3], param[4],
1167                     param[5], param[6], param[7], param[8], param[9]);
1168             });
1169         } else {
1170             var lfsStr=lfs.join(","); // 把传进来的外表字段(数组类型)跟自表字段(数组类型)转换成字符串
1171             var sfsStr=sfs.join(",")
1172
1173             var _={}
1174             _.formParm=ld; // 外表字段
1175             _.toParm=sd; // 自表字段
1176
1177             if(typeof(mygrid)!="undefined"){
1178                 try{
1179                     mygrid.setGridInfoTOPop(_,mygrid);
1180                 }catch(e){
1181
1182                 }
1183
1184             }
1185
1186             funclink$$$(f, t, sfs, lfs, lk, sd, ld, ef, ref, clo,messageTip);
1187         }
1188     }
1189 }
1190 function prossDate(key,mygrid,rows,k) {
1191     try{
71e46f 1192         key = key.toLowerCase();
a6a76f 1193         if(mygrid.Cols[key].Type&&mygrid.Cols[key].Type=="Date"&&DateToString){//增加处理日期问题,时间有可能是用毫秒数表示的情况,by danaus 2019/11/25 15:45
F 1194                 rows[k][key]=DateToString(rows[k][key],mygrid.Cols[key].Format);
1195         }
1196     }catch(e){}
1197 }
1198 function funclink$$$(f, t, sfs, lfs, lk, sd, ld, ef, ref, clo,messageTip) {
1199
1200     var rows=[];
1201     var num=0;
1202     if (typeof (mygrid) != "undefined") {
1203         rows=mygrid.getFieldForNew();
1204         num=rows.length;
1205     }else{ // 没格线则取0;
1206         num=1;
1207     }
1208     var temp = null;
1209     var strPam="";
1210     for (i = 0; i < sfs.length; i++) {
1211         var selfStr ="";
1212         for(var k=0;k<num;k++){ // 选中多少行,for多少
1213             if ($.trim(sfs[i]) == "")
1214                 break;
1215             // 系统消息
1216             if(messageTip!=null && messageTip.indexOf(",")!=-1){
1217                 var value=messageTip.split(",");
1218                 if(value[1]=="message"){
1219                     temp=sfs[i];
1220                 }
1221             }else{ // end
1222                 var key=sfs[i].toLowerCase();
1223                 if (typeof (mygrid) != "undefined") {
1224                     prossDate(key, mygrid, rows, k);
1225                 }
1226                 temp = getValue(key,null,rows[k]);
1227             }
1228             if (temp == undefined || temp == null) {
1229                 temp = sfs[i];
1230             } else if (temp == "null")
1231                 temp = "";
1232             if(selfStr=="")
1233                 selfStr += lfs[i] + "='" + ("" + temp).replaceAll("'", "")+"'";
1234             else
1235                 selfStr +=",'"+("" + temp).replaceAll("'", "")+"'";
1236         }
1237
1238         if(strPam=="")
1239             strPam+=selfStr
1240         else
1241             strPam+=" and "+selfStr
1242     }
1243 //    selfStr +=(temp=="" ? "(" : "")+ lfs[i] + "='" + ("" + temp).replaceAll("'", "")
1244 //        + ((i < sfs.length - 1) ? "'"+(temp=="" ? (" or "+lfs[i]+" is null)") : "")+" //and " : "'"+(temp=="" ? ")" : "")); //修改时间 2014-12-8 ---辛
1245     // lfs 外表字段名
1246
1247
1248
1249     var wp = $.trim(selfStr).length > 0 ? ("wherePan=" + strPam) : "";
1250     if (ef != undefined && ef != null && ef != "")
1251         wp = (wp == "") ? "wherePan=" + encodeURI(encodeURI(ef)) : wp + " and "
1252             + encodeURI(encodeURI(ef));
1253     try {
1254         closeLoading();
1255         parent.addTab("", f, t, wp);
1256     } catch (e) {
1257         closeLoading();
1258         showWindow("/app" + spellPath + f + "/" + t + "/index.jsp?" + wp, "");
1259     }
1260 }
1261
1262 var execParams = []; // 22窗体传值 lk表示是否打开界面或弹出层
1263 function execProc(f, ft, sfs, lfs, lk, ref, clo,exec) { // 储存过程
1264     var paramVa = "";
1265     var t = null;
1266     var rows=[];
1267     var num=0;
1268     if (typeof (mygrid) != "undefined") {
1269         rows=mygrid.getFieldForNew();
1270         num=rows.length;
1271     }else{ // 没格线则取0;
1272         num=1;
1273     }
1274     var sp=";";
1275     for(var s=0;s<sfs.length;s++){
1276         if(sfs[s]!=""&&isNaN(sfs[s])&&sfs[s].indexOf(";")>0){
1277             sp="@p@";
1278             break;
1279         }
1280     }
1281     for(var k=0;k<num;k++){ // 选中多少行,for多少
1282         if(k>0) paramVa += "こ"; // 把用来隔开字段的逗号(,)替换成こ 逗号的使用率高  做字段的隔开不好 有时出现错误 所以改成こ 2014-9-26
1283         for (i = 0; i < sfs.length; i++) {
1284             if(i>0) paramVa += sp;
1285             if ($.trim(sfs[i]) == "") {
1286
1287                 continue;
1288             }
1289             if (sfs[i].indexOf("@") != -1 || $.trim(sfs[i]) == "") {
1290                 paramVa += sfs[i];
1291                 continue;
1292             }
1293             var key=sfs[i];
1294             try{
1295                 if (typeof (mygrid) != "undefined") {
1296                     prossDate(key, mygrid, rows, k);
1297                 }
1298             }catch(e){}
1299             t = getValue(key,null,rows[k]);
1300             if (t==null||t=="null")
1301                 t = sfs[i];
1302             if(isNaN(t)&&t.indexOf(";")>0){ // 当内容存在;情况,需要替换 by danaus
1303                 sp="@p@";
1304                 paramVa=paramVa.replace(/;/g,sp); // 把之前的;也替换
1305             }
1306             paramVa += t;
1307         }
1308     }
1309     if(typeof (formId)!="undefined") {
1310         paramVa = paramVa.replaceAll("@formid", formId).replaceAll(
1311             "'", "");
1312     }
1313     var temp=paramVa.split("こ");
1314     var st="";
1315     var ln=sfs.length;
1316     for(var m=0;m<ln;m++){
1317         if(m>0) st+=sp;
1318         for(var v=0;v<temp.length;v++){
1319             var ss=temp[v].split(sp);
1320             if(v>0) st+=",";
1321             st+=(ss[m]==""?"\'\'":ss[m]); // 为""串时需要增加单引号
1322
1323
1324         }
1325     }
1326     paramVa=st;
1327     if (lk == "1") { // 直接执行存储过程
1328         //注释,执行自定义.do在后台执行,不需要在这里处理 xin 2020-5-14 11:01:40
1329         exec=((exec!=undefined&&exec.indexOf(".do")!=-1)?exec:"/execProc.do");
1330         $.post(exec, {
1331             "formid" :f,
1332             "param" :paramVa,
1333             "disableDuplicateSubmitUUID":systemUuid.uuid //by danaus 2019/11/22 11:12
1334         }, function(data) {
1335                 procCallBack(data, ref, clo);
1336         });
1337     } else {
1338         var stemp=paramVa.split("こ");
1339         var values =stemp[0].split(sp); // 只取第一个,因为新实现已可以选多行传值, paramVa.split(";");// 通过功能连接打开22类型直接通过execParams数组赋值
1340         parent.changFrame = inThisFrame;
1341         var t = [];
1342         var param = "";
1343         for (i = 0; i < values.length; i++) {
1344             t = [ lfs[i], values[i] ];
1345             execParams[i] = t;
1346             var value=values[i]; // isNaN(values[i])?(values[i].match(/&/)?values[i].replace(/&/,"@W@"):values[i]):values[i];
1347             if(value.indexOf("?")>0) value=value.replace("?","#p#");//处理有问号时 url传递有问题
1348             param += lfs[i].toLowerCase() + "=" +value+ "&";
1349         }
1350         if (param.length > 0) {
1351             param = param.substring(0, param.length - 1);
1352         }
1353         //if (param.indexOf("@") != -1) { // 去掉调用,因为在加载页面已实现
1354         //    replaceSessonKey(param, function(d) {
1355         //            parent.addTab('', f, ft, d);
1356         //    });
1357         //    } else {
1358         if(lk==3){//弹出层
1359             var url = "/app" + spellPath + f + "/" + ft + "/index.jsp?"+encodeURIComponent(param);
1360             // hotkey.js
1361             showLayerGrid(url,ref);
1362         }else{
1363             closeLoading();
1364             parent.addTab('', f, ft, param);
1365         }
1366         //    }
1367     }
1368     closeLoading();
1369 }
1370 function procCallBack(data, ref, clo) {
1371
1372     if (data == null || data == "") {// 什么也没返回
1373         $.messager.alert('提示', "进程处理完毕.", "info", function()
1374             {
1375                 if (typeof (savedExecFunclink) == "function") {
1376                     location.reload();
1377                 }
1378                 refreshOrClose(ref, clo);
1379             }
1380         );
1381     } else {
1382         try {
1383             if(data.replace(/\s+/g,"")==="(null)"){
1384                 $.messager.alert('提示', data, "info");
1385                 return;
1386             }else{
1387                 data = JSON.parse(data);
1388             if((data.msg!=undefined&&data.msg=="")&&(data.data==undefined||data.data=="")){
1389                 $.messager.alert('提示', "进程处理完毕.", "info", function()
1390                     {
1391                         if (typeof (savedExecFunclink) == "function") {
1392                             location.reload();
1393                         }
1394                         refreshOrClose(ref, clo);
1395                     }
1396                 );
1397             }
1398             }
1399         } catch (e) {
1400            alert(data.msg!=undefined?data.msg:data);
1401             refreshOrClose(ref, clo);
1402             return;
1403         }
1404         try {//by danaus 2019/11/22 17:42
1405             if (data.state=-1&&JSON.parse(data.data).isuuid) {
1406                 $.messager.show({
1407                     title: '提示',
1408                     msg: data.msg,
1409                     showType: 'show',
1410                     //timeout:3,
1411                     style: {
1412                         right: '',
1413                         top: document.body.scrollTop + document.documentElement.scrollTop,
1414                         bottom: ''
1415                     }
1416                 });
1417
1418                 return;
1419             }
1420         }catch (e) {}
1421
1422         if (data.msg!=undefined&&data.msg != ""&&data.msg!=null&&data.msg!="null"){
1423             alert(data.msg);
1424             refreshOrClose(ref, clo);
1425            // return;
1426         }
1427         if (data.data!=undefined&&data.data!=null&&data.data !=""&&data.data !="null") {
1428             redirect(data.data);
1429             return;
1430         }
1431     }
1432
1433 }
1434 function redirect(info) {
1435     if(info.indexOf("buildv2.do") > -1){ // 生成页面 by danaus 13-6-28 增加返回生成页面和打开多个功能号多张单的功能
1436         $.get(info);
1437     }else if(info.indexOf("open.callBack|") ==0){//处理第三方返回的数据,打开另一个页卡
1438         var url=info.replace("open.callBack|","");
1439       //  showLayerGrid(url,1,'900px','600px');
1440     var perContent= layer.open({
1441             type: 2,
1442             title: '德立测量单信息',
1443             maxmin: false,
1444             skin: 'layui-layer-molv',
1445             shadeClose: true, //点击遮罩关闭层
1446             area : ['1300px' , '800px'],
1447             content:  url       //'/app/67/0/cnzh/110502/1/index.jsp'
1448         });
1449         layer.full(perContent);
1450     }else{ // 打开页面
1451         var tt=info.split("|");
1452         for(var i=0;i<tt.length;i++){
1453             var t = tt[i].split(";");
1454             if (t.length != 3)
1455                 return;
1456             var temp = t[2];
1457             if (temp.indexOf("wherePan") == -1) {
1458                 var doc=temp.split(",");
1459                 for(var d=0;d<doc.length;d++){
1460                     temp = "wherePan=doccode='" + (doc[d]!=""?doc[d].replace("'","").replace("'",""):"") + "'"; // by 12-04-20 去掉内容的单引号“'”,因为当数据已有单引号时候出错
1461                     parent.addTab('', t[0], t[1], temp);
1462                 }
1463             }else{
1464                 parent.addTab('', t[0], t[1], temp);
1465             }
1466         }
1467     }
1468 }
1469 function showPwd(formId, pwdType, callBack) {
1470     $.post("/checkApprovingExists.do", {
1471         "formid" :formId,
1472         "type" :pwdType
1473     }, function(d) {
1474         pwdCallBack = callBack;
1475         if (d == "false") {
1476             $("#addPwd").dialog("open");
1477         } else {
1478             $("#openPwd").dialog("open");
1479         }
1480     });
1481 }
1482 function refreshOrClose(r, c) { // 刷新或关闭
1483     if(typeof(r)=="function"){
1484         if(opener)
1485             opener.location.reload();
1486         return;
1487     }
1488     if (r == "1") {
1489         if(location) location.reload();
1490     }else if(r=="2"){
1491         if(mygrid) mygrid.ReloadBody();
1492     }
1493     if (c == "1") {
1494        if(parent) parent.closeTab();
1495     }
1496 }
1497
1498 function showWindow(url, obj, callBack, arguments) {
1499     if (obj == undefined || obj == null || obj == '') {
1500         obj = {};
1501         obj.isDialog = 1;
1502     }
1503     // url=encodeURL(url);
1504     var param = {
1505         "url" :url,
1506         vArguments :obj,
1507         dialogWidth :(screen.availWidth - 60),
1508         dialogHeight :(screen.availHeight - 110),
1509         callBack :callBack
1510     };
1511     param = $.extend(param, arguments || {});
1512     var openPage = new myapp(param) // new 一个打开对象 **改变了窗体不是默认大小
1513     openPage.openNewWin();
1514 }
1515 function toolExit() { // 工具栏点击退出
1516     if (window.window.dialogArguments) {
1517         window.close();
1518     } else {
1519         parent.closeTab();
1520     }
1521 }
1522 function refresh() {
1523     var flag = checkSession(); // session失效后弹出登录框,flag为true时表示已经失效
1524     var gridbol=false;
1525     if(flag){
1526         return;
1527     }
1528
1529     if(this.formType!=2&&this.formType!=16&&this.formType!=22&& this.formType!=20&& this.formType!=18&& this.formType!=38){
1530         if(this.formType==3||this.formType==10){
1531              var sh=false;
1532         }else{
1533             sh=shx;
1534         }
1535         try{
1536             if(typeof (mygrid)!='undefined'){
1537                 gridbol=mygrid.checkData();
1538             }
1539             if(gridbol||sh){
1540                 $.messager.defaults = { ok: "确定", cancel: "取消" }; // 修改Button显示文字
1541                 $.messager.confirm('确认','页面内容已有改动,刷新操作将会丢失数据,确定刷新吗?',function(r){
1542                     if (r){
1543                         location.reload();
1544                         top.myFresh.panel[top.tabindex+'-t']=false;
1545                     }
1546                 });
1547                 return;
1548             }else{
1549                 location.reload();
1550                 top.myFresh.panel[top.tabindex+'-t']=false;
1551             }
1552         } catch(e){
1553             location.reload();
1554             top.myFresh.panel[top.tabindex+'-t']=false;
1555         }
1556     }else{
1557         location.reload();
1558         top.myFresh.panel[top.tabindex+'-t']=false;
1559     }
1560
1561 }
1562 /**
1563  * top页面info按钮执行函数
1564  * @returns
1565  */
1566 //function showInfo(){
1567 //    var options = {width:"300px",height:"200px",title:'信息', msg:"无", showType:'show',timeout:10000,
1568 //        style:{left:'',right:17,top:document.body.scrollTop+document.documentElement.scrollTop+68,bottom:''}}
1569 //    try{
1570 //        $.ajax({url:'/showInfo.do',
1571 //            data:{'formid' :formid.value,'doccode':doccode.value},
1572 //            type:"POST",async:false,dataType:'text',
1573 //            success:function(mes) {
1574 //                if(mes!=''){
1575 //                    options.msg='<div align="center">'+mes+'</div>';
1576 //                }
1577 //            }});
1578 //    }catch(e){
1579 //        options.msg='<div align="center">加载信息失败【错误信息:'+e+'】</div>';
1580 //    }
1581 //    $.messager.show(options);
1582 //}
1583 function showLoading() {
1584     $("#loading").show();
1585 }
1586 function closeLoading() {
1587     $("#loading").hide();
1588 }
1589 /** ***************************************** */
1590 Object.extend = function(destination, source) {
1591     for ( var property in source) {
1592         destination[property] = source[property];
1593     }
1594     return destination;
1595 }
1596 var myapp = function(o) {
1597     this.options = {
1598         url :"", // 你要打开的页面url
1599         vArguments :"window", // 你要向打开的页面传递的数据
1600         dialogWidth :500, // 打开窗口的宽度
1601         dialogHeight :500, // 你打开窗口的高度
1602         center :"yes", // center: {yes | no | 1 | 0 }:窗口是否居中,默认yes,但仍可以指定高度和宽度。
1603         help :"no", // {yes | no | 1 | 0 }:是否显示帮助按钮,默认yes
1604         resizable :"yes", // {yes | no | 1 | 0 } [IE5+]:是否可被改变大小。默认no
1605         status :"yes", // {yes | no | 1 | 0 } [IE5+]:是否显示状态栏。默认为yes[
1606         // Modeless]或no[Modal]。
1607         scroll :"yes", // { yes | no | 1 | 0 | on | off }:指明对话框是否显示滚动条。默认为yes。
1608         callBack :false
1609     };
1610     Object.extend(this.options, o || {});
1611 }
1612 myapp.prototype = {
1613     openNewWin : function(url) {
1614         var options = this.options;
1615         var l = (screen.availWidth - options["dialogWidth"]) / 2;
1616         var h = (screen.availHeight - options["dialogHeight"]) / 2;
1617         var sp = "dialogTop:" + h + "px;dialogLeft:" + l + "px;dialogWidth:"
1618             + options["dialogWidth"] + "px;dialogHeight:"
1619             + options["dialogHeight"] + "px;center:" + options["center"]
1620             + ";help:" + options["help"] + ";resizable:"
1621             + options["resizable"] + ";status:" + options["status"]
1622             + ";scroll:" + options["scroll"];
1623         var newWin = null;
1624         if(window.showModalDialog!=undefined){
1625             newWin = window.showModalDialog(options["url"],options["vArguments"], sp);
1626             var call = options["callBack"];
1627             if (typeof call == "function") { // 调用 数据处理函数
1628                 call(newWin);
1629             }
1630         }else{
1631             window.open(options["url"],options["vArguments"], "height="+options["dialogHeight"]+",width="+options["dialogWidth"]+",top=300,left=350");
1632         }
1633         // var newWin = window.showModalDialog(options["url"],
1634         //        options["vArguments"], sp);
1635         // var call = options["callBack"];
1636         // if (typeof call == "function") {// 调用 数据处理函数
1637         //        call(newWin);
1638         //}
1639     },
1640     setOptions : function() {
1641     }
1642 }
1643 /** *************************************************************** */
1644 function encodeURL(url) {
1645     try {
1646         url = parent.encodeURL(url);
1647     } catch (e) {
1648     }
1649     return url;
1650 }
1651 function encodeText(t) {
1652     try {
1653         t = parent.encodeText(t);
1654     } catch (e) {
1655     }
1656     return t;
1657 }
1658 // 为String类添加replaceAll函数
1659 String.prototype.replaceAll = function(AFindText, ARepText) {
1660     raRegExp = new RegExp(AFindText, "g");
1661     return this.replace(raRegExp, ARepText)
1662 }
1663 Array.prototype.del = function(n) { // 为数组添加删除元素的函数
1664     if (n < 0)
1665         return this;
1666     else
1667         return this.slice(0, n).concat(this.slice(n + 1, this.length));
1668 }
1669 function replaceSessonKey(str, callback) { // 替换session值
1670     $.post("/replaceSessionKey.do", {
1671         "paramter" :str
1672     }, function(data) {
1673         callback(data);
1674     });
1675 }
1676 function replacePageValue(str) { // 替换页面值
1677     var list = new Array();
1678     var i = 0;
1679     var temp = null;
1680     var postion = 0;
1681     while (str.indexOf("&", i) != -1) {
1682         i = str.indexOf("&", i) + 1;
1683         postion = str.indexOf("&", i);
1684         if (postion == -1)
1685             break;
1686         temp = str.substring(i, postion);
1687         i = postion + 1;
1688         list.push(temp);
1689     }
1690     for (i = 0; i < list.length; i++) {
1691         temp = getValue(list[i]);
1692         str = str.replaceAll("&" + list[i] + "&",
1693             (temp == null || temp == "null") ? list[i] : temp);
1694     }
1695     return str;
1696 }
1697 function getValue(str,format,row) { // 获取页面值
1698     var t;
1699     try {
1700         t = getDoc(str.toLowerCase(), ".value");
1701     } catch (e) {
1702         t=undefined; // by danaus  出现异常赋值   作为判断识别
1703     }
1704     if(t==null){ // 只有是这种情况才需要继续向下查找 by danaus 原则:如果页面上有这个字段定义,不管它是什么值,都把它替换,如果没有这个字段,就继续向下查找,直到没有 则不用替(传什么就是什么)
1705
1706         if (typeof (mygrid) != "undefined") {
1707             try {
1708                 var d=t; // 保存原值
1709                 if(row!=undefined){
1710                     t = (row[str.toLowerCase()+"Link"]!==undefined)?row[str.toLowerCase()+"Link"]:((row[str.toLowerCase()]==undefined)?null:row[str.toLowerCase()]);
1711                 }else{
1712                     t=mygrid.getField(str.toLowerCase());
1713                 }
1714                 if (t==null&&d==null) return str;
1715             } catch (e) {
1716                 return str;
1717             }
1718         }
1719         return t;
1720     }else{
1721         if(t=='null'){t="";}
1722         return t;
1723     }
1724
1725 }
1726 function centerPopup(ctype, callback) { // 2确认 3通过驳回
1727     if (typeof (createPopupPwd) != 'function') {
1728         $.getScript("/js/pwd/inputPwd.js", function() {
1729             createPopupPwd(formId, ctype, callback);
1730         });
1731     } else {
1732         createPopupPwd(formId, ctype, callback);
1733     }
1734 }
1735 var hq={
1736     createPopSelect:function(fid, cfid, doccode, callback) {
1737         if (typeof (openLeaderSelect) != 'function') {
1738             $.getScript("/js/selectLeader/selectLeader.js", function() {
1739                 openLeaderSelect(fid, cfid, doccode, callback);
1740             });
1741         } else {
1742             openLeaderSelect(fid, cfid, doccode, callback);
1743         }
1744     }
1745 }
1746
1747 //报表打印
1748 function printButtonLink(formid, reportid, format, param, formtype,
1749                          Warnnessage, isDirectPrinter, isSelectPrinter, formats, isFont,isbeforerefreshcontent) {
1750     var flag = checkSession(); // session失效后弹出登录框,flag为true时表示已经失效
1751     if(flag){
1752         return;
1753     }
1754     var Warn =function(){ // 打印前抛出的信息
1755         var json=JSON.parse(Warnnessage.replace(/'/g, "\""));
1756         if(json.parameters != ""){
1757             var temp=json.parameters.split(";");// getSymbol(Warnnessage,'&');
1758             var war=[];
1759             for(var i in temp){
1760                 war.push(getDoc(temp[i],'.value'));
1761             }
1762             json.parameters=war.join(";");
1763         }
1764 //        else{
1765 //            return confirm(Warnnessage);
1766 //        }
1767             var warbol=false;
1768             $.ajax({url:'/printReport.do?m=Warnnessage',data:json,type:"POST",async:false,dataType:'json',
1769                 success:function(r) {
1770                     if(r.state==0){
1771                         if(confirm(r.msg)){
1772                             warbol=true;
1773                         }
1774                     }    else{
1775                         warbol=true;
1776                     }
1777                 }});
1778          return warbol;
1779     }
1780     if (Warnnessage == "" || Warn()) {
1781         var proParam = "";
1782         if ($.trim(param) != "") {
1783             if (param.indexOf("@formid") != -1) {
1784                 param = param.replaceAll("@formid", formId);
1785             }
1786             var temp = param.split(";");
1787             for (i = 0; i < temp.length; i++) { // 循环获取报表设置参数的值,从面板和格线里面获取。 2014-10-25
1788                 var temp2 = temp[i].split("=");
1789                 if (temp2.length < 2) {
1790                     if (temp2.length == 1 && temp2[0] == "")
1791                         continue;
1792                     $.messager.alert("操作提示", formid + "报表参数配置有误:" + param,"warning");
1793                     return;
1794                 }
1795                 var t = null;
1796                 var rows=[];
1797                 var num=0;
1798                 if (typeof (mygrid) != "undefined") {
1799                     rows=mygrid.getFieldForNew();
1800                     num=rows.length;
1801                 }else{ // 没格线则取0;
1802                     num=1;
1803                 }
1804                 proParam += temp2[0]+"=";
1805                 var tempx=(temp2[1].replaceAll("&", "")).toLowerCase();
1806                 for(var k=0;k<num;k++){ // 选中多少行,for多少
1807                     if(k>0) proParam += ","; // 多个值的时候用逗号(,)隔开。
1808                     if ($.trim(tempx) == "") {
1809                         continue;
1810                     }
1811                     t = getValue(tempx.toLowerCase(),null,rows[k]);
1812                     if (t==null)
1813                         t = tempx;
1814                     proParam += t; // 组装值
1815                 }
1816                 proParam +=";";
1817             }
1818             proParam = proParam.substring(0, proParam.length - 1);
1819             proParam = encodeURI(encodeURI(proParam)); // 对参数进行编码。(进行二次编码)  
1820         }
1821 //        var servlet = "/" + format.toLowerCase() + ".do?"
1822         var servlet="/printReport.do?m="+format.toLowerCase()
1823         var doccode = getValue('doccode');
1824         var url = "formId=" + formid + "&reportId=" + reportid + "&parameter=" + proParam+";"
1825             + "&p=" + Math.round(Math.random() * 100000);      
1826         //html方法打印
1827         if (format.toLowerCase() == "html") {
1828             parent.addTab("flash打印", "", "", "", encodeURL("/swf.jsp?parm="
1829                 + url.replaceAll("=", "_pb").replaceAll("&", "_fen")
1830                 + "&format=" + format + "&reportId=" + reportid
1831                 + "&formId=" + formid + "&formtype=" + formtype
1832                 + "&doccode=" + doccode + "&print=" + isDirectPrinter
1833                 + "&Formats=" + formats));
1834             return false;
1835         }
1836         if(isbeforerefreshcontent==1){
1837                 //执行更新密码的程序
1838                 $.ajax({url:'/printReport.do?m=updatepwd',
1839                     data:{'formId':formid,'doccode':doccode},
1840                     type:"POST",
1841                     async:false,
1842                     dataType:'json',
1843                     success:function(r) {
1844                         if(r.state==-1){
1845                              $.messager.alert("操作提示", r.msg,"warning");
1846                         }
1847                     }
1848                  });
1849          }            
1850          //如果谷歌浏览器高于50版本才执行最新打印方式否则执行旧版打印方式
1851          if(format.toLowerCase() == "pdf" && getChromeVersion()>50){
1852                 //执行pdf打印,添加一个页卡显示。
1853                 //viewer.jsp是pdfjs提供的加载pdf文件的容器 -xin 2020-6-12 15:00:30
1854                 parent.addTab("PDF报表打印", "", "", "", "/general/pdf/web/viewer.jsp?file="+encodeURL(servlet
1855                        +"&"+ url)+"&formId="+formid+"&formType="+formtype+"&reportId="+reportid
1856                        +"&printFormat="+format+"&doccode="+doccode+"&parameter="+proParam+"&isDirectPrinter="+isDirectPrinter);  
1857                 return false;
1858             }
1859             //执行pdf打印,添加一个页卡显示。
1860             parent.addTab(format + "打印", "", "", "", encodeURL(servlet +"&"+url));
1861             //更新打印次数
1862             $.post("/printReport.do?m=number", {
1863                       "formId" :formid,
1864                       "formType" :formtype,
1865                       "reportId" :reportid,
1866                       "printFormat" :format,
1867                       "doccode" :doccode,
1868                       "parameter":proParam
1869                   },function(r){
1870                       if(r.state==-1){
1871                           $.messager.alert("操作提示", r.msg,"warning");
1872                       }
1873                   });
1874             }
1875 }
1876 //获取谷歌浏览器版本
1877 function getChromeVersion() {
1878     var arr = navigator.userAgent.split(' '); 
1879     var chromeVersion = '';
1880     for(var i=0;i < arr.length;i++){
1881         if(/chrome/i.test(arr[i]))
1882         chromeVersion = arr[i]
1883     }
1884     if(chromeVersion){
1885         return Number(chromeVersion.split('/')[1].split('.')[0]);
1886     } else {
1887         return false;
1888     }
1889 }
1890
1891 function getSymbol(sql,split){    // 获取有符号的字段
1892     var splitLength=split.length;
1893     //List<String> list=new ArrayList<String>();
1894     var i=0;
1895     var postion=0;
1896     var list = new Array();
1897     while(sql.indexOf(split,i)!=-1){
1898         i=sql.indexOf(split,i)+splitLength;
1899         postion=sql.indexOf(split, i);
1900         if(postion==-1)break;
1901         var temp=getDoc(sql.substring(i,postion),'.value');
1902         var tefu=sql.substring(i-1,postion+1);
1903         sql=sql.replace(tefu,temp);
1904         i=postion+splitLength;
1905     }
1906     return sql;
1907 }
1908
1909 function getReportPage(fid, rptid, fun) {
1910     $.post("/reportGetPage.do", {
1911         "formId" :fid,
1912         "reportId" :rptid
1913     }, function(d) {
1914         if (typeof fun == "function")
1915             fun(d);
1916     });
1917 }
1918 function recentFilesTo() {
1919     if (typeof formId != "undefined" && typeof formType != "undefined") {
1920         var url = "/recentfiles.do";
1921         var formname = document.title;
1922         var query_string = document.URL;
1923         query_string = (query_string.indexOf("?") == -1) ? "" : query_string
1924             .substring(query_string.indexOf("?") + 1);
1925         $.post(url, {
1926             "formid" :formId,
1927             "formtype" :formType,
1928             "formname" :formname,
1929             "query_string" :query_string
1930         }, '');
1931     }
1932 }
1933 function getDocURL(isNext) {
1934     var doccode = doc('doccode').value;
1935     panIndex = "0";
1936     $.post("/getDoc.do", {
1937         "t_doc" :isNext,
1938         "doccode" :doccode,
1939         "where" :"",
1940         "tUrl" :document.URL
1941     }, function(data) {
1942         if (data != null && data != "") {
1943             location.href = data;
1944         } else {
1945             alert(data);
1946         }
1947     });
1948 }
1949 var postToThis = null; // 接受字段 父页面
1950 var panelToPost = null; // 所需字段 子页面
1951 var inThisFrame = "";
1952 var inChangFrame = "";
1953 var C_Grid = "";
1954 var ispop="";
1955 $( function($) {
1956     if (typeof parent.getIframeAttr != 'undefined') {
1957         inThisFrame = parent.getIframeAttr("id");
1958         inChangFrame = parent.getIframeAttr("pframe");
1959         panelToPost = parent.getIframeAttr("paneltopost")!=undefined?parent.getIframeAttr("paneltopost").split(";"):"";
1960         postToThis = parent.getIframeAttr("posttothis")!=undefined?parent.getIframeAttr("posttothis").split(";"):"";
1961         C_Grid = parent.getIframeAttr("t_grid");
1962     }
1963     recentFilesTo();
1964 });
1965
1966 // 【帮助】按钮事件函数,点击打开该功能的帮助页面
1967 function openHelpPage(tabtitle)
1968 {
1969     var flag = checkSession(); // session失效后弹出登录框,flag为true时表示已经失效
1970     if(flag){
1971         return;
1972     }
1973     // 获取帮助文件所在目录路径
1974     var a = location.href;
1975     a=a.replace(/(.+\/).*$/g, '$1');
1976
1977     //alert(tabtitle);
1978     //var tabtile=.getElementById("tab_title").value;
1979
1980     // 组合路径并在tab打开页面
1981     try {
1982         //alert("1");
1983         var url=a+"help.jsp";
1984         //alert(url);
1985         parent.addTab(tabtitle+"-"+formId+"-帮助", formId, '','',  url);
1986     } catch (e) {
1987         alert(e); // window.open("help.jsp");
1988     }
1989 }
1990
1991
1992 //选择按钮的隐藏和显示
1993 $(function(){
1994     $("#tpselect").hide();
1995     if((C_Grid!=undefined&&C_Grid!=""&&eval('('+C_Grid+')').toP!="") || $.trim(postToThis).length>0 || self_datafields!=""){
1996         $("#tpselect").show();
1997     }
1998
1999     parent.numId=""; // 设置单号的值
2000
2001 })
2002
2003 // TW添加
2004 function showrestmenu(){
2005     var offset  = $('#showRestmenuDiv').offset()
2006     var top = parseInt(offset.top+$('#showRestmenuDiv').height()+5);
2007     if(isTopFixed()) {//固定头部用到 xin 2020-11-10 10:54:20
2008         top=67;
2009     }
2010     $('#restmenuDiv').css({"top":top,"left":offset.left});
2011     $('#restmenuDiv').show();
2012 }
2013 function restmenuclose(){
2014     $('#restmenuDiv').hide();
2015 }
2016 // 打开搜索框和更多
2017 $(function(){
2018     if (navigator.userAgent.match(/iPad|iPhone|Android/i)){
2019         $("#showRestmenuDiv").toggle(function(){
2020             $("#restmenuDiv").bind('touchstart',function(){
2021                 showrestmenu();
2022             })
2023         },function(){
2024             if($('div').hasClass("restmenuDiv")){
2025                 restmenuclose();
2026             }
2027         });
2028     }
2029     $('#selectinfo').mousedown(function(){
2030         var flag = checkSession(); // session失效后弹出登录框,flag为true时表示已经失效
2031         if(flag){
2032             return;
2033         }
2034         $('#selectDiv').show();
2035     })
2036     $('#selectinfo').mouseup(function(){
2037         $('#queryValue').focus();
2038     })
2039     // 按下回车键执行的函数,先解除绑定,再绑定。解决事件累加而执行二次
2040     $('#queryValue').unbind('keydown').keydown(function(event){
2041         if(event.keyCode == 13){
2042             tw.simpConfirm(); // query.js里面的一个方法
2043             windowClose();cas
2044         }
2045     })
2046     //更多里面的收藏按钮 -xin 2020-6-23 16:39:45
2047     // if(typeof(formId)!='undefined'){
2048     //     try{
2049     //         var Evt= $('#layoutIcon');
2050     //         $.post('/setIconMenu.do',{'formid':formId},function(data){
2051     //             Evt.linkbutton({
2052     //                 iconCls: (data.state==1?'icon-scok':'icon-scno'),
2053     //                 text:(data.state==1?'已添加':'添加'),
2054     //                 title:'为此功能号添加到图标菜单',
2055     //                 plain:true
2056     //             });
2057     //         },'json');
2058     //         Evt.bind('click',function(){
2059     //             alert('进入收藏');
2060     //         })
2061     //     }catch(e){}
2062     // }
2063 })
2064 function showselectDiv(){
2065      $('#queryValue').focus();
2066 }
2067 // 2、3类型搜索确认事件
2068 function selectSimpConfirm(){
2069     tw.simpConfirm();//query.js里面的一个方法
2070     windowClose();
2071 }
2072 // 2、3类型搜索确认事件
2073 function selectSimpConfirm2(){
2074     tw.confirm2();//query.js里面的一个方法
2075     windowClose();
2076 }
2077
2078 // 2、3类型搜索弹出事件
2079 function select(){
2080     $('#selectDiv').window('open');
2081
2082 }
2083 // 2、3类型搜索的关闭事件
2084 function windowClose(){
2085     $('#selectDiv').dialog('close');
2086 }
2087
2088 // 2、3类型更多按钮弹出事件
2089 function moreSelect(){
2090     var offset  = $('#showRestmenuDiv').offset();
2091     var top = parseInt(offset.top+$('#showRestmenuDiv').height()+5);
2092     $('#restmenuDiv').window({"top":top,"left":offset.left});
2093     $('#restmenuDiv').window('open');
2094 }
2095 // 2、3类型更多按钮的关闭事件
2096 function moreWindowClose(){
2097     $('#restmenuDiv').dialog('close');
2098 }
2099
2100 // 设置头部标题的高度
2101 $(function(){
2102     var a = $("#title_top").html();
2103     if(a!=null && typeof($('#top2').val())!="undefined"){
c81e3f 2104         $('#top2').layout('panel', 'north').panel('resize',{height:68});
a6a76f 2105         $('#top2').layout('resize');
F 2106     }
2107 })
2108
2109 // 窗体类型为20的头部标题的高度设置
2110 function formtype(){
2111     var a = $("#title_top").html();
2112     if(a!=null && typeof($('#top20').val())!="undefined"){
fc3567 2113         $('#top20').layout('panel', 'north').panel('resize',{height:110});
a6a76f 2114         // $('#h_all').layout('panel', 'north').panel('resize',{height:68});
F 2115         $('#top20').layout('resize');
2116         //$('#h_all').layout('resize');
2117     }else{
2118         //$('#h_all').layout('panel', 'north3').panel('resize',{height:0});
2119         $('#h_all').layout('panel', 'north').panel('resize',{height:33});
2120         $('#h_all').layout('resize');
2121     }
2122 }
2123
2124 // 系统消息
2125 var flag=false;
2126 function funB(){
2127     var init = $.cookie(userCode);
2128     if(init==null){
2129         $.cookie(userCode,flag);
2130     }
2131     if( $.cookie(userCode)=="false"){
2132         $.post("/messageTip.do",function(data){
2133             var message = data.message;
2134             if(message!=""){
2135                 $.messagerTip.lays(300, 220);
2136                 $.messagerTip.show(0, message);
2137                 flag= $("input[name='isTip']").is(":checked");
2138                 $.cookie(userCode,flag,{expires: 1})
2139             }
2140             setTimeout(funB, 300000); // 5分钟调用一次
2141         },"json")
2142     }
2143 }
2144
2145
2146
2147 function isChecked(){
2148     flag= $("input[name='isTip']").is(":checked");
2149     $.cookie(userCode,flag);
2150 }
2151
2152 function checkSession(){
2153     var flag = false;
2154     $.ajax({
2155         type : "post",
2156         url : "/checkSession.do",
2157         async : false,
2158         dataType: "json",
2159         success : function(data){
2160             if(data.status=="fail"){
2161                 if($.cookie("dbid")!=null&&$.cookie("dbid")!=""){
2162                     parent.deskTopShow('重新登录','/sessionFail.jsp',400,220,'');
2163                     flag=true;
2164                 }else{ // 不存在cookie,会出错,所以直接返回login页面
2165                     location.href="/login.jsp";
2166                 }
2167             }
2168         }
2169     });
2170     return flag;
2171 }
2172
2173 function gridSave(){
2174     var flag = checkSession();
2175     if(flag){
2176         return;
2177     }else{
2178         showLoading();
2179         mygrid.save('',function(){
2180             closeLoading();
2181         })
2182     }
2183 }
2184
2185 // 重启服务后生成功能号
2186 $(function(){
2187     $.post("/getRealUrl.do",function(data){
2188         if(data.error=="true"){
2189             alert(data.info);
2190         }else{
2191             if(data.formId!=""){ // 获取需要重新生成的功能号
2192                 if(data.formId=="all"){
2193                     // addTab('一键生成','','','','/buildv2.do?m=a','',{isFlowChart:true})
2194                     $.post('/buildv2.do?m=a');
2195                 }else{
2196                     $.post('/buildv2.do?m=a',{'list':data.formId});
2197                 }
2198                 // 将需要生成 的功能号进行清空
2199                 $.post('/property.do',{'formId':''});
2200             }
2201         }
2202     },'json')
2203 })
2204
2205 function checkVersion(){
2206     setTimeout(checkVersion, 86400000);
2207     setTimeout(checkVersion2, 86400000);//24小时调用一次
2208 }
2209
2210 function checkVersion2(){
2211     parent.deskTopShow('版本升级','/versionUpdate/isupdate.jsp?active=zhudong',550,520,'')
2212 }
2213
2214 // 测试$.post
2215 function testfunc(){
2216     $.ajaxError($.post("treeData.jsp"));
2217 }
2218
2219 // 根据单据报表设置的状态显示于隐藏
2220 function reportsdiv(dj,doctaout){
2221     try{
2222         var ent=$('.ReportStatus');
2223         if(ent !=undefined){
2224             $('.ReportStatus').each(function(i){
2225                 var status=$(this).data('status')+'';
2226                 status=status.split(';');
2227                 if(status.indexOf(doctaout)==-1 && status[0]!=""){
2228                     $(this).remove();
2229                 }
2230             })
2231         }else{
2232              var djs=dj.substring(0,dj.length-1).split("#");
2233                 for(var j=0;j<djs.length;j++){
2234                     if(doctaout==0){
2235                         if(djs[j].substring(0,1).indexOf(doctaout)!=-1){
2236                             if(document.getElementById(djs[j])){
2237                                 if(document.getElementById(djs[j]).style.display=="inline-block"){
2238                                     document.getElementById(djs[j]).style.display="inline-block";
2239                                 }else{
2240                                     document.getElementById(djs[j]).style.display="block";
2241                                 }
2242                             }
2243                         }else if(djs[j].indexOf("bdiv")!=-1){
2244                             if(document.getElementById(djs[j]))
2245                                 document.getElementById(djs[j]).style.display="inline-block";
2246                         }else{
2247                             document.getElementById(djs[j]).style.display="none";
2248                         }
2249                     }else{
2250                         var doct=djs[j].substring(0,djs[j].indexOf("-")).split(";");//获取报表设置的显示单据状态
2251                         var bolsecc=false;
2252                         for(var k=0;k<doct.length;k++){
2253                             if(doct[k]==doctaout){
2254                                 if(document.getElementById(djs[j])){
2255                                     if(document.getElementById(djs[j]).style.display=="inline-block"){
2256                                         document.getElementById(djs[j]).style.display="inline-block";
2257                                         bolsecc=true;
2258                                     }else{
2259                                         document.getElementById(djs[j]).style.display="block";//inline-block
2260                                         bolsecc=true;
2261                                     }
2262                                 }
2263                             }else if(djs[j].indexOf("bdiv")!=-1){
2264                                 if(document.getElementById(djs[j])){
2265                                     document.getElementById(djs[j]).style.display="inline-block";
2266                                     bolsecc=true;
2267                                 }
2268                             }
2269                         }
2270                         if(!bolsecc){
2271                             document.getElementById(djs[j]).style.display="none";//inline-block
2272                         }
2273                     }
2274                 }
2275         }       
2276     }catch (e) {
2277         //window.open("help.jsp");
2278     }
2279 }
2280 //-------------RSA---------------
2281 !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.JSEncrypt={})}(this,function(t){"use strict";var e="0123456789abcdefghijklmnopqrstuvwxyz";function a(t){return e.charAt(t)}function i(t,e){return t&e}function u(t,e){return t|e}function r(t,e){return t^e}function n(t,e){return t&~e}function s(t){if(0==t)return-1;var e=0;return 0==(65535&t)&&(t>>=16,e+=16),0==(255&t)&&(t>>=8,e+=8),0==(15&t)&&(t>>=4,e+=4),0==(3&t)&&(t>>=2,e+=2),0==(1&t)&&++e,e}function o(t){for(var e=0;0!=t;)t&=t-1,++e;return e}var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function c(t){var e,i,r="";for(e=0;e+3<=t.length;e+=3)i=parseInt(t.substring(e,e+3),16),r+=h.charAt(i>>6)+h.charAt(63&i);for(e+1==t.length?(i=parseInt(t.substring(e,e+1),16),r+=h.charAt(i<<2)):e+2==t.length&&(i=parseInt(t.substring(e,e+2),16),r+=h.charAt(i>>2)+h.charAt((3&i)<<4));0<(3&r.length);)r+="=";return r}function f(t){var e,i="",r=0,n=0;for(e=0;e<t.length&&"="!=t.charAt(e);++e){var s=h.indexOf(t.charAt(e));s<0||(0==r?(i+=a(s>>2),n=3&s,r=1):1==r?(i+=a(n<<2|s>>4),n=15&s,r=2):2==r?(i+=a(n),i+=a(s>>2),n=3&s,r=3):(i+=a(n<<2|s>>4),i+=a(15&s),r=0))}return 1==r&&(i+=a(n<<2)),i}var l,p=function(t,e){return(p=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)e.hasOwnProperty(i)&&(t[i]=e[i])})(t,e)};var g,d=function(t){var e;if(void 0===l){var i="0123456789ABCDEF",r=" \f\n\r\t \u2028\u2029";for(l={},e=0;e<16;++e)l[i.charAt(e)]=e;for(i=i.toLowerCase(),e=10;e<16;++e)l[i.charAt(e)]=e;for(e=0;e<r.length;++e)l[r.charAt(e)]=-1}var n=[],s=0,o=0;for(e=0;e<t.length;++e){var h=t.charAt(e);if("="==h)break;if(-1!=(h=l[h])){if(void 0===h)throw new Error("Illegal character at offset "+e);s|=h,2<=++o?(n[n.length]=s,o=s=0):s<<=4}}if(o)throw new Error("Hex encoding incomplete: 4 bits missing");return n},v={decode:function(t){var e;if(void 0===g){var i="= \f\n\r\t \u2028\u2029";for(g=Object.create(null),e=0;e<64;++e)g["ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".charAt(e)]=e;for(e=0;e<i.length;++e)g[i.charAt(e)]=-1}var r=[],n=0,s=0;for(e=0;e<t.length;++e){var o=t.charAt(e);if("="==o)break;if(-1!=(o=g[o])){if(void 0===o)throw new Error("Illegal character at offset "+e);n|=o,4<=++s?(r[r.length]=n>>16,r[r.length]=n>>8&255,r[r.length]=255&n,s=n=0):n<<=6}}switch(s){case 1:throw new Error("Base64 encoding incomplete: at least 2 bits missing");case 2:r[r.length]=n>>10;break;case 3:r[r.length]=n>>16,r[r.length]=n>>8&255}return r},re:/-----BEGIN [^-]+-----([A-Za-z0-9+\/=\s]+)-----END [^-]+-----|begin-base64[^\n]+\n([A-Za-z0-9+\/=\s]+)====/,unarmor:function(t){var e=v.re.exec(t);if(e)if(e[1])t=e[1];else{if(!e[2])throw new Error("RegExp out of sync");t=e[2]}return v.decode(t)}},m=1e13,y=function(){function t(t){this.buf=[+t||0]}return t.prototype.mulAdd=function(t,e){var i,r,n=this.buf,s=n.length;for(i=0;i<s;++i)(r=n[i]*t+e)<m?e=0:r-=(e=0|r/m)*m,n[i]=r;0<e&&(n[i]=e)},t.prototype.sub=function(t){var e,i,r=this.buf,n=r.length;for(e=0;e<n;++e)(i=r[e]-t)<0?(i+=m,t=1):t=0,r[e]=i;for(;0===r[r.length-1];)r.pop()},t.prototype.toString=function(t){if(10!=(t||10))throw new Error("only base 10 is supported");for(var e=this.buf,i=e[e.length-1].toString(),r=e.length-2;0<=r;--r)i+=(m+e[r]).toString().substring(1);return i},t.prototype.valueOf=function(){for(var t=this.buf,e=0,i=t.length-1;0<=i;--i)e=e*m+t[i];return e},t.prototype.simplify=function(){var t=this.buf;return 1==t.length?t[0]:this},t}(),b="…",T=/^(\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/,S=/^(\d\d\d\d)(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])([01]\d|2[0-3])(?:([0-5]\d)(?:([0-5]\d)(?:[.,](\d{1,3}))?)?)?(Z|[-+](?:[0]\d|1[0-2])([0-5]\d)?)?$/;function E(t,e){return t.length>e&&(t=t.substring(0,e)+b),t}var w,D=function(){function i(t,e){this.hexDigits="0123456789ABCDEF",t instanceof i?(this.enc=t.enc,this.pos=t.pos):(this.enc=t,this.pos=e)}return i.prototype.get=function(t){if(void 0===t&&(t=this.pos++),t>=this.enc.length)throw new Error("Requesting byte offset "+t+" on a stream of length "+this.enc.length);return"string"==typeof this.enc?this.enc.charCodeAt(t):this.enc[t]},i.prototype.hexByte=function(t){return this.hexDigits.charAt(t>>4&15)+this.hexDigits.charAt(15&t)},i.prototype.hexDump=function(t,e,i){for(var r="",n=t;n<e;++n)if(r+=this.hexByte(this.get(n)),!0!==i)switch(15&n){case 7:r+="  ";break;case 15:r+="\n";break;default:r+=" "}return r},i.prototype.isASCII=function(t,e){for(var i=t;i<e;++i){var r=this.get(i);if(r<32||176<r)return!1}return!0},i.prototype.parseStringISO=function(t,e){for(var i="",r=t;r<e;++r)i+=String.fromCharCode(this.get(r));return i},i.prototype.parseStringUTF=function(t,e){for(var i="",r=t;r<e;){var n=this.get(r++);i+=n<128?String.fromCharCode(n):191<n&&n<224?String.fromCharCode((31&n)<<6|63&this.get(r++)):String.fromCharCode((15&n)<<12|(63&this.get(r++))<<6|63&this.get(r++))}return i},i.prototype.parseStringBMP=function(t,e){for(var i,r,n="",s=t;s<e;)i=this.get(s++),r=this.get(s++),n+=String.fromCharCode(i<<8|r);return n},i.prototype.parseTime=function(t,e,i){var r=this.parseStringISO(t,e),n=(i?T:S).exec(r);return n?(i&&(n[1]=+n[1],n[1]+=+n[1]<70?2e3:1900),r=n[1]+"-"+n[2]+"-"+n[3]+" "+n[4],n[5]&&(r+=":"+n[5],n[6]&&(r+=":"+n[6],n[7]&&(r+="."+n[7]))),n[8]&&(r+=" UTC","Z"!=n[8]&&(r+=n[8],n[9]&&(r+=":"+n[9]))),r):"Unrecognized time: "+r},i.prototype.parseInteger=function(t,e){for(var i,r=this.get(t),n=127<r,s=n?255:0,o="";r==s&&++t<e;)r=this.get(t);if(0===(i=e-t))return n?-1:0;if(4<i){for(o=r,i<<=3;0==(128&(+o^s));)o=+o<<1,--i;o="("+i+" bit)\n"}n&&(r-=256);for(var h=new y(r),a=t+1;a<e;++a)h.mulAdd(256,this.get(a));return o+h.toString()},i.prototype.parseBitString=function(t,e,i){for(var r=this.get(t),n="("+((e-t-1<<3)-r)+" bit)\n",s="",o=t+1;o<e;++o){for(var h=this.get(o),a=o==e-1?r:0,u=7;a<=u;--u)s+=h>>u&1?"1":"0";if(s.length>i)return n+E(s,i)}return n+s},i.prototype.parseOctetString=function(t,e,i){if(this.isASCII(t,e))return E(this.parseStringISO(t,e),i);var r=e-t,n="("+r+" byte)\n";(i/=2)<r&&(e=t+i);for(var s=t;s<e;++s)n+=this.hexByte(this.get(s));return i<r&&(n+=b),n},i.prototype.parseOID=function(t,e,i){for(var r="",n=new y,s=0,o=t;o<e;++o){var h=this.get(o);if(n.mulAdd(128,127&h),s+=7,!(128&h)){if(""===r)if((n=n.simplify())instanceof y)n.sub(80),r="2."+n.toString();else{var a=n<80?n<40?0:1:2;r=a+"."+(n-40*a)}else r+="."+n.toString();if(r.length>i)return E(r,i);n=new y,s=0}}return 0<s&&(r+=".incomplete"),r},i}(),x=function(){function c(t,e,i,r,n){if(!(r instanceof R))throw new Error("Invalid tag value.");this.stream=t,this.header=e,this.length=i,this.tag=r,this.sub=n}return c.prototype.typeName=function(){switch(this.tag.tagClass){case 0:switch(this.tag.tagNumber){case 0:return"EOC";case 1:return"BOOLEAN";case 2:return"INTEGER";case 3:return"BIT_STRING";case 4:return"OCTET_STRING";case 5:return"NULL";case 6:return"OBJECT_IDENTIFIER";case 7:return"ObjectDescriptor";case 8:return"EXTERNAL";case 9:return"REAL";case 10:return"ENUMERATED";case 11:return"EMBEDDED_PDV";case 12:return"UTF8String";case 16:return"SEQUENCE";case 17:return"SET";case 18:return"NumericString";case 19:return"PrintableString";case 20:return"TeletexString";case 21:return"VideotexString";case 22:return"IA5String";case 23:return"UTCTime";case 24:return"GeneralizedTime";case 25:return"GraphicString";case 26:return"VisibleString";case 27:return"GeneralString";case 28:return"UniversalString";case 30:return"BMPString"}return"Universal_"+this.tag.tagNumber.toString();case 1:return"Application_"+this.tag.tagNumber.toString();case 2:return"["+this.tag.tagNumber.toString()+"]";case 3:return"Private_"+this.tag.tagNumber.toString()}},c.prototype.content=function(t){if(void 0===this.tag)return null;void 0===t&&(t=1/0);var e=this.posContent(),i=Math.abs(this.length);if(!this.tag.isUniversal())return null!==this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+i,t);switch(this.tag.tagNumber){case 1:return 0===this.stream.get(e)?"false":"true";case 2:return this.stream.parseInteger(e,e+i);case 3:return this.sub?"("+this.sub.length+" elem)":this.stream.parseBitString(e,e+i,t);case 4:return this.sub?"("+this.sub.length+" elem)":this.stream.parseOctetString(e,e+i,t);case 6:return this.stream.parseOID(e,e+i,t);case 16:case 17:return null!==this.sub?"("+this.sub.length+" elem)":"(no elem)";case 12:return E(this.stream.parseStringUTF(e,e+i),t);case 18:case 19:case 20:case 21:case 22:case 26:return E(this.stream.parseStringISO(e,e+i),t);case 30:return E(this.stream.parseStringBMP(e,e+i),t);case 23:case 24:return this.stream.parseTime(e,e+i,23==this.tag.tagNumber)}return null},c.prototype.toString=function(){return this.typeName()+"@"+this.stream.pos+"[header:"+this.header+",length:"+this.length+",sub:"+(null===this.sub?"null":this.sub.length)+"]"},c.prototype.toPrettyString=function(t){void 0===t&&(t="");var e=t+this.typeName()+" @"+this.stream.pos;if(0<=this.length&&(e+="+"),e+=this.length,this.tag.tagConstructed?e+=" (constructed)":!this.tag.isUniversal()||3!=this.tag.tagNumber&&4!=this.tag.tagNumber||null===this.sub||(e+=" (encapsulates)"),e+="\n",null!==this.sub){t+="  ";for(var i=0,r=this.sub.length;i<r;++i)e+=this.sub[i].toPrettyString(t)}return e},c.prototype.posStart=function(){return this.stream.pos},c.prototype.posContent=function(){return this.stream.pos+this.header},c.prototype.posEnd=function(){return this.stream.pos+this.header+Math.abs(this.length)},c.prototype.toHexString=function(){return this.stream.hexDump(this.posStart(),this.posEnd(),!0)},c.decodeLength=function(t){var e=t.get(),i=127&e;if(i==e)return i;if(6<i)throw new Error("Length over 48 bits not supported at position "+(t.pos-1));if(0===i)return null;for(var r=e=0;r<i;++r)e=256*e+t.get();return e},c.prototype.getHexStringValue=function(){var t=this.toHexString(),e=2*this.header,i=2*this.length;return t.substr(e,i)},c.decode=function(t){var r;r=t instanceof D?t:new D(t,0);var e=new D(r),i=new R(r),n=c.decodeLength(r),s=r.pos,o=s-e.pos,h=null,a=function(){var t=[];if(null!==n){for(var e=s+n;r.pos<e;)t[t.length]=c.decode(r);if(r.pos!=e)throw new Error("Content size is not correct for container starting at offset "+s)}else try{for(;;){var i=c.decode(r);if(i.tag.isEOC())break;t[t.length]=i}n=s-r.pos}catch(t){throw new Error("Exception while decoding undefined length content: "+t)}return t};if(i.tagConstructed)h=a();else if(i.isUniversal()&&(3==i.tagNumber||4==i.tagNumber))try{if(3==i.tagNumber&&0!=r.get())throw new Error("BIT STRINGs with unused bits cannot encapsulate.");h=a();for(var u=0;u<h.length;++u)if(h[u].tag.isEOC())throw new Error("EOC is not supposed to be actual content.")}catch(t){h=null}if(null===h){if(null===n)throw new Error("We can't skip over an invalid tag with undefined length at offset "+s);r.pos=s+Math.abs(n)}return new c(e,o,n,i,h)},c}(),R=function(){function t(t){var e=t.get();if(this.tagClass=e>>6,this.tagConstructed=0!=(32&e),this.tagNumber=31&e,31==this.tagNumber){for(var i=new y;e=t.get(),i.mulAdd(128,127&e),128&e;);this.tagNumber=i.simplify()}}return t.prototype.isUniversal=function(){return 0===this.tagClass},t.prototype.isEOC=function(){return 0===this.tagClass&&0===this.tagNumber},t}(),B=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/B[B.length-1],O=function(){function b(t,e,i){null!=t&&("number"==typeof t?this.fromNumber(t,e,i):null==e&&"string"!=typeof t?this.fromString(t,256):this.fromString(t,e))}return b.prototype.toString=function(t){if(this.s<0)return"-"+this.negate().toString(t);var e;if(16==t)e=4;else if(8==t)e=3;else if(2==t)e=1;else if(32==t)e=5;else{if(4!=t)return this.toRadix(t);e=2}var i,r=(1<<e)-1,n=!1,s="",o=this.t,h=this.DB-o*this.DB%e;if(0<o--)for(h<this.DB&&0<(i=this[o]>>h)&&(n=!0,s=a(i));0<=o;)h<e?(i=(this[o]&(1<<h)-1)<<e-h,i|=this[--o]>>(h+=this.DB-e)):(i=this[o]>>(h-=e)&r,h<=0&&(h+=this.DB,--o)),0<i&&(n=!0),n&&(s+=a(i));return n?s:"0"},b.prototype.negate=function(){var t=M();return b.ZERO.subTo(this,t),t},b.prototype.abs=function(){return this.s<0?this.negate():this},b.prototype.compareTo=function(t){var e=this.s-t.s;if(0!=e)return e;var i=this.t;if(0!=(e=i-t.t))return this.s<0?-e:e;for(;0<=--i;)if(0!=(e=this[i]-t[i]))return e;return 0},b.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+U(this[this.t-1]^this.s&this.DM)},b.prototype.mod=function(t){var e=M();return this.abs().divRemTo(t,null,e),this.s<0&&0<e.compareTo(b.ZERO)&&t.subTo(e,e),e},b.prototype.modPowInt=function(t,e){var i;return i=t<256||e.isEven()?new I(e):new N(e),this.exp(t,i)},b.prototype.clone=function(){var t=M();return this.copyTo(t),t},b.prototype.intValue=function(){if(this.s<0){if(1==this.t)return this[0]-this.DV;if(0==this.t)return-1}else{if(1==this.t)return this[0];if(0==this.t)return 0}return(this[1]&(1<<32-this.DB)-1)<<this.DB|this[0]},b.prototype.byteValue=function(){return 0==this.t?this.s:this[0]<<24>>24},b.prototype.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},b.prototype.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},b.prototype.toByteArray=function(){var t=this.t,e=[];e[0]=this.s;var i,r=this.DB-t*this.DB%8,n=0;if(0<t--)for(r<this.DB&&(i=this[t]>>r)!=(this.s&this.DM)>>r&&(e[n++]=i|this.s<<this.DB-r);0<=t;)r<8?(i=(this[t]&(1<<r)-1)<<8-r,i|=this[--t]>>(r+=this.DB-8)):(i=this[t]>>(r-=8)&255,r<=0&&(r+=this.DB,--t)),0!=(128&i)&&(i|=-256),0==n&&(128&this.s)!=(128&i)&&++n,(0<n||i!=this.s)&&(e[n++]=i);return e},b.prototype.equals=function(t){return 0==this.compareTo(t)},b.prototype.min=function(t){return this.compareTo(t)<0?this:t},b.prototype.max=function(t){return 0<this.compareTo(t)?this:t},b.prototype.and=function(t){var e=M();return this.bitwiseTo(t,i,e),e},b.prototype.or=function(t){var e=M();return this.bitwiseTo(t,u,e),e},b.prototype.xor=function(t){var e=M();return this.bitwiseTo(t,r,e),e},b.prototype.andNot=function(t){var e=M();return this.bitwiseTo(t,n,e),e},b.prototype.not=function(){for(var t=M(),e=0;e<this.t;++e)t[e]=this.DM&~this[e];return t.t=this.t,t.s=~this.s,t},b.prototype.shiftLeft=function(t){var e=M();return t<0?this.rShiftTo(-t,e):this.lShiftTo(t,e),e},b.prototype.shiftRight=function(t){var e=M();return t<0?this.lShiftTo(-t,e):this.rShiftTo(t,e),e},b.prototype.getLowestSetBit=function(){for(var t=0;t<this.t;++t)if(0!=this[t])return t*this.DB+s(this[t]);return this.s<0?this.t*this.DB:-1},b.prototype.bitCount=function(){for(var t=0,e=this.s&this.DM,i=0;i<this.t;++i)t+=o(this[i]^e);return t},b.prototype.testBit=function(t){var e=Math.floor(t/this.DB);return e>=this.t?0!=this.s:0!=(this[e]&1<<t%this.DB)},b.prototype.setBit=function(t){return this.changeBit(t,u)},b.prototype.clearBit=function(t){return this.changeBit(t,n)},b.prototype.flipBit=function(t){return this.changeBit(t,r)},b.prototype.add=function(t){var e=M();return this.addTo(t,e),e},b.prototype.subtract=function(t){var e=M();return this.subTo(t,e),e},b.prototype.multiply=function(t){var e=M();return this.multiplyTo(t,e),e},b.prototype.divide=function(t){var e=M();return this.divRemTo(t,e,null),e},b.prototype.remainder=function(t){var e=M();return this.divRemTo(t,null,e),e},b.prototype.divideAndRemainder=function(t){var e=M(),i=M();return this.divRemTo(t,e,i),[e,i]},b.prototype.modPow=function(t,e){var i,r,n=t.bitLength(),s=F(1);if(n<=0)return s;i=n<18?1:n<48?3:n<144?4:n<768?5:6,r=n<8?new I(e):e.isEven()?new P(e):new N(e);var o=[],h=3,a=i-1,u=(1<<i)-1;if(o[1]=r.convert(this),1<i){var c=M();for(r.sqrTo(o[1],c);h<=u;)o[h]=M(),r.mulTo(c,o[h-2],o[h]),h+=2}var f,l,p=t.t-1,g=!0,d=M();for(n=U(t[p])-1;0<=p;){for(a<=n?f=t[p]>>n-a&u:(f=(t[p]&(1<<n+1)-1)<<a-n,0<p&&(f|=t[p-1]>>this.DB+n-a)),h=i;0==(1&f);)f>>=1,--h;if((n-=h)<0&&(n+=this.DB,--p),g)o[f].copyTo(s),g=!1;else{for(;1<h;)r.sqrTo(s,d),r.sqrTo(d,s),h-=2;0<h?r.sqrTo(s,d):(l=s,s=d,d=l),r.mulTo(d,o[f],s)}for(;0<=p&&0==(t[p]&1<<n);)r.sqrTo(s,d),l=s,s=d,d=l,--n<0&&(n=this.DB-1,--p)}return r.revert(s)},b.prototype.modInverse=function(t){var e=t.isEven();if(this.isEven()&&e||0==t.signum())return b.ZERO;for(var i=t.clone(),r=this.clone(),n=F(1),s=F(0),o=F(0),h=F(1);0!=i.signum();){for(;i.isEven();)i.rShiftTo(1,i),e?(n.isEven()&&s.isEven()||(n.addTo(this,n),s.subTo(t,s)),n.rShiftTo(1,n)):s.isEven()||s.subTo(t,s),s.rShiftTo(1,s);for(;r.isEven();)r.rShiftTo(1,r),e?(o.isEven()&&h.isEven()||(o.addTo(this,o),h.subTo(t,h)),o.rShiftTo(1,o)):h.isEven()||h.subTo(t,h),h.rShiftTo(1,h);0<=i.compareTo(r)?(i.subTo(r,i),e&&n.subTo(o,n),s.subTo(h,s)):(r.subTo(i,r),e&&o.subTo(n,o),h.subTo(s,h))}return 0!=r.compareTo(b.ONE)?b.ZERO:0<=h.compareTo(t)?h.subtract(t):h.signum()<0?(h.addTo(t,h),h.signum()<0?h.add(t):h):h},b.prototype.pow=function(t){return this.exp(t,new V)},b.prototype.gcd=function(t){var e=this.s<0?this.negate():this.clone(),i=t.s<0?t.negate():t.clone();if(e.compareTo(i)<0){var r=e;e=i,i=r}var n=e.getLowestSetBit(),s=i.getLowestSetBit();if(s<0)return e;for(n<s&&(s=n),0<s&&(e.rShiftTo(s,e),i.rShiftTo(s,i));0<e.signum();)0<(n=e.getLowestSetBit())&&e.rShiftTo(n,e),0<(n=i.getLowestSetBit())&&i.rShiftTo(n,i),0<=e.compareTo(i)?(e.subTo(i,e),e.rShiftTo(1,e)):(i.subTo(e,i),i.rShiftTo(1,i));return 0<s&&i.lShiftTo(s,i),i},b.prototype.isProbablePrime=function(t){var e,i=this.abs();if(1==i.t&&i[0]<=B[B.length-1]){for(e=0;e<B.length;++e)if(i[0]==B[e])return!0;return!1}if(i.isEven())return!1;for(e=1;e<B.length;){for(var r=B[e],n=e+1;n<B.length&&r<A;)r*=B[n++];for(r=i.modInt(r);e<n;)if(r%B[e++]==0)return!1}return i.millerRabin(t)},b.prototype.copyTo=function(t){for(var e=this.t-1;0<=e;--e)t[e]=this[e];t.t=this.t,t.s=this.s},b.prototype.fromInt=function(t){this.t=1,this.s=t<0?-1:0,0<t?this[0]=t:t<-1?this[0]=t+this.DV:this.t=0},b.prototype.fromString=function(t,e){var i;if(16==e)i=4;else if(8==e)i=3;else if(256==e)i=8;else if(2==e)i=1;else if(32==e)i=5;else{if(4!=e)return void this.fromRadix(t,e);i=2}this.t=0,this.s=0;for(var r=t.length,n=!1,s=0;0<=--r;){var o=8==i?255&+t[r]:C(t,r);o<0?"-"==t.charAt(r)&&(n=!0):(n=!1,0==s?this[this.t++]=o:s+i>this.DB?(this[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this[this.t++]=o>>this.DB-s):this[this.t-1]|=o<<s,(s+=i)>=this.DB&&(s-=this.DB))}8==i&&0!=(128&+t[0])&&(this.s=-1,0<s&&(this[this.t-1]|=(1<<this.DB-s)-1<<s)),this.clamp(),n&&b.ZERO.subTo(this,this)},b.prototype.clamp=function(){for(var t=this.s&this.DM;0<this.t&&this[this.t-1]==t;)--this.t},b.prototype.dlShiftTo=function(t,e){var i;for(i=this.t-1;0<=i;--i)e[i+t]=this[i];for(i=t-1;0<=i;--i)e[i]=0;e.t=this.t+t,e.s=this.s},b.prototype.drShiftTo=function(t,e){for(var i=t;i<this.t;++i)e[i-t]=this[i];e.t=Math.max(this.t-t,0),e.s=this.s},b.prototype.lShiftTo=function(t,e){for(var i=t%this.DB,r=this.DB-i,n=(1<<r)-1,s=Math.floor(t/this.DB),o=this.s<<i&this.DM,h=this.t-1;0<=h;--h)e[h+s+1]=this[h]>>r|o,o=(this[h]&n)<<i;for(h=s-1;0<=h;--h)e[h]=0;e[s]=o,e.t=this.t+s+1,e.s=this.s,e.clamp()},b.prototype.rShiftTo=function(t,e){e.s=this.s;var i=Math.floor(t/this.DB);if(i>=this.t)e.t=0;else{var r=t%this.DB,n=this.DB-r,s=(1<<r)-1;e[0]=this[i]>>r;for(var o=i+1;o<this.t;++o)e[o-i-1]|=(this[o]&s)<<n,e[o-i]=this[o]>>r;0<r&&(e[this.t-i-1]|=(this.s&s)<<n),e.t=this.t-i,e.clamp()}},b.prototype.subTo=function(t,e){for(var i=0,r=0,n=Math.min(t.t,this.t);i<n;)r+=this[i]-t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r-=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r-=t[i],e[i++]=r&this.DM,r>>=this.DB;r-=t.s}e.s=r<0?-1:0,r<-1?e[i++]=this.DV+r:0<r&&(e[i++]=r),e.t=i,e.clamp()},b.prototype.multiplyTo=function(t,e){var i=this.abs(),r=t.abs(),n=i.t;for(e.t=n+r.t;0<=--n;)e[n]=0;for(n=0;n<r.t;++n)e[n+i.t]=i.am(0,r[n],e,n,0,i.t);e.s=0,e.clamp(),this.s!=t.s&&b.ZERO.subTo(e,e)},b.prototype.squareTo=function(t){for(var e=this.abs(),i=t.t=2*e.t;0<=--i;)t[i]=0;for(i=0;i<e.t-1;++i){var r=e.am(i,e[i],t,2*i,0,1);(t[i+e.t]+=e.am(i+1,2*e[i],t,2*i+1,r,e.t-i-1))>=e.DV&&(t[i+e.t]-=e.DV,t[i+e.t+1]=1)}0<t.t&&(t[t.t-1]+=e.am(i,e[i],t,2*i,0,1)),t.s=0,t.clamp()},b.prototype.divRemTo=function(t,e,i){var r=t.abs();if(!(r.t<=0)){var n=this.abs();if(n.t<r.t)return null!=e&&e.fromInt(0),void(null!=i&&this.copyTo(i));null==i&&(i=M());var s=M(),o=this.s,h=t.s,a=this.DB-U(r[r.t-1]);0<a?(r.lShiftTo(a,s),n.lShiftTo(a,i)):(r.copyTo(s),n.copyTo(i));var u=s.t,c=s[u-1];if(0!=c){var f=c*(1<<this.F1)+(1<u?s[u-2]>>this.F2:0),l=this.FV/f,p=(1<<this.F1)/f,g=1<<this.F2,d=i.t,v=d-u,m=null==e?M():e;for(s.dlShiftTo(v,m),0<=i.compareTo(m)&&(i[i.t++]=1,i.subTo(m,i)),b.ONE.dlShiftTo(u,m),m.subTo(s,s);s.t<u;)s[s.t++]=0;for(;0<=--v;){var y=i[--d]==c?this.DM:Math.floor(i[d]*l+(i[d-1]+g)*p);if((i[d]+=s.am(0,y,i,v,0,u))<y)for(s.dlShiftTo(v,m),i.subTo(m,i);i[d]<--y;)i.subTo(m,i)}null!=e&&(i.drShiftTo(u,e),o!=h&&b.ZERO.subTo(e,e)),i.t=u,i.clamp(),0<a&&i.rShiftTo(a,i),o<0&&b.ZERO.subTo(i,i)}}},b.prototype.invDigit=function(){if(this.t<1)return 0;var t=this[0];if(0==(1&t))return 0;var e=3&t;return 0<(e=(e=(e=(e=e*(2-(15&t)*e)&15)*(2-(255&t)*e)&255)*(2-((65535&t)*e&65535))&65535)*(2-t*e%this.DV)%this.DV)?this.DV-e:-e},b.prototype.isEven=function(){return 0==(0<this.t?1&this[0]:this.s)},b.prototype.exp=function(t,e){if(4294967295<t||t<1)return b.ONE;var i=M(),r=M(),n=e.convert(this),s=U(t)-1;for(n.copyTo(i);0<=--s;)if(e.sqrTo(i,r),0<(t&1<<s))e.mulTo(r,n,i);else{var o=i;i=r,r=o}return e.revert(i)},b.prototype.chunkSize=function(t){return Math.floor(Math.LN2*this.DB/Math.log(t))},b.prototype.toRadix=function(t){if(null==t&&(t=10),0==this.signum()||t<2||36<t)return"0";var e=this.chunkSize(t),i=Math.pow(t,e),r=F(i),n=M(),s=M(),o="";for(this.divRemTo(r,n,s);0<n.signum();)o=(i+s.intValue()).toString(t).substr(1)+o,n.divRemTo(r,n,s);return s.intValue().toString(t)+o},b.prototype.fromRadix=function(t,e){this.fromInt(0),null==e&&(e=10);for(var i=this.chunkSize(e),r=Math.pow(e,i),n=!1,s=0,o=0,h=0;h<t.length;++h){var a=C(t,h);a<0?"-"==t.charAt(h)&&0==this.signum()&&(n=!0):(o=e*o+a,++s>=i&&(this.dMultiply(r),this.dAddOffset(o,0),o=s=0))}0<s&&(this.dMultiply(Math.pow(e,s)),this.dAddOffset(o,0)),n&&b.ZERO.subTo(this,this)},b.prototype.fromNumber=function(t,e,i){if("number"==typeof e)if(t<2)this.fromInt(1);else for(this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(b.ONE.shiftLeft(t-1),u,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(e);)this.dAddOffset(2,0),this.bitLength()>t&&this.subTo(b.ONE.shiftLeft(t-1),this);else{var r=[],n=7&t;r.length=1+(t>>3),e.nextBytes(r),0<n?r[0]&=(1<<n)-1:r[0]=0,this.fromString(r,256)}},b.prototype.bitwiseTo=function(t,e,i){var r,n,s=Math.min(t.t,this.t);for(r=0;r<s;++r)i[r]=e(this[r],t[r]);if(t.t<this.t){for(n=t.s&this.DM,r=s;r<this.t;++r)i[r]=e(this[r],n);i.t=this.t}else{for(n=this.s&this.DM,r=s;r<t.t;++r)i[r]=e(n,t[r]);i.t=t.t}i.s=e(this.s,t.s),i.clamp()},b.prototype.changeBit=function(t,e){var i=b.ONE.shiftLeft(t);return this.bitwiseTo(i,e,i),i},b.prototype.addTo=function(t,e){for(var i=0,r=0,n=Math.min(t.t,this.t);i<n;)r+=this[i]+t[i],e[i++]=r&this.DM,r>>=this.DB;if(t.t<this.t){for(r+=t.s;i<this.t;)r+=this[i],e[i++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;i<t.t;)r+=t[i],e[i++]=r&this.DM,r>>=this.DB;r+=t.s}e.s=r<0?-1:0,0<r?e[i++]=r:r<-1&&(e[i++]=this.DV+r),e.t=i,e.clamp()},b.prototype.dMultiply=function(t){this[this.t]=this.am(0,t-1,this,0,0,this.t),++this.t,this.clamp()},b.prototype.dAddOffset=function(t,e){if(0!=t){for(;this.t<=e;)this[this.t++]=0;for(this[e]+=t;this[e]>=this.DV;)this[e]-=this.DV,++e>=this.t&&(this[this.t++]=0),++this[e]}},b.prototype.multiplyLowerTo=function(t,e,i){var r=Math.min(this.t+t.t,e);for(i.s=0,i.t=r;0<r;)i[--r]=0;for(var n=i.t-this.t;r<n;++r)i[r+this.t]=this.am(0,t[r],i,r,0,this.t);for(n=Math.min(t.t,e);r<n;++r)this.am(0,t[r],i,r,0,e-r);i.clamp()},b.prototype.multiplyUpperTo=function(t,e,i){--e;var r=i.t=this.t+t.t-e;for(i.s=0;0<=--r;)i[r]=0;for(r=Math.max(e-this.t,0);r<t.t;++r)i[this.t+r-e]=this.am(e-r,t[r],i,0,0,this.t+r-e);i.clamp(),i.drShiftTo(1,i)},b.prototype.modInt=function(t){if(t<=0)return 0;var e=this.DV%t,i=this.s<0?t-1:0;if(0<this.t)if(0==e)i=this[0]%t;else for(var r=this.t-1;0<=r;--r)i=(e*i+this[r])%t;return i},b.prototype.millerRabin=function(t){var e=this.subtract(b.ONE),i=e.getLowestSetBit();if(i<=0)return!1;var r=e.shiftRight(i);B.length<(t=t+1>>1)&&(t=B.length);for(var n=M(),s=0;s<t;++s){n.fromInt(B[Math.floor(Math.random()*B.length)]);var o=n.modPow(r,this);if(0!=o.compareTo(b.ONE)&&0!=o.compareTo(e)){for(var h=1;h++<i&&0!=o.compareTo(e);)if(0==(o=o.modPowInt(2,this)).compareTo(b.ONE))return!1;if(0!=o.compareTo(e))return!1}}return!0},b.prototype.square=function(){var t=M();return this.squareTo(t),t},b.prototype.gcda=function(t,e){var i=this.s<0?this.negate():this.clone(),r=t.s<0?t.negate():t.clone();if(i.compareTo(r)<0){var n=i;i=r,r=n}var s=i.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)e(i);else{s<o&&(o=s),0<o&&(i.rShiftTo(o,i),r.rShiftTo(o,r));var h=function(){0<(s=i.getLowestSetBit())&&i.rShiftTo(s,i),0<(s=r.getLowestSetBit())&&r.rShiftTo(s,r),0<=i.compareTo(r)?(i.subTo(r,i),i.rShiftTo(1,i)):(r.subTo(i,r),r.rShiftTo(1,r)),0<i.signum()?setTimeout(h,0):(0<o&&r.lShiftTo(o,r),setTimeout(function(){e(r)},0))};setTimeout(h,10)}},b.prototype.fromNumberAsync=function(t,e,i,r){if("number"==typeof e)if(t<2)this.fromInt(1);else{this.fromNumber(t,i),this.testBit(t-1)||this.bitwiseTo(b.ONE.shiftLeft(t-1),u,this),this.isEven()&&this.dAddOffset(1,0);var n=this,s=function(){n.dAddOffset(2,0),n.bitLength()>t&&n.subTo(b.ONE.shiftLeft(t-1),n),n.isProbablePrime(e)?setTimeout(function(){r()},0):setTimeout(s,0)};setTimeout(s,0)}else{var o=[],h=7&t;o.length=1+(t>>3),e.nextBytes(o),0<h?o[0]&=(1<<h)-1:o[0]=0,this.fromString(o,256)}},b}(),V=function(){function t(){}return t.prototype.convert=function(t){return t},t.prototype.revert=function(t){return t},t.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i)},t.prototype.sqrTo=function(t,e){t.squareTo(e)},t}(),I=function(){function t(t){this.m=t}return t.prototype.convert=function(t){return t.s<0||0<=t.compareTo(this.m)?t.mod(this.m):t},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){t.divRemTo(this.m,null,t)},t.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),N=function(){function t(t){this.m=t,this.mp=t.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<t.DB-15)-1,this.mt2=2*t.t}return t.prototype.convert=function(t){var e=M();return t.abs().dlShiftTo(this.m.t,e),e.divRemTo(this.m,null,e),t.s<0&&0<e.compareTo(O.ZERO)&&this.m.subTo(e,e),e},t.prototype.revert=function(t){var e=M();return t.copyTo(e),this.reduce(e),e},t.prototype.reduce=function(t){for(;t.t<=this.mt2;)t[t.t++]=0;for(var e=0;e<this.m.t;++e){var i=32767&t[e],r=i*this.mpl+((i*this.mph+(t[e]>>15)*this.mpl&this.um)<<15)&t.DM;for(t[i=e+this.m.t]+=this.m.am(0,r,t,e,0,this.m.t);t[i]>=t.DV;)t[i]-=t.DV,t[++i]++}t.clamp(),t.drShiftTo(this.m.t,t),0<=t.compareTo(this.m)&&t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}(),P=function(){function t(t){this.m=t,this.r2=M(),this.q3=M(),O.ONE.dlShiftTo(2*t.t,this.r2),this.mu=this.r2.divide(t)}return t.prototype.convert=function(t){if(t.s<0||t.t>2*this.m.t)return t.mod(this.m);if(t.compareTo(this.m)<0)return t;var e=M();return t.copyTo(e),this.reduce(e),e},t.prototype.revert=function(t){return t},t.prototype.reduce=function(t){for(t.drShiftTo(this.m.t-1,this.r2),t.t>this.m.t+1&&(t.t=this.m.t+1,t.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);t.compareTo(this.r2)<0;)t.dAddOffset(1,this.m.t+1);for(t.subTo(this.r2,t);0<=t.compareTo(this.m);)t.subTo(this.m,t)},t.prototype.mulTo=function(t,e,i){t.multiplyTo(e,i),this.reduce(i)},t.prototype.sqrTo=function(t,e){t.squareTo(e),this.reduce(e)},t}();function M(){return new O(null)}function q(t,e){return new O(t,e)}"Microsoft Internet Explorer"==navigator.appName?(O.prototype.am=function(t,e,i,r,n,s){for(var o=32767&e,h=e>>15;0<=--s;){var a=32767&this[t],u=this[t++]>>15,c=h*a+u*o;n=((a=o*a+((32767&c)<<15)+i[r]+(1073741823&n))>>>30)+(c>>>15)+h*u+(n>>>30),i[r++]=1073741823&a}return n},w=30):"Netscape"!=navigator.appName?(O.prototype.am=function(t,e,i,r,n,s){for(;0<=--s;){var o=e*this[t++]+i[r]+n;n=Math.floor(o/67108864),i[r++]=67108863&o}return n},w=26):(O.prototype.am=function(t,e,i,r,n,s){for(var o=16383&e,h=e>>14;0<=--s;){var a=16383&this[t],u=this[t++]>>14,c=h*a+u*o;n=((a=o*a+((16383&c)<<14)+i[r]+n)>>28)+(c>>14)+h*u,i[r++]=268435455&a}return n},w=28),O.prototype.DB=w,O.prototype.DM=(1<<w)-1,O.prototype.DV=1<<w;O.prototype.FV=Math.pow(2,52),O.prototype.F1=52-w,O.prototype.F2=2*w-52;var j,L,H=[];for(j="0".charCodeAt(0),L=0;L<=9;++L)H[j++]=L;for(j="a".charCodeAt(0),L=10;L<36;++L)H[j++]=L;for(j="A".charCodeAt(0),L=10;L<36;++L)H[j++]=L;function C(t,e){var i=H[t.charCodeAt(e)];return null==i?-1:i}function F(t){var e=M();return e.fromInt(t),e}function U(t){var e,i=1;return 0!=(e=t>>>16)&&(t=e,i+=16),0!=(e=t>>8)&&(t=e,i+=8),0!=(e=t>>4)&&(t=e,i+=4),0!=(e=t>>2)&&(t=e,i+=2),0!=(e=t>>1)&&(t=e,i+=1),i}O.ZERO=F(0),O.ONE=F(1);var K=function(){function t(){this.i=0,this.j=0,this.S=[]}return t.prototype.init=function(t){var e,i,r;for(e=0;e<256;++e)this.S[e]=e;for(e=i=0;e<256;++e)i=i+this.S[e]+t[e%t.length]&255,r=this.S[e],this.S[e]=this.S[i],this.S[i]=r;this.i=0,this.j=0},t.prototype.next=function(){var t;return this.i=this.i+1&255,this.j=this.j+this.S[this.i]&255,t=this.S[this.i],this.S[this.i]=this.S[this.j],this.S[this.j]=t,this.S[t+this.S[this.i]&255]},t}();var k,_,z=256,Z=null;if(null==Z){Z=[];var G=void(_=0);if(window.crypto&&window.crypto.getRandomValues){var $=new Uint32Array(256);for(window.crypto.getRandomValues($),G=0;G<$.length;++G)Z[_++]=255&$[G]}var Y=function(t){if(this.count=this.count||0,256<=this.count||z<=_)window.removeEventListener?window.removeEventListener("mousemove",Y,!1):window.detachEvent&&window.detachEvent("onmousemove",Y);else try{var e=t.x+t.y;Z[_++]=255&e,this.count+=1}catch(t){}};window.addEventListener?window.addEventListener("mousemove",Y,!1):window.attachEvent&&window.attachEvent("onmousemove",Y)}function J(){if(null==k){for(k=new K;_<z;){var t=Math.floor(65536*Math.random());Z[_++]=255&t}for(k.init(Z),_=0;_<Z.length;++_)Z[_]=0;_=0}return k.next()}var X=function(){function t(){}return t.prototype.nextBytes=function(t){for(var e=0;e<t.length;++e)t[e]=J()},t}();var Q=function(){function t(){this.n=null,this.e=0,this.d=null,this.p=null,this.q=null,this.dmp1=null,this.dmq1=null,this.coeff=null}return t.prototype.doPublic=function(t){return t.modPowInt(this.e,this.n)},t.prototype.doPrivate=function(t){if(null==this.p||null==this.q)return t.modPow(this.d,this.n);for(var e=t.mod(this.p).modPow(this.dmp1,this.p),i=t.mod(this.q).modPow(this.dmq1,this.q);e.compareTo(i)<0;)e=e.add(this.p);return e.subtract(i).multiply(this.coeff).mod(this.p).multiply(this.q).add(i)},t.prototype.setPublic=function(t,e){null!=t&&null!=e&&0<t.length&&0<e.length?(this.n=q(t,16),this.e=parseInt(e,16)):console.error("Invalid RSA public key")},t.prototype.encrypt=function(t){var e=function(t,e){if(e<t.length+11)return console.error("Message too long for RSA"),null;for(var i=[],r=t.length-1;0<=r&&0<e;){var n=t.charCodeAt(r--);n<128?i[--e]=n:127<n&&n<2048?(i[--e]=63&n|128,i[--e]=n>>6|192):(i[--e]=63&n|128,i[--e]=n>>6&63|128,i[--e]=n>>12|224)}i[--e]=0;for(var s=new X,o=[];2<e;){for(o[0]=0;0==o[0];)s.nextBytes(o);i[--e]=o[0]}return i[--e]=2,i[--e]=0,new O(i)}(t,this.n.bitLength()+7>>3);if(null==e)return null;var i=this.doPublic(e);if(null==i)return null;var r=i.toString(16);return 0==(1&r.length)?r:"0"+r},t.prototype.setPrivate=function(t,e,i){null!=t&&null!=e&&0<t.length&&0<e.length?(this.n=q(t,16),this.e=parseInt(e,16),this.d=q(i,16)):console.error("Invalid RSA private key")},t.prototype.setPrivateEx=function(t,e,i,r,n,s,o,h){null!=t&&null!=e&&0<t.length&&0<e.length?(this.n=q(t,16),this.e=parseInt(e,16),this.d=q(i,16),this.p=q(r,16),this.q=q(n,16),this.dmp1=q(s,16),this.dmq1=q(o,16),this.coeff=q(h,16)):console.error("Invalid RSA private key")},t.prototype.generate=function(t,e){var i=new X,r=t>>1;this.e=parseInt(e,16);for(var n=new O(e,16);;){for(;this.p=new O(t-r,1,i),0!=this.p.subtract(O.ONE).gcd(n).compareTo(O.ONE)||!this.p.isProbablePrime(10););for(;this.q=new O(r,1,i),0!=this.q.subtract(O.ONE).gcd(n).compareTo(O.ONE)||!this.q.isProbablePrime(10););if(this.p.compareTo(this.q)<=0){var s=this.p;this.p=this.q,this.q=s}var o=this.p.subtract(O.ONE),h=this.q.subtract(O.ONE),a=o.multiply(h);if(0==a.gcd(n).compareTo(O.ONE)){this.n=this.p.multiply(this.q),this.d=n.modInverse(a),this.dmp1=this.d.mod(o),this.dmq1=this.d.mod(h),this.coeff=this.q.modInverse(this.p);break}}},t.prototype.decrypt=function(t){var e=q(t,16),i=this.doPrivate(e);return null==i?null:function(t,e){var i=t.toByteArray(),r=0;for(;r<i.length&&0==i[r];)++r;if(i.length-r!=e-1||2!=i[r])return null;++r;for(;0!=i[r];)if(++r>=i.length)return null;var n="";for(;++r<i.length;){var s=255&i[r];s<128?n+=String.fromCharCode(s):191<s&&s<224?(n+=String.fromCharCode((31&s)<<6|63&i[r+1]),++r):(n+=String.fromCharCode((15&s)<<12|(63&i[r+1])<<6|63&i[r+2]),r+=2)}return n}(i,this.n.bitLength()+7>>3)},t.prototype.generateAsync=function(t,e,n){var s=new X,o=t>>1;this.e=parseInt(e,16);var h=new O(e,16),a=this,u=function(){var e=function(){if(a.p.compareTo(a.q)<=0){var t=a.p;a.p=a.q,a.q=t}var e=a.p.subtract(O.ONE),i=a.q.subtract(O.ONE),r=e.multiply(i);0==r.gcd(h).compareTo(O.ONE)?(a.n=a.p.multiply(a.q),a.d=h.modInverse(r),a.dmp1=a.d.mod(e),a.dmq1=a.d.mod(i),a.coeff=a.q.modInverse(a.p),setTimeout(function(){n()},0)):setTimeout(u,0)},i=function(){a.q=M(),a.q.fromNumberAsync(o,1,s,function(){a.q.subtract(O.ONE).gcda(h,function(t){0==t.compareTo(O.ONE)&&a.q.isProbablePrime(10)?setTimeout(e,0):setTimeout(i,0)})})},r=function(){a.p=M(),a.p.fromNumberAsync(t-o,1,s,function(){a.p.subtract(O.ONE).gcda(h,function(t){0==t.compareTo(O.ONE)&&a.p.isProbablePrime(10)?setTimeout(i,0):setTimeout(r,0)})})};setTimeout(r,0)};setTimeout(u,0)},t.prototype.sign=function(t,e,i){var r=function(t,e){if(e<t.length+22)return console.error("Message too long for RSA"),null;for(var i=e-t.length-6,r="",n=0;n<i;n+=2)r+="ff";return q("0001"+r+"00"+t,16)}((W[i]||"")+e(t).toString(),this.n.bitLength()/4);if(null==r)return null;var n=this.doPrivate(r);if(null==n)return null;var s=n.toString(16);return 0==(1&s.length)?s:"0"+s},t.prototype.verify=function(t,e,i){var r=q(e,16),n=this.doPublic(r);return null==n?null:function(t){for(var e in W)if(W.hasOwnProperty(e)){var i=W[e],r=i.length;if(t.substr(0,r)==i)return t.substr(r)}return t}(n.toString(16).replace(/^1f+00/,""))==i(t).toString()},t}();var W={md2:"3020300c06082a864886f70d020205000410",md5:"3020300c06082a864886f70d020505000410",sha1:"3021300906052b0e03021a05000414",sha224:"302d300d06096086480165030402040500041c",sha256:"3031300d060960864801650304020105000420",sha384:"3041300d060960864801650304020205000430",sha512:"3051300d060960864801650304020305000440",ripemd160:"3021300906052b2403020105000414"};var tt={};tt.lang={extend:function(t,e,i){if(!e||!t)throw new Error("YAHOO.lang.extend failed, please check that all dependencies are included.");var r=function(){};if(r.prototype=e.prototype,t.prototype=new r,(t.prototype.constructor=t).superclass=e.prototype,e.prototype.constructor==Object.prototype.constructor&&(e.prototype.constructor=e),i){var n;for(n in i)t.prototype[n]=i[n];var s=function(){},o=["toString","valueOf"];try{/MSIE/.test(navigator.userAgent)&&(s=function(t,e){for(n=0;n<o.length;n+=1){var i=o[n],r=e[i];"function"==typeof r&&r!=Object.prototype[i]&&(t[i]=r)}})}catch(t){}s(t.prototype,i)}}};var et={};void 0!==et.asn1&&et.asn1||(et.asn1={}),et.asn1.ASN1Util=new function(){this.integerToByteHex=function(t){var e=t.toString(16);return e.length%2==1&&(e="0"+e),e},this.bigIntToMinTwosComplementsHex=function(t){var e=t.toString(16);if("-"!=e.substr(0,1))e.length%2==1?e="0"+e:e.match(/^[0-7]/)||(e="00"+e);else{var i=e.substr(1).length;i%2==1?i+=1:e.match(/^[0-7]/)||(i+=2);for(var r="",n=0;n<i;n++)r+="f";e=new O(r,16).xor(t).add(O.ONE).toString(16).replace(/^-/,"")}return e},this.getPEMStringFromHex=function(t,e){return hextopem(t,e)},this.newObject=function(t){var e=et.asn1,i=e.DERBoolean,r=e.DERInteger,n=e.DERBitString,s=e.DEROctetString,o=e.DERNull,h=e.DERObjectIdentifier,a=e.DEREnumerated,u=e.DERUTF8String,c=e.DERNumericString,f=e.DERPrintableString,l=e.DERTeletexString,p=e.DERIA5String,g=e.DERUTCTime,d=e.DERGeneralizedTime,v=e.DERSequence,m=e.DERSet,y=e.DERTaggedObject,b=e.ASN1Util.newObject,T=Object.keys(t);if(1!=T.length)throw"key of param shall be only one.";var S=T[0];if(-1==":bool:int:bitstr:octstr:null:oid:enum:utf8str:numstr:prnstr:telstr:ia5str:utctime:gentime:seq:set:tag:".indexOf(":"+S+":"))throw"undefined key: "+S;if("bool"==S)return new i(t[S]);if("int"==S)return new r(t[S]);if("bitstr"==S)return new n(t[S]);if("octstr"==S)return new s(t[S]);if("null"==S)return new o(t[S]);if("oid"==S)return new h(t[S]);if("enum"==S)return new a(t[S]);if("utf8str"==S)return new u(t[S]);if("numstr"==S)return new c(t[S]);if("prnstr"==S)return new f(t[S]);if("telstr"==S)return new l(t[S]);if("ia5str"==S)return new p(t[S]);if("utctime"==S)return new g(t[S]);if("gentime"==S)return new d(t[S]);if("seq"==S){for(var E=t[S],w=[],D=0;D<E.length;D++){var x=b(E[D]);w.push(x)}return new v({array:w})}if("set"==S){for(E=t[S],w=[],D=0;D<E.length;D++){x=b(E[D]);w.push(x)}return new m({array:w})}if("tag"==S){var R=t[S];if("[object Array]"===Object.prototype.toString.call(R)&&3==R.length){var B=b(R[2]);return new y({tag:R[0],explicit:R[1],obj:B})}var A={};if(void 0!==R.explicit&&(A.explicit=R.explicit),void 0!==R.tag&&(A.tag=R.tag),void 0===R.obj)throw"obj shall be specified for 'tag'.";return A.obj=b(R.obj),new y(A)}},this.jsonToASN1HEX=function(t){return this.newObject(t).getEncodedHex()}},et.asn1.ASN1Util.oidHexToInt=function(t){for(var e="",i=parseInt(t.substr(0,2),16),r=(e=Math.floor(i/40)+"."+i%40,""),n=2;n<t.length;n+=2){var s=("00000000"+parseInt(t.substr(n,2),16).toString(2)).slice(-8);if(r+=s.substr(1,7),"0"==s.substr(0,1))e=e+"."+new O(r,2).toString(10),r=""}return e},et.asn1.ASN1Util.oidIntToHex=function(t){var h=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},e=function(t){var e="",i=new O(t,10).toString(2),r=7-i.length%7;7==r&&(r=0);for(var n="",s=0;s<r;s++)n+="0";i=n+i;for(s=0;s<i.length-1;s+=7){var o=i.substr(s,7);s!=i.length-7&&(o="1"+o),e+=h(parseInt(o,2))}return e};if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var i="",r=t.split("."),n=40*parseInt(r[0])+parseInt(r[1]);i+=h(n),r.splice(0,2);for(var s=0;s<r.length;s++)i+=e(r[s]);return i},et.asn1.ASN1Object=function(){this.getLengthHexFromValue=function(){if(void 0===this.hV||null==this.hV)throw"this.hV is null or undefined.";if(this.hV.length%2==1)throw"value hex must be even length: n="+"".length+",v="+this.hV;var t=this.hV.length/2,e=t.toString(16);if(e.length%2==1&&(e="0"+e),t<128)return e;var i=e.length/2;if(15<i)throw"ASN.1 length too long to represent by 8x: n = "+t.toString(16);return(128+i).toString(16)+e},this.getEncodedHex=function(){return(null==this.hTLV||this.isModified)&&(this.hV=this.getFreshValueHex(),this.hL=this.getLengthHexFromValue(),this.hTLV=this.hT+this.hL+this.hV,this.isModified=!1),this.hTLV},this.getValueHex=function(){return this.getEncodedHex(),this.hV},this.getFreshValueHex=function(){return""}},et.asn1.DERAbstractString=function(t){et.asn1.DERAbstractString.superclass.constructor.call(this),this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(this.s)},this.setStringHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?this.setString(t):void 0!==t.str?this.setString(t.str):void 0!==t.hex&&this.setStringHex(t.hex))},tt.lang.extend(et.asn1.DERAbstractString,et.asn1.ASN1Object),et.asn1.DERAbstractTime=function(t){et.asn1.DERAbstractTime.superclass.constructor.call(this),this.localDateToUTC=function(t){return utc=t.getTime()+6e4*t.getTimezoneOffset(),new Date(utc)},this.formatDate=function(t,e,i){var r=this.zeroPadding,n=this.localDateToUTC(t),s=String(n.getFullYear());"utc"==e&&(s=s.substr(2,2));var o=s+r(String(n.getMonth()+1),2)+r(String(n.getDate()),2)+r(String(n.getHours()),2)+r(String(n.getMinutes()),2)+r(String(n.getSeconds()),2);if(!0===i){var h=n.getMilliseconds();if(0!=h){var a=r(String(h),3);o=o+"."+(a=a.replace(/[0]+$/,""))}}return o+"Z"},this.zeroPadding=function(t,e){return t.length>=e?t:new Array(e-t.length+1).join("0")+t},this.getString=function(){return this.s},this.setString=function(t){this.hTLV=null,this.isModified=!0,this.s=t,this.hV=stohex(t)},this.setByDateValue=function(t,e,i,r,n,s){var o=new Date(Date.UTC(t,e-1,i,r,n,s,0));this.setByDate(o)},this.getFreshValueHex=function(){return this.hV}},tt.lang.extend(et.asn1.DERAbstractTime,et.asn1.ASN1Object),et.asn1.DERAbstractStructured=function(t){et.asn1.DERAbstractString.superclass.constructor.call(this),this.setByASN1ObjectArray=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array=t},this.appendASN1Object=function(t){this.hTLV=null,this.isModified=!0,this.asn1Array.push(t)},this.asn1Array=new Array,void 0!==t&&void 0!==t.array&&(this.asn1Array=t.array)},tt.lang.extend(et.asn1.DERAbstractStructured,et.asn1.ASN1Object),et.asn1.DERBoolean=function(){et.asn1.DERBoolean.superclass.constructor.call(this),this.hT="01",this.hTLV="0101ff"},tt.lang.extend(et.asn1.DERBoolean,et.asn1.ASN1Object),et.asn1.DERInteger=function(t){et.asn1.DERInteger.superclass.constructor.call(this),this.hT="02",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=et.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new O(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.bigint?this.setByBigInteger(t.bigint):void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},tt.lang.extend(et.asn1.DERInteger,et.asn1.ASN1Object),et.asn1.DERBitString=function(t){if(void 0!==t&&void 0!==t.obj){var e=et.asn1.ASN1Util.newObject(t.obj);t.hex="00"+e.getEncodedHex()}et.asn1.DERBitString.superclass.constructor.call(this),this.hT="03",this.setHexValueIncludingUnusedBits=function(t){this.hTLV=null,this.isModified=!0,this.hV=t},this.setUnusedBitsAndHexValue=function(t,e){if(t<0||7<t)throw"unused bits shall be from 0 to 7: u = "+t;var i="0"+t;this.hTLV=null,this.isModified=!0,this.hV=i+e},this.setByBinaryString=function(t){var e=8-(t=t.replace(/0+$/,"")).length%8;8==e&&(e=0);for(var i=0;i<=e;i++)t+="0";var r="";for(i=0;i<t.length-1;i+=8){var n=t.substr(i,8),s=parseInt(n,2).toString(16);1==s.length&&(s="0"+s),r+=s}this.hTLV=null,this.isModified=!0,this.hV="0"+e+r},this.setByBooleanArray=function(t){for(var e="",i=0;i<t.length;i++)1==t[i]?e+="1":e+="0";this.setByBinaryString(e)},this.newFalseArray=function(t){for(var e=new Array(t),i=0;i<t;i++)e[i]=!1;return e},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t&&t.toLowerCase().match(/^[0-9a-f]+$/)?this.setHexValueIncludingUnusedBits(t):void 0!==t.hex?this.setHexValueIncludingUnusedBits(t.hex):void 0!==t.bin?this.setByBinaryString(t.bin):void 0!==t.array&&this.setByBooleanArray(t.array))},tt.lang.extend(et.asn1.DERBitString,et.asn1.ASN1Object),et.asn1.DEROctetString=function(t){if(void 0!==t&&void 0!==t.obj){var e=et.asn1.ASN1Util.newObject(t.obj);t.hex=e.getEncodedHex()}et.asn1.DEROctetString.superclass.constructor.call(this,t),this.hT="04"},tt.lang.extend(et.asn1.DEROctetString,et.asn1.DERAbstractString),et.asn1.DERNull=function(){et.asn1.DERNull.superclass.constructor.call(this),this.hT="05",this.hTLV="0500"},tt.lang.extend(et.asn1.DERNull,et.asn1.ASN1Object),et.asn1.DERObjectIdentifier=function(t){var h=function(t){var e=t.toString(16);return 1==e.length&&(e="0"+e),e},s=function(t){var e="",i=new O(t,10).toString(2),r=7-i.length%7;7==r&&(r=0);for(var n="",s=0;s<r;s++)n+="0";i=n+i;for(s=0;s<i.length-1;s+=7){var o=i.substr(s,7);s!=i.length-7&&(o="1"+o),e+=h(parseInt(o,2))}return e};et.asn1.DERObjectIdentifier.superclass.constructor.call(this),this.hT="06",this.setValueHex=function(t){this.hTLV=null,this.isModified=!0,this.s=null,this.hV=t},this.setValueOidString=function(t){if(!t.match(/^[0-9.]+$/))throw"malformed oid string: "+t;var e="",i=t.split("."),r=40*parseInt(i[0])+parseInt(i[1]);e+=h(r),i.splice(0,2);for(var n=0;n<i.length;n++)e+=s(i[n]);this.hTLV=null,this.isModified=!0,this.s=null,this.hV=e},this.setValueName=function(t){var e=et.asn1.x509.OID.name2oid(t);if(""===e)throw"DERObjectIdentifier oidName undefined: "+t;this.setValueOidString(e)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&("string"==typeof t?t.match(/^[0-2].[0-9.]+$/)?this.setValueOidString(t):this.setValueName(t):void 0!==t.oid?this.setValueOidString(t.oid):void 0!==t.hex?this.setValueHex(t.hex):void 0!==t.name&&this.setValueName(t.name))},tt.lang.extend(et.asn1.DERObjectIdentifier,et.asn1.ASN1Object),et.asn1.DEREnumerated=function(t){et.asn1.DEREnumerated.superclass.constructor.call(this),this.hT="0a",this.setByBigInteger=function(t){this.hTLV=null,this.isModified=!0,this.hV=et.asn1.ASN1Util.bigIntToMinTwosComplementsHex(t)},this.setByInteger=function(t){var e=new O(String(t),10);this.setByBigInteger(e)},this.setValueHex=function(t){this.hV=t},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.int?this.setByInteger(t.int):"number"==typeof t?this.setByInteger(t):void 0!==t.hex&&this.setValueHex(t.hex))},tt.lang.extend(et.asn1.DEREnumerated,et.asn1.ASN1Object),et.asn1.DERUTF8String=function(t){et.asn1.DERUTF8String.superclass.constructor.call(this,t),this.hT="0c"},tt.lang.extend(et.asn1.DERUTF8String,et.asn1.DERAbstractString),et.asn1.DERNumericString=function(t){et.asn1.DERNumericString.superclass.constructor.call(this,t),this.hT="12"},tt.lang.extend(et.asn1.DERNumericString,et.asn1.DERAbstractString),et.asn1.DERPrintableString=function(t){et.asn1.DERPrintableString.superclass.constructor.call(this,t),this.hT="13"},tt.lang.extend(et.asn1.DERPrintableString,et.asn1.DERAbstractString),et.asn1.DERTeletexString=function(t){et.asn1.DERTeletexString.superclass.constructor.call(this,t),this.hT="14"},tt.lang.extend(et.asn1.DERTeletexString,et.asn1.DERAbstractString),et.asn1.DERIA5String=function(t){et.asn1.DERIA5String.superclass.constructor.call(this,t),this.hT="16"},tt.lang.extend(et.asn1.DERIA5String,et.asn1.DERAbstractString),et.asn1.DERUTCTime=function(t){et.asn1.DERUTCTime.superclass.constructor.call(this,t),this.hT="17",this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"utc"),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{12}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date))},tt.lang.extend(et.asn1.DERUTCTime,et.asn1.DERAbstractTime),et.asn1.DERGeneralizedTime=function(t){et.asn1.DERGeneralizedTime.superclass.constructor.call(this,t),this.hT="18",this.withMillis=!1,this.setByDate=function(t){this.hTLV=null,this.isModified=!0,this.date=t,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)},this.getFreshValueHex=function(){return void 0===this.date&&void 0===this.s&&(this.date=new Date,this.s=this.formatDate(this.date,"gen",this.withMillis),this.hV=stohex(this.s)),this.hV},void 0!==t&&(void 0!==t.str?this.setString(t.str):"string"==typeof t&&t.match(/^[0-9]{14}Z$/)?this.setString(t):void 0!==t.hex?this.setStringHex(t.hex):void 0!==t.date&&this.setByDate(t.date),!0===t.millis&&(this.withMillis=!0))},tt.lang.extend(et.asn1.DERGeneralizedTime,et.asn1.DERAbstractTime),et.asn1.DERSequence=function(t){et.asn1.DERSequence.superclass.constructor.call(this,t),this.hT="30",this.getFreshValueHex=function(){for(var t="",e=0;e<this.asn1Array.length;e++){t+=this.asn1Array[e].getEncodedHex()}return this.hV=t,this.hV}},tt.lang.extend(et.asn1.DERSequence,et.asn1.DERAbstractStructured),et.asn1.DERSet=function(t){et.asn1.DERSet.superclass.constructor.call(this,t),this.hT="31",this.sortFlag=!0,this.getFreshValueHex=function(){for(var t=new Array,e=0;e<this.asn1Array.length;e++){var i=this.asn1Array[e];t.push(i.getEncodedHex())}return 1==this.sortFlag&&t.sort(),this.hV=t.join(""),this.hV},void 0!==t&&void 0!==t.sortflag&&0==t.sortflag&&(this.sortFlag=!1)},tt.lang.extend(et.asn1.DERSet,et.asn1.DERAbstractStructured),et.asn1.DERTaggedObject=function(t){et.asn1.DERTaggedObject.superclass.constructor.call(this),this.hT="a0",this.hV="",this.isExplicit=!0,this.asn1Object=null,this.setASN1Object=function(t,e,i){this.hT=e,this.isExplicit=t,this.asn1Object=i,this.isExplicit?(this.hV=this.asn1Object.getEncodedHex(),this.hTLV=null,this.isModified=!0):(this.hV=null,this.hTLV=i.getEncodedHex(),this.hTLV=this.hTLV.replace(/^../,e),this.isModified=!1)},this.getFreshValueHex=function(){return this.hV},void 0!==t&&(void 0!==t.tag&&(this.hT=t.tag),void 0!==t.explicit&&(this.isExplicit=t.explicit),void 0!==t.obj&&(this.asn1Object=t.obj,this.setASN1Object(this.isExplicit,this.hT,this.asn1Object)))},tt.lang.extend(et.asn1.DERTaggedObject,et.asn1.ASN1Object);var it=function(i){function r(t){var e=i.call(this)||this;return t&&("string"==typeof t?e.parseKey(t):(r.hasPrivateKeyProperty(t)||r.hasPublicKeyProperty(t))&&e.parsePropertiesFrom(t)),e}return function(t,e){function i(){this.constructor=t}p(t,e),t.prototype=null===e?Object.create(e):(i.prototype=e.prototype,new i)}(r,i),r.prototype.parseKey=function(t){try{var e=0,i=0,r=/^\s*(?:[0-9A-Fa-f][0-9A-Fa-f]\s*)+$/.test(t)?d(t):v.unarmor(t),n=x.decode(r);if(3===n.sub.length&&(n=n.sub[2].sub[0]),9===n.sub.length){e=n.sub[1].getHexStringValue(),this.n=q(e,16),i=n.sub[2].getHexStringValue(),this.e=parseInt(i,16);var s=n.sub[3].getHexStringValue();this.d=q(s,16);var o=n.sub[4].getHexStringValue();this.p=q(o,16);var h=n.sub[5].getHexStringValue();this.q=q(h,16);var a=n.sub[6].getHexStringValue();this.dmp1=q(a,16);var u=n.sub[7].getHexStringValue();this.dmq1=q(u,16);var c=n.sub[8].getHexStringValue();this.coeff=q(c,16)}else{if(2!==n.sub.length)return!1;var f=n.sub[1].sub[0];e=f.sub[0].getHexStringValue(),this.n=q(e,16),i=f.sub[1].getHexStringValue(),this.e=parseInt(i,16)}return!0}catch(t){return!1}},r.prototype.getPrivateBaseKey=function(){var t={array:[new et.asn1.DERInteger({int:0}),new et.asn1.DERInteger({bigint:this.n}),new et.asn1.DERInteger({int:this.e}),new et.asn1.DERInteger({bigint:this.d}),new et.asn1.DERInteger({bigint:this.p}),new et.asn1.DERInteger({bigint:this.q}),new et.asn1.DERInteger({bigint:this.dmp1}),new et.asn1.DERInteger({bigint:this.dmq1}),new et.asn1.DERInteger({bigint:this.coeff})]};return new et.asn1.DERSequence(t).getEncodedHex()},r.prototype.getPrivateBaseKeyB64=function(){return c(this.getPrivateBaseKey())},r.prototype.getPublicBaseKey=function(){var t=new et.asn1.DERSequence({array:[new et.asn1.DERObjectIdentifier({oid:"1.2.840.113549.1.1.1"}),new et.asn1.DERNull]}),e=new et.asn1.DERSequence({array:[new et.asn1.DERInteger({bigint:this.n}),new et.asn1.DERInteger({int:this.e})]}),i=new et.asn1.DERBitString({hex:"00"+e.getEncodedHex()});return new et.asn1.DERSequence({array:[t,i]}).getEncodedHex()},r.prototype.getPublicBaseKeyB64=function(){return c(this.getPublicBaseKey())},r.wordwrap=function(t,e){if(!t)return t;var i="(.{1,"+(e=e||64)+"})( +|$\n?)|(.{1,"+e+"})";return t.match(RegExp(i,"g")).join("\n")},r.prototype.getPrivateKey=function(){var t="-----BEGIN RSA PRIVATE KEY-----\n";return t+=r.wordwrap(this.getPrivateBaseKeyB64())+"\n",t+="-----END RSA PRIVATE KEY-----"},r.prototype.getPublicKey=function(){var t="-----BEGIN PUBLIC KEY-----\n";return t+=r.wordwrap(this.getPublicBaseKeyB64())+"\n",t+="-----END PUBLIC KEY-----"},r.hasPublicKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")},r.hasPrivateKeyProperty=function(t){return(t=t||{}).hasOwnProperty("n")&&t.hasOwnProperty("e")&&t.hasOwnProperty("d")&&t.hasOwnProperty("p")&&t.hasOwnProperty("q")&&t.hasOwnProperty("dmp1")&&t.hasOwnProperty("dmq1")&&t.hasOwnProperty("coeff")},r.prototype.parsePropertiesFrom=function(t){this.n=t.n,this.e=t.e,t.hasOwnProperty("d")&&(this.d=t.d,this.p=t.p,this.q=t.q,this.dmp1=t.dmp1,this.dmq1=t.dmq1,this.coeff=t.coeff)},r}(Q),rt=function(){function t(t){t=t||{},this.default_key_size=parseInt(t.default_key_size,10)||1024,this.default_public_exponent=t.default_public_exponent||"010001",this.log=t.log||!1,this.key=null}return t.prototype.setKey=function(t){this.log&&this.key&&console.warn("A key was already set, overriding existing."),this.key=new it(t)},t.prototype.setPrivateKey=function(t){this.setKey(t)},t.prototype.setPublicKey=function(t){this.setKey(t)},t.prototype.decrypt=function(t){try{return this.getKey().decrypt(f(t))}catch(t){return!1}},t.prototype.encrypt=function(t){try{return c(this.getKey().encrypt(t))}catch(t){return!1}},t.prototype.sign=function(t,e,i){try{return c(this.getKey().sign(t,e,i))}catch(t){return!1}},t.prototype.verify=function(t,e,i){try{return this.getKey().verify(t,f(e),i)}catch(t){return!1}},t.prototype.getKey=function(t){if(!this.key){if(this.key=new it,t&&"[object Function]"==={}.toString.call(t))return void this.key.generateAsync(this.default_key_size,this.default_public_exponent,t);this.key.generate(this.default_key_size,this.default_public_exponent)}return this.key},t.prototype.getPrivateKey=function(){return this.getKey().getPrivateKey()},t.prototype.getPrivateKeyB64=function(){return this.getKey().getPrivateBaseKeyB64()},t.prototype.getPublicKey=function(){return this.getKey().getPublicKey()},t.prototype.getPublicKeyB64=function(){return this.getKey().getPublicBaseKeyB64()},t.version="3.0.0-rc.1",t}();window.JSEncrypt=rt,t.JSEncrypt=rt,t.default=rt,Object.defineProperty(t,"__esModule",{value:!0})});