1
|
function navigate(url) {
|
2
|
location.href=url;
|
3
|
}
|
4
|
|
5
|
// getElementByID with browser check!!
|
6
|
|
7
|
function getElById(idVal) {
|
8
|
if (document.getElementById != null)
|
9
|
return document.getElementById(idVal);
|
10
|
if (document.all != null)
|
11
|
return document.all[idVal];
|
12
|
|
13
|
alert("Problem getting element by id");
|
14
|
return null;
|
15
|
}
|
16
|
|
17
|
|
18
|
// Node object
|
19
|
|
20
|
function Node(id, pid, name, url, title, target, icon, iconOpen, open , checkable ,checked, add, del) {
|
21
|
|
22
|
this.id = id;
|
23
|
|
24
|
this.pid = pid;
|
25
|
|
26
|
this.name = name;
|
27
|
|
28
|
this.url = url;
|
29
|
|
30
|
this.title = title;
|
31
|
|
32
|
this.target = target;
|
33
|
|
34
|
this.icon = icon;
|
35
|
|
36
|
this.iconOpen = iconOpen;
|
37
|
|
38
|
this._io = open || false;
|
39
|
|
40
|
this.checkable = checkable || false;
|
41
|
|
42
|
this.checked = checked || false;
|
43
|
|
44
|
this.add = add || false;
|
45
|
|
46
|
this.del = del || false;
|
47
|
|
48
|
this._is = false;
|
49
|
|
50
|
this._ls = false;
|
51
|
|
52
|
this._hc = false;
|
53
|
|
54
|
this._ai = 0;
|
55
|
|
56
|
this._p;
|
57
|
|
58
|
}
|
59
|
|
60
|
// Tree object
|
61
|
|
62
|
function dTree(objName) {
|
63
|
|
64
|
this.config = {
|
65
|
|
66
|
target : null,
|
67
|
|
68
|
folderLinks : true,
|
69
|
|
70
|
useSelection : true,
|
71
|
|
72
|
useCookies : true,
|
73
|
|
74
|
useLines : true,
|
75
|
|
76
|
useIcons : true,
|
77
|
|
78
|
useStatusText : false,
|
79
|
|
80
|
closeSameLevel : false,
|
81
|
|
82
|
inOrder : false
|
83
|
|
84
|
};
|
85
|
|
86
|
this.icon = {
|
87
|
|
88
|
root : 'tree-images/zone.gif',
|
89
|
|
90
|
folder : 'tree-images/folder.gif',
|
91
|
|
92
|
folderOpen : 'tree-images/folderopen.gif',
|
93
|
|
94
|
node : 'tree-images/page.gif',
|
95
|
|
96
|
empty : 'tree-images/empty.gif',
|
97
|
|
98
|
line : 'tree-images/line.gif',
|
99
|
|
100
|
join : 'tree-images/join.gif',
|
101
|
|
102
|
joinBottom : 'tree-images/joinbottom.gif',
|
103
|
|
104
|
plus : 'tree-images/plus_updown.gif',
|
105
|
|
106
|
plusBottom : 'tree-images/plus_up.gif',
|
107
|
|
108
|
minus : 'tree-images/minus_.gif',
|
109
|
|
110
|
minusBottom : 'tree-images/minus_up.gif',
|
111
|
|
112
|
nlPlus : 'tree-images/plus_.gif',
|
113
|
|
114
|
nlMinus : 'tree-images/minus_.gif'
|
115
|
|
116
|
};
|
117
|
|
118
|
this.obj = objName;
|
119
|
|
120
|
this.aNodes = [];
|
121
|
|
122
|
this.aIndent = [];
|
123
|
|
124
|
this.root = new Node(-1);
|
125
|
|
126
|
this.selectedNode = null;
|
127
|
|
128
|
this.selectedFound = false;
|
129
|
|
130
|
this.completed = false;
|
131
|
|
132
|
}
|
133
|
|
134
|
|
135
|
|
136
|
// Adds a new node to the node array
|
137
|
|
138
|
dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open, checkable, checked, add, del) {
|
139
|
|
140
|
this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open, checkable, checked, add, del);
|
141
|
|
142
|
};
|
143
|
|
144
|
|
145
|
|
146
|
// Open/close all nodes
|
147
|
|
148
|
dTree.prototype.openAll = function() {
|
149
|
|
150
|
this.oAll(true);
|
151
|
|
152
|
};
|
153
|
|
154
|
dTree.prototype.closeAll = function() {
|
155
|
|
156
|
this.oAll(false);
|
157
|
|
158
|
};
|
159
|
|
160
|
|
161
|
|
162
|
// Outputs the tree to the page
|
163
|
|
164
|
dTree.prototype.toString = function() {
|
165
|
|
166
|
var str = '<div class="treeview">\n';
|
167
|
|
168
|
if (document.getElementById) {
|
169
|
|
170
|
if (this.config.useCookies) this.selectedNode = this.getSelected();
|
171
|
|
172
|
str += this.addNode(this.root);
|
173
|
|
174
|
} else str += 'Browser not supported.';
|
175
|
|
176
|
str += '</div>';
|
177
|
|
178
|
if (!this.selectedFound) this.selectedNode = null;
|
179
|
|
180
|
this.completed = true;
|
181
|
|
182
|
return str;
|
183
|
|
184
|
};
|
185
|
|
186
|
|
187
|
|
188
|
// Creates the tree structure
|
189
|
|
190
|
dTree.prototype.addNode = function(pNode) {
|
191
|
|
192
|
var str = '';
|
193
|
|
194
|
var n=0;
|
195
|
|
196
|
if (this.config.inOrder) n = pNode._ai;
|
197
|
|
198
|
for (n; n<this.aNodes.length; n++) {
|
199
|
|
200
|
if (this.aNodes[n].pid == pNode.id) {
|
201
|
|
202
|
var cn = this.aNodes[n];
|
203
|
|
204
|
cn._p = pNode;
|
205
|
|
206
|
cn._ai = n;
|
207
|
|
208
|
this.setCS(cn);
|
209
|
|
210
|
if (!cn.target && this.config.target) cn.target = this.config.target;
|
211
|
|
212
|
if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);
|
213
|
|
214
|
if (!this.config.folderLinks && cn._hc) cn.url = null;
|
215
|
|
216
|
if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) {
|
217
|
|
218
|
cn._is = true;
|
219
|
|
220
|
this.selectedNode = n;
|
221
|
|
222
|
this.selectedFound = true;
|
223
|
|
224
|
}
|
225
|
|
226
|
str += this.node(cn, n);
|
227
|
|
228
|
if (cn._ls) break;
|
229
|
|
230
|
}
|
231
|
|
232
|
}
|
233
|
|
234
|
return str;
|
235
|
|
236
|
};
|
237
|
|
238
|
|
239
|
// Creates the node icon, url and text
|
240
|
|
241
|
dTree.prototype.node = function(node, nodeId) {
|
242
|
|
243
|
var str = '<div class="node" >' + this.indent(node, nodeId);
|
244
|
|
245
|
if (this.config.useIcons) {
|
246
|
|
247
|
if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);
|
248
|
|
249
|
if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;
|
250
|
|
251
|
if (this.root.id == node.pid) {
|
252
|
|
253
|
node.icon = this.icon.root;
|
254
|
|
255
|
node.iconOpen = this.icon.root;
|
256
|
|
257
|
}
|
258
|
|
259
|
//class="img" border="10" vspace="18" align="bottom" style="border:0px; margin:0; padding:0; FILTER: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=50); -moz-opacity:0.5"
|
260
|
str += '<img style="border:0; margin:0; padding:0; height:16px; vertical-align:top; overflow:hidden;" id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />';
|
261
|
if (node.checkable) {
|
262
|
str += '<input style="border:0; margin:0; padding:0; height:16px; vertical-align:top; overflow:hidden; FILTER: progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=50); " type="checkbox" id="c' + this.obj + node.id + '" onclick="javascript : ' + this.obj + '.c(' + node.id + ');"';
|
263
|
if (node.checked) str += ' checked >'; else str += ' >';
|
264
|
}//else str+='';
|
265
|
|
266
|
}
|
267
|
|
268
|
if (node.url) {
|
269
|
|
270
|
str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="javascript:navigate(\'' + node.url + '\')"';
|
271
|
|
272
|
if (node.title) str += ' title="' + node.title + '"';
|
273
|
|
274
|
//if (node.target) str += ' target="' + node.target + ';"';
|
275
|
|
276
|
if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" ';
|
277
|
|
278
|
if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))
|
279
|
|
280
|
str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"';
|
281
|
|
282
|
str += '>';
|
283
|
|
284
|
}
|
285
|
|
286
|
else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)
|
287
|
|
288
|
str += '<a style="border:0; margin:0; padding:0; text-size: smaller; vertical-align: top; overflow:hidden;" href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">';
|
289
|
|
290
|
str += ' '+node.name;
|
291
|
|
292
|
if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';
|
293
|
|
294
|
if (node.add && node.url) {
|
295
|
str += ' -- <a href="' + node.url + '&qaction=addsub"/> <img style="border:0; margin:0; padding:0; width: 16px; height:16px; vertical-align: top; overflow:hidden;" id="i' + this.obj + nodeId + '" src="images/plus.gif" alt="" /></a>';
|
296
|
}
|
297
|
if (node.del && node.url) {
|
298
|
str += ' <a href="' + node.url + '&qaction=delete"/> <img style="border:0; margin:0; padding:0; width: 11px; height:11px; vertical-align: top; overflow:hidden;" id="i' + this.obj + nodeId + '" src="images/block.gif" alt="" /></a>';
|
299
|
}
|
300
|
|
301
|
if (node._hc) {
|
302
|
|
303
|
str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';
|
304
|
|
305
|
str += this.addNode(node);
|
306
|
|
307
|
str += '</div>';
|
308
|
|
309
|
}
|
310
|
|
311
|
str += '</div>';
|
312
|
|
313
|
this.aIndent.pop();
|
314
|
|
315
|
return str;
|
316
|
|
317
|
};
|
318
|
|
319
|
|
320
|
// Adds the empty and line icons
|
321
|
|
322
|
dTree.prototype.indent = function(node, nodeId) {
|
323
|
|
324
|
var str = '';
|
325
|
|
326
|
if (this.root.id != node.pid) {
|
327
|
|
328
|
for (var n=0; n<this.aIndent.length; n++)
|
329
|
|
330
|
str += '<img style="verical-align: top;" src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" />';
|
331
|
|
332
|
(node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);
|
333
|
|
334
|
if (node._hc) {
|
335
|
|
336
|
str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img id="j' + this.obj + nodeId + '" src="';
|
337
|
|
338
|
if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;
|
339
|
|
340
|
else str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) );
|
341
|
|
342
|
str += '" alt="" /></a>';
|
343
|
|
344
|
} else str += '<img src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" />';
|
345
|
|
346
|
}
|
347
|
|
348
|
return str;
|
349
|
|
350
|
};
|
351
|
|
352
|
|
353
|
|
354
|
// Checks if a node has any children and if it is the last sibling
|
355
|
|
356
|
dTree.prototype.setCS = function(node) {
|
357
|
|
358
|
var lastId;
|
359
|
|
360
|
for (var n=0; n<this.aNodes.length; n++) {
|
361
|
|
362
|
if (this.aNodes[n].pid == node.id) node._hc = true;
|
363
|
|
364
|
if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;
|
365
|
|
366
|
}
|
367
|
|
368
|
if (lastId==node.id) node._ls = true;
|
369
|
|
370
|
};
|
371
|
|
372
|
|
373
|
|
374
|
// Returns the selected node
|
375
|
|
376
|
dTree.prototype.getSelected = function() {
|
377
|
|
378
|
var sn = this.getCookie('cs' + this.obj);
|
379
|
|
380
|
return (sn) ? sn : null;
|
381
|
|
382
|
};
|
383
|
|
384
|
|
385
|
|
386
|
// Highlights the selected node
|
387
|
|
388
|
dTree.prototype.s = function(id) {
|
389
|
|
390
|
if (!this.config.useSelection) return;
|
391
|
|
392
|
var cn = this.aNodes[id];
|
393
|
|
394
|
if (cn._hc && !this.config.folderLinks) return;
|
395
|
|
396
|
if (this.selectedNode != id) {
|
397
|
|
398
|
if (this.selectedNode || this.selectedNode==0) {
|
399
|
|
400
|
eOld = document.getElementById("s" + this.obj + this.selectedNode);
|
401
|
|
402
|
eOld.className = "node";
|
403
|
|
404
|
}
|
405
|
|
406
|
eNew = document.getElementById("s" + this.obj + id);
|
407
|
|
408
|
eNew.className = "nodeSel";
|
409
|
|
410
|
this.selectedNode = id;
|
411
|
|
412
|
if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);
|
413
|
|
414
|
}
|
415
|
|
416
|
};
|
417
|
|
418
|
// Checks all parents
|
419
|
|
420
|
dTree.prototype.c = function(id) {
|
421
|
|
422
|
//alert('callid='+id);
|
423
|
|
424
|
var n=0;
|
425
|
|
426
|
var parent;
|
427
|
|
428
|
parent = document.getElementById("c" + this.obj + id);
|
429
|
|
430
|
//if (parent.checked==true) parent.checked=false; else parent.checked=true;
|
431
|
|
432
|
var what = parent.checked;
|
433
|
|
434
|
for (n; n<this.aNodes.length; n++) {
|
435
|
|
436
|
if (this.aNodes[n].pid == id) {
|
437
|
|
438
|
var cn = this.aNodes[n];
|
439
|
|
440
|
element = document.getElementById("c" + this.obj + cn.id);
|
441
|
|
442
|
element.checked = what;
|
443
|
|
444
|
cn.checked = what;
|
445
|
|
446
|
//alert(cn.pid+'(child)==(parent)'+id+'->'+cn.id+'='+what+','+this.aNodes.length );
|
447
|
|
448
|
this.c(cn.id);
|
449
|
|
450
|
}
|
451
|
|
452
|
}
|
453
|
|
454
|
};
|
455
|
|
456
|
|
457
|
dTree.prototype.generate_checkedlist = function(id) {
|
458
|
|
459
|
var retStr='';
|
460
|
|
461
|
var n=0;
|
462
|
|
463
|
var parent = document.getElementById("c" + this.obj + id);
|
464
|
|
465
|
for (n; n<this.aNodes.length; n++) {
|
466
|
|
467
|
if (this.aNodes[n].pid == id) {
|
468
|
|
469
|
var cn = this.aNodes[n];
|
470
|
|
471
|
var element = document.getElementById("c" + this.obj + cn.id);
|
472
|
|
473
|
//alert(cn.name + ' = ' +element.checked);
|
474
|
|
475
|
if (element.checked) {
|
476
|
|
477
|
if (retStr == '')
|
478
|
{retStr = cn.name; }// this.generate_checkedlist(cn.id);
|
479
|
else
|
480
|
retStr += ',' + cn.name;//this.generate_checkedlist(cn.id);
|
481
|
}
|
482
|
//alert(cn.pid+'(child)==(parent)'+id+'->'+cn.id+'='+what+','+this.aNodes.length );
|
483
|
|
484
|
}
|
485
|
|
486
|
}
|
487
|
|
488
|
return retStr;
|
489
|
};
|
490
|
|
491
|
// Toggle Open or close
|
492
|
|
493
|
dTree.prototype.o = function(id) {
|
494
|
|
495
|
var cn = this.aNodes[id];
|
496
|
|
497
|
this.nodeStatus(!cn._io, id, cn._ls);
|
498
|
|
499
|
cn._io = !cn._io;
|
500
|
|
501
|
if (this.config.closeSameLevel) this.closeLevel(cn);
|
502
|
|
503
|
if (this.config.useCookies) this.updateCookie();
|
504
|
|
505
|
};
|
506
|
|
507
|
|
508
|
|
509
|
// Open or close all nodes
|
510
|
|
511
|
dTree.prototype.oAll = function(status) {
|
512
|
|
513
|
for (var n=0; n<this.aNodes.length; n++) {
|
514
|
|
515
|
if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) {
|
516
|
|
517
|
this.nodeStatus(status, n, this.aNodes[n]._ls);
|
518
|
|
519
|
this.aNodes[n]._io = status;
|
520
|
|
521
|
}
|
522
|
|
523
|
}
|
524
|
|
525
|
if (this.config.useCookies) this.updateCookie();
|
526
|
|
527
|
};
|
528
|
|
529
|
|
530
|
|
531
|
// Opens the tree to a specific node
|
532
|
|
533
|
dTree.prototype.openTo = function(nId, bSelect, bFirst) {
|
534
|
|
535
|
if (!bFirst) {
|
536
|
|
537
|
for (var n=0; n<this.aNodes.length; n++) {
|
538
|
|
539
|
if (this.aNodes[n].id == nId) {
|
540
|
|
541
|
nId=n;
|
542
|
|
543
|
break;
|
544
|
|
545
|
}
|
546
|
|
547
|
}
|
548
|
|
549
|
}
|
550
|
|
551
|
var cn=this.aNodes[nId];
|
552
|
|
553
|
if (cn.pid==this.root.id || !cn._p) return;
|
554
|
|
555
|
cn._io = true;
|
556
|
|
557
|
cn._is = bSelect;
|
558
|
|
559
|
if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);
|
560
|
|
561
|
if (this.completed && bSelect) this.s(cn._ai);
|
562
|
|
563
|
else if (bSelect) this._sn=cn._ai;
|
564
|
|
565
|
this.openTo(cn._p._ai, false, true);
|
566
|
|
567
|
};
|
568
|
|
569
|
|
570
|
|
571
|
// Closes all nodes on the same level as certain node
|
572
|
|
573
|
dTree.prototype.closeLevel = function(node) {
|
574
|
|
575
|
for (var n=0; n<this.aNodes.length; n++) {
|
576
|
|
577
|
if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) {
|
578
|
|
579
|
this.nodeStatus(false, n, this.aNodes[n]._ls);
|
580
|
|
581
|
this.aNodes[n]._io = false;
|
582
|
|
583
|
this.closeAllChildren(this.aNodes[n]);
|
584
|
|
585
|
}
|
586
|
|
587
|
}
|
588
|
|
589
|
};
|
590
|
|
591
|
|
592
|
|
593
|
// Closes all children of a node
|
594
|
|
595
|
dTree.prototype.closeAllChildren = function(node) {
|
596
|
|
597
|
for (var n=0; n<this.aNodes.length; n++) {
|
598
|
|
599
|
if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) {
|
600
|
|
601
|
if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls);
|
602
|
|
603
|
this.aNodes[n]._io = false;
|
604
|
|
605
|
this.closeAllChildren(this.aNodes[n]);
|
606
|
|
607
|
}
|
608
|
|
609
|
}
|
610
|
|
611
|
};
|
612
|
|
613
|
|
614
|
|
615
|
// Change the status of a node(open or closed)
|
616
|
|
617
|
dTree.prototype.nodeStatus = function(status, id, bottom) {
|
618
|
|
619
|
eDiv = document.getElementById('d' + this.obj + id);
|
620
|
|
621
|
eJoin = document.getElementById('j' + this.obj + id);
|
622
|
|
623
|
if (this.config.useIcons) {
|
624
|
|
625
|
eIcon = document.getElementById('i' + this.obj + id);
|
626
|
|
627
|
eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon;
|
628
|
|
629
|
}
|
630
|
|
631
|
eJoin.src = (this.config.useLines)?
|
632
|
|
633
|
((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):
|
634
|
|
635
|
((status)?this.icon.nlMinus:this.icon.nlPlus);
|
636
|
|
637
|
eDiv.style.display = (status) ? 'block': 'none';
|
638
|
|
639
|
};
|
640
|
|
641
|
|
642
|
|
643
|
|
644
|
|
645
|
// [Cookie] Clears a cookie
|
646
|
|
647
|
dTree.prototype.clearCookie = function() {
|
648
|
|
649
|
var now = new Date();
|
650
|
|
651
|
var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
|
652
|
|
653
|
this.setCookie('co'+this.obj, 'cookieValue', yesterday);
|
654
|
|
655
|
this.setCookie('cs'+this.obj, 'cookieValue', yesterday);
|
656
|
|
657
|
};
|
658
|
|
659
|
|
660
|
|
661
|
// [Cookie] Sets value in a cookie
|
662
|
|
663
|
dTree.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {
|
664
|
document.cookie =
|
665
|
escape(cookieName) + '=' + escape(cookieValue) +
|
666
|
(expires ? '; expires=' + expires.toGMTString() : '') +
|
667
|
(path ? '; path=' + path : '') +
|
668
|
(domain ? '; domain=' + domain : '') +
|
669
|
(secure ? '; secure' : '');
|
670
|
};
|
671
|
|
672
|
|
673
|
|
674
|
// [Cookie] Gets a value from a cookie
|
675
|
|
676
|
dTree.prototype.getCookie = function(cookieName) {
|
677
|
|
678
|
var cookieValue = '';
|
679
|
|
680
|
var posName = document.cookie.indexOf(escape(cookieName) + '=');
|
681
|
|
682
|
if (posName != -1) {
|
683
|
|
684
|
var posValue = posName + (escape(cookieName) + '=').length;
|
685
|
|
686
|
var endPos = document.cookie.indexOf(';', posValue);
|
687
|
|
688
|
if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
|
689
|
|
690
|
else cookieValue = unescape(document.cookie.substring(posValue));
|
691
|
|
692
|
}
|
693
|
|
694
|
return (cookieValue);
|
695
|
|
696
|
};
|
697
|
|
698
|
|
699
|
|
700
|
// [Cookie] Returns ids of open nodes as a string
|
701
|
|
702
|
dTree.prototype.updateCookie = function() {
|
703
|
|
704
|
var str = '';
|
705
|
|
706
|
for (var n=0; n<this.aNodes.length; n++) {
|
707
|
|
708
|
if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) {
|
709
|
|
710
|
if (str) str += '.';
|
711
|
|
712
|
str += this.aNodes[n].id;
|
713
|
|
714
|
}
|
715
|
|
716
|
}
|
717
|
|
718
|
this.setCookie('co' + this.obj, str);
|
719
|
|
720
|
};
|
721
|
|
722
|
|
723
|
|
724
|
// [Cookie] Checks if a node id is in a cookie
|
725
|
|
726
|
dTree.prototype.isOpen = function(id) {
|
727
|
|
728
|
var aOpen = this.getCookie('co' + this.obj).split('.');
|
729
|
|
730
|
for (var n=0; n<aOpen.length; n++) {
|
731
|
if (aOpen[n] == id) return true;
|
732
|
}
|
733
|
|
734
|
return false;
|
735
|
};
|
736
|
|
737
|
|
738
|
|
739
|
// If Push and pop is not implemented by the browser
|
740
|
|
741
|
if (!Array.prototype.push) {
|
742
|
|
743
|
Array.prototype.push = function array_push() {
|
744
|
|
745
|
for(var i=0;i<arguments.length;i++)
|
746
|
|
747
|
this[this.length]=arguments[i];
|
748
|
|
749
|
return this.length;
|
750
|
|
751
|
};
|
752
|
|
753
|
}
|
754
|
|
755
|
if (!Array.prototype.pop) {
|
756
|
|
757
|
Array.prototype.pop = function array_pop() {
|
758
|
|
759
|
lastElement = this[this.length-1];
|
760
|
|
761
|
this.length = Math.max(this.length-1,0);
|
762
|
|
763
|
return lastElement;
|
764
|
|
765
|
};
|
766
|
|
767
|
}
|