-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.js
588 lines (477 loc) · 15.3 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
/**
* Implement the IE's selectNodes function
* @param {Document} xmlDoc the AJAX responseXML data
* @param {string} elementPath xpath data
* @returns {Node[]} a list of all the data that match the xpath
*/
function SelectNodes(xmlDoc, elementPath)
{
if(window.ActiveXObject)
{
return xmlDoc.selectNodes(elementPath);
}
else
{
var xpe = new XPathEvaluator();
var nsResolver = xpe.createNSResolver( xmlDoc.ownerDocument == null ? xmlDoc.documentElement : xmlDoc.ownerDocument.documentElement);
var result = xpe.evaluate(elementPath, xmlDoc, nsResolver, 0, null);
var found = [];
var res;
while (res = result.iterateNext())
found.push(res);
return found;
}
}
//初始化菜单参数
var menuItems = new Array();
var topMenuItems = new Array();
var linkItems = new Array();
var userId="";
var topmenu;//用来保存顶级菜单
var topMenuLength = 0;
var menuLength = 0;
var linkLength = 0;
//父节点ID,本身ID,权限名称,权限描述,权限路径,权限图片
function send_request(url,SystemBh)
{
/** @type {XMLHttpRequest} */
var http_request = false;
if( window.XMLHttpRequest )
{
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType)
{
http_request.overrideMimeType("text/xml");
}
}
else if (window.ActiveXObject)
{
try
{
http_request = new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
try
{
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
catch (ei)
{}
}
}
if (!http_request)
{
window.alert("不能创建对象!");
return false;
}
try
{
http_request.open("POST",url, false);
http_request.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
http_request.send(null);
/** @type {Document} */
var tmpxml = http_request.responseXML;
//加载顶层菜单开始
var topXml = SelectNodes(tmpxml, "/Menus/topMenus/Menu");//tmpxml.selectNodes("/Menus/topMenus/Menu");
for(i=0;i<topXml.length;i++)
{
topMenuItems[topMenuLength] = new Array();
topMenuItems[topMenuLength][0] = topXml[i].attributes.getNamedItem("parentid").value;
topMenuItems[topMenuLength][1] = SystemBh + "_" + topXml[i].attributes.getNamedItem("id").value;
topMenuItems[topMenuLength][2] = topXml[i].attributes.getNamedItem("name").value;
topMenuItems[topMenuLength][3] = topXml[i].attributes.getNamedItem("title").value;
topMenuItems[topMenuLength][4] = topXml[i].attributes.getNamedItem("path").value;
topMenuItems[topMenuLength][5] = topXml[i].attributes.getNamedItem("imageUrl").value;
topMenuItems[topMenuLength][6] = topXml[i].attributes.getNamedItem("defaultPage").value;
topMenuLength++;
}
//加载顶层菜单结束
//加载一层菜单开始
var menuXml = SelectNodes(tmpxml, "/Menus/Level1Menus/Menu");
for(i=0;i<menuXml.length;i++)
{
menuItems[menuLength] = new Array();
menuItems[menuLength][0] = SystemBh + "_" + menuXml[i].attributes.getNamedItem("parentid").value;
menuItems[menuLength][1] = SystemBh + "_" + menuXml[i].attributes.getNamedItem("id").value;
menuItems[menuLength][2] = menuXml[i].attributes.getNamedItem("name").value;
menuItems[menuLength][3] = menuXml[i].attributes.getNamedItem("title").value;
menuItems[menuLength][4] = menuXml[i].attributes.getNamedItem("path").value;
menuItems[menuLength][5] = menuXml[i].attributes.getNamedItem("imageUrl").value;
menuLength++;
}
//加载一层菜单结束
//加载二层菜单开始
var linkXml = SelectNodes(tmpxml, "/Menus/Level2Menus/Menu");
for(i=0;i<linkXml.length;i++)
{
linkItems[linkLength] = new Array();
linkItems[linkLength][0] = SystemBh + "_" + linkXml[i].attributes.getNamedItem("parentid").value;
linkItems[linkLength][1] = SystemBh + "_" + linkXml[i].attributes.getNamedItem("id").value;
linkItems[linkLength][2] = linkXml[i].attributes.getNamedItem("name").value;
linkItems[linkLength][3] = linkXml[i].attributes.getNamedItem("title").value;
linkItems[linkLength][4] = linkXml[i].attributes.getNamedItem("path").value;
linkItems[linkLength][5] = linkXml[i].attributes.getNamedItem("imageUrl").value;
linkLength++;
}
//加载二层菜单结束
}
catch(eii)
{alert("加载编号为"+SystemBh+"的应用系统失败,可能是网络延迟问题!");}
}
var tmptbody = "";
//生成Top菜单
function loadTopMenu(){
var topMenu="";
var top=77;//固定高度等于77
var left=28;//固定左边宽度
for(var i=0;i<topMenuItems.length;i++)
{
topMenu+= "<div id='KjFs"+i+"' class=desktop_ico style='position: absolute; left:"+left+"px; top:"+top+"px;'>";
topMenu += "<p class='p1'>";
topMenu += "<img style='cursor: pointer ' src='../framework/images/menu_icons/"+topMenuItems[i][5]+"' ondblclick=";
topMenu += "javascript:KjFsLinkEvent(document.getElementById('KjFsBt"+i+"').innerText,'new_window.jsp?lianjie="+topMenuItems[i][6]+"','"+topMenuItems[i][1]+"'); ";
topMenu += "onmousedown=javascript:m('KjFs"+i+"'); />";
topMenu += "</p><p class='p1' id='KjFsBt"+i+"' >" + topMenuItems[i][2] + "</p></div>";
//判断页面高度是否大与450 如果大与 则换移动左边距
top=top+85;
if(top >450 )
{
left=left+86;
top=77;
}
}
document.getElementById("centernav").innerHTML = topMenu;
}
//创建菜单条上的小菜单
function createBottomTd(title)
{
var divbot=document.getElementById("topMenuDiv");
var newCell = document.getElementById("subToolTbl").rows[0].insertCell();
if(getIEVersion()>=8){
document.getElementById("subToolTbl").width = 109 * document.getElementById("subToolTbl").rows[0].cells.length;
}else{
document.getElementById("subToolTbl").style.width = 109 * document.getElementById("subToolTbl").rows[0].cells.length;
}
newCell.id = "subToolTblTd" +Winid;
newCell.title = title;
newCell.name="tableWin"+Winid;
newCell.innerHTML = "<span menu='menu4' id=subToolTblTd"+Winid+";>" + title + "</span>";
newCell.onclick = new Function("showCurrentPage("+Winid+")");
newCell.menu='menu4';
showCurrentPage(Winid);
}
//显示Tab菜单
function showCurrentPage(PageNum){
if (PageNum == 0 || document.getElementById("win"+PageNum) == null)
{
return(false);
}
if (PageNum == currentPage)
{
if (document.getElementById("win"+PageNum).style.display == "none")
{
//document.getElementById("subToolTblTd" + PageNum).className = "tdClassIsSelect";
MyWin.Show("win"+PageNum);
return(false);
}
if (oldPageNum == 0 || document.getElementById("win"+oldPageNum) == null)
{
if (document.getElementById("win"+PageNum).style.display == "none")
{
//document.getElementById("subToolTblTd" + PageNum).className = "tdClassIsSelect";
MyWin.Show("win"+PageNum);
}
else
{
document.getElementById("subToolTblTd" + PageNum).className = "tdClassNoSelect";
document.getElementById("win"+PageNum).style.display = "none";
}
}
else
{
if (document.getElementById("win"+oldPageNum).style.display == "none")
{
document.getElementById("subToolTblTd" + PageNum).className = "tdClassNoSelect";
document.getElementById("win"+PageNum).style.display = "none";
}
else
{
showCurrentPage(oldPageNum);
}
}
return(false);
}
MyWin.Show("win"+PageNum);
//currentPage = PageNum;
}
//关闭tab菜单
function closeSubPage(PageNum){
document.getElementById("iframeTr" + PageNum).removeNode(true);
//document.getElementById("frm" + PageNum).removeNode(true);
document.getElementById("subToolTblTd" + PageNum).removeNode(true);
showCurrentPage(0);
}
//刷新当前页面
function refurbishCurrentPage(){
var temp = document.getElementById("currentPage").value;
document.getElementById("frm" + temp).src = document.getElementById("frm" + temp).src;
}
//移动菜单DIV
var Timer;
function aa(Dir) {
document.all('MENUDIV').doScroll(Dir);Timer=setTimeout('aa("'+Dir+'")',100);
}
//停止滚动条
function StopScroll(){
try{
if(Timer!=null)clearTimeout(Timer)
}
catch(exception){
;
}
}
//打开二级菜单窗口
function KjFsLinkEvent(BT,URL,menuid)
{
topmenu=menuid;//获取顶级菜单ID 保存到topmenu里
MyWin.Create(BT,"[pg]"+URL,1,document.documentElement.clientWidth-70,document.documentElement.clientHeight - 38,1,1);
createBottomTd(BT);
}
//鼠标监听
//主要功能:M() 桌面图标单击移动
// D_NewMouseMove()鼠标左键点下拖动鼠标时
// D_NewMouseUp() 鼠标左键按下时
var Mouse_Obj="none";
var pX
var pY
function m(c_Obj)
{
Mouse_Obj=c_Obj;
pX=parseInt(document.all(Mouse_Obj).style.left)-event.x;
pY=parseInt(document.all(Mouse_Obj).style.top)-event.y;
document.onmousemove=D_NewMouseMove;
document.onmouseup=D_NewMouseUp;
}
function D_NewMouseMove()
{
if(Mouse_Obj!="none")
{
document.all(Mouse_Obj).style.left=pX+event.x;
document.all(Mouse_Obj).style.top=pY+event.y;
event.returnValue=false;
}
}
function D_NewMouseUp()
{
if (Mouse_Obj != "none")
{
var tmpx = document.all(Mouse_Obj).offsetLeft;
var tmpy = document.all(Mouse_Obj).offsetTop;
try
{
var str=tmpx+","+tmpy;
setCookie(userId+Mouse_Obj,str);
}
catch(erro)
{
alert('本机已阻止cookie运行,请更改安全设置!');
}
Mouse_Obj="none";
}
}
/////拖动层结束
/**左边下拉列表JS**/
var LastLeftID = "";
function menuFix() {
try
{
var obj = document.getElementById("leftmenu").getElementsByTagName("li");
for (var i=0; i<obj.length; i++) {
obj[i].onmouseover=function() {
this.className+=(this.className.length>0? " ": "") + "sfhover";
}
obj[i].onMouseDown=function() {
this.className+=(this.className.length>0? " ": "") + "sfhover";
}
obj[i].onMouseUp=function() {
this.className+=(this.className.length>0? " ": "") + "sfhover";
}
obj[i].onmouseout=function() {
this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"), "");
}
}
}catch(erro)
{
}
}
function DoMenu(emid)
{
try
{
var obj = document.getElementById(emid);
obj.className = (obj.className.toLowerCase() == "expanded"?"collapsed":"expanded");
if((LastLeftID!="")&&(emid!=LastLeftID)) //关闭上一个Menu
{
document.getElementById(LastLeftID).className = "collapsed";
}
LastLeftID = emid;
}catch(erro)
{
}
}
function GetMenuID()
{
var MenuID="";
var _paramStr = new String(window.location.href);
var _sharpPos = _paramStr.indexOf("#");
if (_sharpPos >= 0 && _sharpPos < _paramStr.length - 1)
{
_paramStr = _paramStr.substring(_sharpPos + 1, _paramStr.length);
}
else
{
_paramStr = "";
}
if (_paramStr.length > 0)
{
var _paramArr = _paramStr.split("&");
if (_paramArr.length>0)
{
var _paramKeyVal = _paramArr[0].split("=");
if (_paramKeyVal.length>0)
{
MenuID = _paramKeyVal[1];
}
}
}
if(MenuID!="")
{
DoMenu(MenuID)
}
}
GetMenuID(); //*这两个function的顺序要注意一下,不然在Firefox里GetMenuID()不起效果
menuFix();
//MAIN页面右边箭头收缩
function switchSysBar(){
//document.getElementById("jiantou").style.display="none";
document.getElementById("ind_right").style.display="none";;
document.getElementById("jiantou").innerHTML="<div style=position: absolute; right:0px; top:0px; ><div style='height:100%; text-align:right; vertical-align:middle; float:right; padding-top:260px;'><img src=../framework/images/new_08.gif onclick='switchSysBaropen();' /></div></div>";
}
//MAIN页面右边箭头掌开
function switchSysBaropen()
{
document.getElementById("jiantou").innerHTML="<div class=shortcuts id=jiantou style=' position: absolute; right:0px; top:0px;' ><div class='arrow'><img src=./images/new_09.gif onclick='switchSysBar();' /></div></div>"
document.getElementById("ind_right").style.display="";;
}
//页面刷新
function doShowDesk()
{
if (document.getElementById("subToolTbl").rows[0].cells.length > 0)
{
tmpId = document.getElementById("subToolTbl").rows[0].cells[document.getElementById("subToolTbl").rows[0].cells.length-1].id.substring(12);
document.getElementById("win" + tmpId).style.display = "";
}
for(i=0;i<document.getElementById("subToolTbl").rows[0].cells.length;i++)
{
tmpId = document.getElementById("subToolTbl").rows[0].cells[i].id.substring(12);
if (document.getElementById("win" + tmpId).style.display == "")
{
MyWin.Min("win" + tmpId);
}
}
}
//移动底部菜单
function doMoveTopDiv(moveFlag)
{
if (moveFlag == "left")
{
if (parseInt(document.getElementById("subToolTbl").style.pixelLeft) + parseInt(document.getElementById("subToolTbl").style.width) > document.getElementById("idContainer2").clientWidth )
document.getElementById("subToolTbl").style.pixelLeft = document.getElementById("subToolTbl").style.pixelLeft - 107;
}
else
{
if (document.getElementById("subToolTbl").style.pixelLeft < 0 )
document.getElementById("subToolTbl").style.pixelLeft = document.getElementById("subToolTbl").style.pixelLeft + 107;
}
}
function getUserId(UserId)
{
userId=UserId;
}
//设置cookie,默认保持30天
function setCookie(name, value) {
var Days = 30;
var exp = new Date();
exp.setTime(exp.getTime() + Days * 24 * 60 * 60 * 1000);
//document.cookie = name + "=" + escape(value) + ";expires=" + exp.toGMTString();
}
//获取cookie
function getCookie(name) {
//var arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
var arr = document.cookie.split(";");
if (arr != null) {
for(var i=0;i<arr.length;i++) {
var theTmp = arr[i].split("=");
if(name == trimstr(theTmp[0]))
return unescape(theTmp[1]);
}
}
return "";
}
//删除一个cookie
function delCookie(name) {
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval = getCookie(name);
if (cval != null) {
document.cookie = name + "=" + cval + ";expires=" + exp.toGMTString();
}
}
//右键菜单最大化
function Maximize(e)
{
var aid=e.name;
aid=aid.replace(";","");
var wind=aid.substring(aid.lastIndexOf("d")+1,aid.length);
var win=document.getElementById("win"+wind);
MyWin.Show(win.id);
}
//右键菜单最小化
function Minimize(e)
{
var aid=e.name;
aid=aid.replace(";","");
var wind=aid.substring(aid.lastIndexOf("d")+1,aid.length);
var windId="win"+wind;
MyWin.Min(windId);
}
//右键菜单关闭窗口
function WinClose(e)
{
var aid=e.name;
aid=aid.replace(";","");
var wind=aid.substring(aid.lastIndexOf("d")+1,aid.length);
var windId="win"+wind;
var aid=e.name;
MyWin.Close(windId,0);
}
function findshortcuts(userid)
{
kjcdMonitor.findFrmshortcuts(userid,getFrmshortcuts);
}
function getFrmshortcuts(list)
{
var path=getRootPath();
var menulist=new Array();
menulist=list;
var rightmenu=document.getElementById("ChildMenu4");
var textbody="";
for(var i=0; i<menulist.length;i++)
{
// textbody+="<li style='background:url("+menulist[i][5]+") no-repeat 30px 30px;' ><a href=javascript:KjFsLinkEvent('"+menulist[i][2]+"','new_window.jsp?lianjie="+menulist[i][3]+"&fater="+menulist[i][6]+"') >"+menulist[i][2]+"</a></li>";
textbody+="<li no-repeat 30px 30px;' ><a href=javascript:KjFsLinkEvent('"+menulist[i][2]+"','new_window.jsp?lianjie="+menulist[i][3]+"&fater="+menulist[i][6]+"') ><p class=icopp1><img src='"+path+"/framework/images/kjcd_icons/"+menulist[i][5]+"' /></p><p class=icopp2>"+menulist[i][2]+"</a></li>";
}
rightmenu.innerHTML=textbody;
}
chushihua();