-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathftiens4.js
executable file
·1182 lines (1005 loc) · 33.3 KB
/
ftiens4.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
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//****************************************************************
// You must keep this copyright notice:
//
// This script is Copyright (c) 2006 by Conor O'Mahony.
// For inquiries, please email GubuSoft@GubuSoft.com.
// GubuSoft is owned and operated by Conor O'Mahony.
// Original author of TreeView script is Marcelino Martins.
//
// Do not download the script's files from here. For a free
// download and full instructions go to the following site:
// http://www.TreeView.net
//****************************************************************
// Log of changes:
// 26 Sep 06 - Updated preLoadIcons function;
// Fix small bugs or typos (in the Folder, InitializeFolder,
// and blockStartHTML functions)
// 14 Feb 06 - Re-brand as GubuSoft
// 08 Jun 04 - Very small change to one error message
// 21 Mar 04 - Support for folder.addChildren allows for much bigger trees
// 12 May 03 - Support for Safari Beta 3
// 01 Mar 03 - VERSION 4.3 - Support for checkboxes
// 21 Feb 03 - Added support for Opera 7
// 22 Sep 02 - Added maySelect member for node-by-node control
// of selection and highlight
// 21 Sep 02 - Cookie values are now separated by cookieCutter
// 12 Sep 02 - VERSION 4.2 - Can highlight Selected Nodes and
// can preserve state through external (DB) IDs
// 29 Aug 02 - Fine tune 'supportDeferral' for IE4 and IE Mac
// 25 Aug 02 - Fixes: STARTALLOPEN, and multi-page frameless
// 09 Aug 02 - Fix repeated folder on Mozilla 1.x
// 31 Jul 02 - VERSION 4.1 - Dramatic speed increase for trees
// with hundreds or thousands of nodes; changes to the control
// flags of the gLnk function
// 18 Jul 02 - Changes in pre-load images function
// 13 Jun 02 - Add ICONPATH var to allow for gif subdir
// 20 Apr 02 - Improve support for frame-less layout
// 07 Apr 02 - Minor changes to support server-side dynamic feeding
// (example: FavoritesManagerASP)
// Definition of class Folder
// *****************************************************************
function Folder(folderDescription, hreference) //constructor
{
//constant data
this.desc = folderDescription;
this.hreference = hreference;
this.id = -1;
this.navObj = 0;
this.iconImg = 0;
this.nodeImg = 0;
this.iconSrc = ICONPATH + "ftv2folderopen.gif";
this.iconSrcClosed = ICONPATH + "ftv2folderclosed.gif";
this.children = new Array;
this.nChildren = 0;
this.level = 0;
this.leftSideCoded = "";
this.isLastNode=false;
this.parentObj = null;
this.maySelect=true;
this.prependHTML = ""
//dynamic data
this.isOpen = false
this.isLastOpenedFolder = false
this.isRendered = 0
//methods
this.initialize = initializeFolder
this.setState = setStateFolder
this.addChild = addChild
this.addChildren = addChildren
this.createIndex = createEntryIndex
this.escondeBlock = escondeBlock
this.esconde = escondeFolder
this.folderMstr = folderMstr
this.renderOb = drawFolder
this.totalHeight = totalHeight
this.subEntries = folderSubEntries
this.linkHTML = linkFolderHTML
this.blockStartHTML = blockStartHTML
this.blockEndHTML = blockEndHTML
this.nodeImageSrc = nodeImageSrc
this.iconImageSrc = iconImageSrc
this.getID = getID
this.forceOpeningOfAncestorFolders = forceOpeningOfAncestorFolders
}
function initializeFolder(level, lastNode, leftSide)
{
var i=0
nc = this.nChildren
this.createIndex()
this.level = level
this.leftSideCoded = leftSide
if (browserVersion == 0 || STARTALLOPEN==1)
this.isOpen=true;
if (level>0)
if (lastNode) //the last child in the children array
leftSide = leftSide + "0"
else
leftSide = leftSide + "1"
this.isLastNode = lastNode
if (nc > 0)
{
level = level + 1
for (i=0 ; i < this.nChildren; i++)
{
if (typeof this.children[i].initialize == 'undefined') //document node was specified using the addChildren function
{
if (typeof this.children[i][0] == 'undefined' || typeof this.children[i] == 'string')
{
this.children[i] = ["item incorrectly defined", ""];
}
//Basic initialization of the Item object
//These members or methods are needed even before the Item is rendered
this.children[i].initialize=initializeItem;
this.children[i].createIndex=createEntryIndex;
if (typeof this.children[i].maySelect == 'undefined')
this.children[i].maySelect=true
this.children[i].forceOpeningOfAncestorFolders = forceOpeningOfAncestorFolders
}
if (i == this.nChildren-1)
this.children[i].initialize(level, 1, leftSide)
else
this.children[i].initialize(level, 0, leftSide)
}
}
}
function drawFolder(insertAtObj)
{
var nodeName = ""
var auxEv = ""
var docW = ""
var i=0
finalizeCreationOfChildDocs(this)
var leftSide = leftSideHTML(this.leftSideCoded)
if (browserVersion > 0)
auxEv = "<a href='javascript:clickOnNode(\""+this.getID()+"\")'>"
else
auxEv = "<a>"
nodeName = this.nodeImageSrc()
if (this.level>0)
if (this.isLastNode) //the last child in the children array
leftSide = leftSide + "<td valign=top>" + auxEv + "<img name='nodeIcon" + this.id + "' id='nodeIcon" + this.id + "' src='" + nodeName + "' width=16 height=22 border=0></a></td>"
else
leftSide = leftSide + "<td valign=top background=" + ICONPATH + "ftv2vertline.gif>" + auxEv + "<img name='nodeIcon" + this.id + "' id='nodeIcon" + this.id + "' src='" + nodeName + "' width=16 height=22 border=0></a></td>"
this.isRendered = 1
if (browserVersion == 2) {
if (!doc.yPos)
doc.yPos=20
}
docW = this.blockStartHTML("folder");
docW = docW + "<tr>" + leftSide + "<td valign=top>";
if (USEICONS)
{
docW = docW + this.linkHTML(false)
docW = docW + "<img id='folderIcon" + this.id + "' name='folderIcon" + this.id + "' src='" + this.iconImageSrc() + "' border=0></a>"
}
else
{
if (this.prependHTML == "")
docW = docW + "<img src=" + ICONPATH + "ftv2blank.gif height=2 width=2>"
}
if (WRAPTEXT)
docW = docW + "</td>"+this.prependHTML+"<td valign=middle width=100%>"
else
docW = docW + "</td>"+this.prependHTML+"<td valign=middle nowrap width=100%>"
if (USETEXTLINKS)
{
docW = docW + this.linkHTML(true)
docW = docW + this.desc + "</a>"
}
else
docW = docW + this.desc
docW = docW + "</td>"
docW = docW + this.blockEndHTML()
if (insertAtObj == null)
{
if (supportsDeferral) {
doc.write("<div id=domRoot></div>") //transition between regular flow HTML, and node-insert DOM DHTML
insertAtObj = getElById("domRoot")
insertAtObj.insertAdjacentHTML("beforeEnd", docW)
}
else
doc.write(docW)
}
else
{
insertAtObj.insertAdjacentHTML("afterEnd", docW)
}
if (browserVersion == 2)
{
this.navObj = doc.layers["folder"+this.id]
if (USEICONS)
this.iconImg = this.navObj.document.images["folderIcon"+this.id]
this.nodeImg = this.navObj.document.images["nodeIcon"+this.id]
doc.yPos=doc.yPos+this.navObj.clip.height
}
else if (browserVersion != 0)
{
this.navObj = getElById("folder"+this.id)
if (USEICONS)
this.iconImg = getElById("folderIcon"+this.id)
this.nodeImg = getElById("nodeIcon"+this.id)
}
}
function setStateFolder(isOpen)
{
var subEntries
var totalHeight
var fIt = 0
var i=0
var currentOpen
if (isOpen == this.isOpen)
return
if (browserVersion == 2)
{
totalHeight = 0
for (i=0; i < this.nChildren; i++)
totalHeight = totalHeight + this.children[i].navObj.clip.height
subEntries = this.subEntries()
if (this.isOpen)
totalHeight = 0 - totalHeight
for (fIt = this.id + subEntries + 1; fIt < nEntries; fIt++)
indexOfEntries[fIt].navObj.moveBy(0, totalHeight)
}
this.isOpen = isOpen;
if (this.getID()!=foldersTree.getID() && PRESERVESTATE && !this.isOpen) //closing
{
currentOpen = GetCookie("clickedFolder")
if (currentOpen != null) {
currentOpen = currentOpen.replace(this.getID()+cookieCutter, "")
SetCookie("clickedFolder", currentOpen)
}
}
if (!this.isOpen && this.isLastOpenedfolder)
{
lastOpenedFolder = null;
this.isLastOpenedfolder = false;
}
propagateChangesInState(this)
}
function propagateChangesInState(folder)
{
var i=0
//Change icon
if (folder.nChildren > 0 && folder.level>0) //otherwise the one given at render stays
folder.nodeImg.src = folder.nodeImageSrc()
//Change node
if (USEICONS)
folder.iconImg.src = folder.iconImageSrc()
//Propagate changes
for (i=folder.nChildren-1; i>=0; i--) {
if (folder.isOpen)
folder.children[i].folderMstr(folder.navObj)
else
folder.children[i].esconde()
}
}
function escondeFolder()
{
this.escondeBlock()
this.setState(0)
}
function linkFolderHTML(isTextLink)
{
var docW = "";
if (this.hreference)
{
if (USEFRAMES)
docW = docW + "<a href='" + this.hreference + "' TARGET=\"basefrm\" "
else
docW = docW + "<a href='" + this.hreference + "' TARGET=_top "
if (isTextLink) {
docW += "id=\"itemTextLink"+this.id+"\" ";
}
if (browserVersion > 0)
docW = docW + "onClick='javascript:clickOnFolder(\""+this.getID()+"\")'"
docW = docW + ">"
}
else
docW = docW + "<a>"
return docW;
}
function addChild(childNode)
{
this.children[this.nChildren] = childNode
childNode.parentObj = this
this.nChildren++
return childNode
}
//The list can contain either a Folder object or a sub list with the arguments for Item
function addChildren(listOfChildren)
{
this.children = listOfChildren
this.nChildren = listOfChildren.length
for (i=0; i<this.nChildren; i++)
this.children[i].parentObj = this
}
function folderSubEntries()
{
var i = 0
var se = this.nChildren
for (i=0; i < this.nChildren; i++){
if (this.children[i].children) //is a folder
se = se + this.children[i].subEntries()
}
return se
}
function nodeImageSrc() {
var srcStr = "";
if (this.isLastNode) //the last child in the children array
{
if (this.nChildren == 0)
srcStr = ICONPATH + "ftv2lastnode.gif"
else
if (this.isOpen)
srcStr = ICONPATH + "ftv2mlastnode.gif"
else
srcStr = ICONPATH + "ftv2plastnode.gif"
}
else
{
if (this.nChildren == 0)
srcStr = ICONPATH + "ftv2node.gif"
else
if (this.isOpen)
srcStr = ICONPATH + "ftv2mnode.gif"
else
srcStr = ICONPATH + "ftv2pnode.gif"
}
return srcStr;
}
function iconImageSrc() {
if (this.isOpen)
return(this.iconSrc)
else
return(this.iconSrcClosed)
}
// Definition of class Item (a document or link inside a Folder)
// *************************************************************
function Item(itemDescription) // Constructor
{
// constant data
this.desc = itemDescription
this.level = 0
this.isLastNode = false
this.leftSideCoded = ""
this.parentObj = null
this.maySelect=true
this.initialize = initializeItem;
this.createIndex = createEntryIndex;
this.forceOpeningOfAncestorFolders = forceOpeningOfAncestorFolders;
finalizeCreationOfItem(this)
}
//Assignments that can be delayed when the item is created with folder.addChildren
//The assignments that cannot be delayed are done in addChildren and in initializeFolder
//Additionaly, some assignments are also done in finalizeCreationOfChildDocs itself
function finalizeCreationOfItem(itemArray)
{
itemArray.navObj = 0 //initialized in render()
itemArray.iconImg = 0 //initialized in render()
itemArray.iconSrc = ICONPATH + "ftv2doc.gif"
itemArray.isRendered = 0
itemArray.nChildren = 0
itemArray.prependHTML = ""
// methods
itemArray.escondeBlock = escondeBlock
itemArray.esconde = escondeBlock
itemArray.folderMstr = folderMstr
itemArray.renderOb = drawItem
itemArray.totalHeight = totalHeight
itemArray.blockStartHTML = blockStartHTML
itemArray.blockEndHTML = blockEndHTML
itemArray.getID = getID
}
function initializeItem(level, lastNode, leftSide)
{
this.createIndex()
this.level = level
this.leftSideCoded = leftSide
this.isLastNode = lastNode
}
function drawItem(insertAtObj)
{
var leftSide = leftSideHTML(this.leftSideCoded)
var docW = ""
var fullLink = "href=\""+this.link+"\" target=\""+this.target+"\" onClick=\"clickOnLink('"+this.getID()+"\', '"+this.link+"','"+this.target+"');return false;\"";
this.isRendered = 1
if (this.level>0)
if (this.isLastNode) //the last 'brother' in the children array
{
leftSide = leftSide + "<td valign=top><img src='" + ICONPATH + "ftv2lastnode.gif' width=16 height=22></td>"
}
else
{
leftSide = leftSide + "<td valign=top background=" + ICONPATH + "ftv2vertline.gif><img src='" + ICONPATH + "ftv2node.gif' width=16 height=22></td>"
}
docW = docW + this.blockStartHTML("item")
docW = docW + "<tr>" + leftSide + "<td valign=top>"
if (USEICONS)
docW = docW + "<a " + fullLink + " id=\"itemIconLink"+this.id+"\">" + "<img id='itemIcon"+this.id+"' " + "src='"+this.iconSrc+"' border=0>" + "</a>"
else
if (this.prependHTML == "")
docW = docW + "<img src=" + ICONPATH + "ftv2blank.gif height=2 width=3>"
if (WRAPTEXT)
docW = docW + "</td>"+this.prependHTML+"<td valign=middle width=100%>"
else
docW = docW + "</td>"+this.prependHTML+"<td valign=middle nowrap width=100%>"
if (USETEXTLINKS)
docW = docW + "<a " + fullLink + " id=\"itemTextLink"+this.id+"\">" + this.desc + "</a>"
else
docW = docW + this.desc
docW = docW + "</td>"
docW = docW + this.blockEndHTML()
if (insertAtObj == null)
{
doc.write(docW)
}
else
{
insertAtObj.insertAdjacentHTML("afterEnd", docW)
}
if (browserVersion == 2) {
this.navObj = doc.layers["item"+this.id]
if (USEICONS)
this.iconImg = this.navObj.document.images["itemIcon"+this.id]
doc.yPos=doc.yPos+this.navObj.clip.height
} else if (browserVersion != 0) {
this.navObj = getElById("item"+this.id)
if (USEICONS)
this.iconImg = getElById("itemIcon"+this.id)
}
}
// Methods common to both objects (pseudo-inheritance)
// ********************************************************
function forceOpeningOfAncestorFolders() {
if (this.parentObj == null || this.parentObj.isOpen)
return
else {
this.parentObj.forceOpeningOfAncestorFolders()
clickOnNodeObj(this.parentObj)
}
}
function escondeBlock()
{
if (browserVersion == 1 || browserVersion == 3) {
if (this.navObj.style.display == "none")
return
this.navObj.style.display = "none"
} else {
if (this.navObj.visibility == "hidden")
return
this.navObj.visibility = "hidden"
}
}
function folderMstr(domObj)
{
if (browserVersion == 1 || browserVersion == 3) {
if (t==-1)
return
var str = new String(doc.links[t])
if (str.slice(14,16) != "em")
return
}
if (!this.isRendered)
this.renderOb(domObj)
else
if (browserVersion == 1 || browserVersion == 3)
this.navObj.style.display = "block"
else
this.navObj.visibility = "show"
}
function blockStartHTML(idprefix) {
var idParam = "id='" + idprefix + this.id + "'"
var docW = ""
if (browserVersion == 2)
docW = "<layer "+ idParam + " top=" + doc.yPos + " visibility=show>"
else if (browserVersion != 0)
docW = "<div " + idParam + " style='display:block;'>"
docW = docW + "<table border=0 cellspacing=0 cellpadding=0 width=100% >"
return docW
}
function blockEndHTML() {
var docW = ""
docW = "</table>"
if (browserVersion == 2)
docW = docW + "</layer>"
else if (browserVersion != 0)
docW = docW + "</div>"
return docW
}
function createEntryIndex()
{
this.id = nEntries
indexOfEntries[nEntries] = this
nEntries++
}
// total height of subEntries open
function totalHeight() //used with browserVersion == 2
{
var h = this.navObj.clip.height
var i = 0
if (this.isOpen) //is a folder and _is_ open
for (i=0 ; i < this.nChildren; i++)
h = h + this.children[i].totalHeight()
return h
}
function leftSideHTML(leftSideCoded) {
var i;
var retStr = "";
for (i=0; i<leftSideCoded.length; i++)
{
if (leftSideCoded.charAt(i) == "1")
{
retStr = retStr + "<td valign=top background=" + ICONPATH + "ftv2vertline.gif><img src='" + ICONPATH + "ftv2vertline.gif' width=16 height=22></td>"
}
if (leftSideCoded.charAt(i) == "0")
{
retStr = retStr + "<td valign=top><img src='" + ICONPATH + "ftv2blank.gif' width=16 height=22></td>"
}
}
return retStr
}
function getID()
{
//define a .xID in all nodes (folders and items) if you want to PERVESTATE that
//work when the tree changes. The value eXternal value must be unique for each
//node and must node change when other nodes are added or removed
//The value may be numeric or string, but cannot have the same char used in cookieCutter
if (typeof this.xID != "undefined")
return this.xID
else
return this.id
}
// Events
// *********************************************************
function clickOnFolder(folderId)
{
var clicked = findObj(folderId)
if (typeof clicked=='undefined' || clicked==null)
{
alert("Treeview was not able to find the node object corresponding to ID=" + folderId + ". If the configuration file sets a.xID values, it must set them for ALL nodes, including the foldersTree root.")
return;
}
if (!clicked.isOpen) {
clickOnNodeObj(clicked)
}
if (lastOpenedFolder != null && lastOpenedFolder != folderId)
clickOnNode(lastOpenedFolder); //sets lastOpenedFolder to null
if (clicked.nChildren==0) {
lastOpenedFolder = folderId;
clicked.isLastOpenedfolder = true
}
if (isLinked(clicked.hreference)) {
highlightObjLink(clicked);
}
}
function clickOnNode(folderId)
{
fOb = findObj(folderId);
if (typeof fOb=='undefined' || fOb==null)
{
alert("Treeview was not able to find the node object corresponding to ID=" + folderId + ". If the configuration file sets a.xID, it must set foldersTree.xID as well.")
return;
}
clickOnNodeObj(fOb);
}
function clickOnNodeObj(folderObj)
{
var state = 0
var currentOpen
state = folderObj.isOpen
folderObj.setState(!state) //open<->close
if (folderObj.id!=foldersTree.id && PRESERVESTATE)
{
currentOpen = GetCookie("clickedFolder")
if (currentOpen == null)
currentOpen = ""
if (!folderObj.isOpen) //closing
{
currentOpen = currentOpen.replace(folderObj.getID()+cookieCutter, "")
SetCookie("clickedFolder", currentOpen)
}
else
SetCookie("clickedFolder", currentOpen+folderObj.getID()+cookieCutter)
}
}
function clickOnLink(clickedId, target, windowName) {
highlightObjLink(findObj(clickedId));
if (isLinked(target)) {
window.open(target,windowName);
}
}
function ld ()
{
return document.links.length-1
}
// Auxiliary Functions
// *******************
function finalizeCreationOfChildDocs(folderObj) {
for(i=0; i < folderObj.nChildren; i++) {
child = folderObj.children[i]
if (typeof child[0] != 'undefined')
{
// Amazingly, arrays can have members, so a = ["a", "b"]; a.desc="asdas" works
// If a doc was inserted as an array, we can transform it into an itemObj by adding
// the missing members and functions
child.desc = child[0]
setItemLink(child, GLOBALTARGET, child[1])
finalizeCreationOfItem(child)
}
}
}
function findObj(id)
{
var i=0;
var nodeObj;
if (typeof foldersTree.xID != "undefined") {
nodeObj = indexOfEntries[i];
for(i=0;i<nEntries&&indexOfEntries[i].xID!=id;i++) //may need optimization
;
id = i
}
if (id >= nEntries)
return null; //example: node removed in DB
else
return indexOfEntries[id];
}
function isLinked(hrefText) {
var result = true;
result = (result && hrefText !=null);
result = (result && hrefText != '');
result = (result && hrefText.indexOf('undefined') < 0);
result = (result && hrefText.indexOf('parent.op') < 0);
return result;
}
// Do highlighting by changing background and foreg. colors of folder or doc text
function highlightObjLink(nodeObj) {
if (!HIGHLIGHT || nodeObj==null || nodeObj.maySelect==false) {//node deleted in DB
return;
}
if (browserVersion == 1 || browserVersion == 3) {
var clickedDOMObj = getElById('itemTextLink'+nodeObj.id);
if (clickedDOMObj != null) {
if (lastClicked != null) {
var prevClickedDOMObj = getElById('itemTextLink'+lastClicked.id);
prevClickedDOMObj.style.color=lastClickedColor;
prevClickedDOMObj.style.backgroundColor=lastClickedBgColor;
}
lastClickedColor = clickedDOMObj.style.color;
lastClickedBgColor = clickedDOMObj.style.backgroundColor;
clickedDOMObj.style.color=HIGHLIGHT_COLOR;
clickedDOMObj.style.backgroundColor=HIGHLIGHT_BG;
}
}
lastClicked = nodeObj;
if (PRESERVESTATE)
SetCookie('highlightedTreeviewLink', nodeObj.getID());
}
function insFld(parentFolder, childFolder)
{
return parentFolder.addChild(childFolder)
}
function insDoc(parentFolder, document)
{
return parentFolder.addChild(document)
}
function gFld(description, hreference)
{
folder = new Folder(description, hreference);
return folder;
}
function gLnk(optionFlags, description, linkData)
{
if (optionFlags>=0) { //is numeric (old style) or empty (error)
//Target changed from numeric to string in Aug 2002, and support for numeric style was entirely dropped in Mar 2004
alert("Change your Treeview configuration file to use the new style of target argument in gLnk");
return;
}
newItem = new Item(description);
setItemLink(newItem, optionFlags, linkData);
return newItem;
}
function setItemLink(item, optionFlags, linkData) {
var targetFlag = "";
var target = "";
var protocolFlag = "";
var protocol = "";
targetFlag = optionFlags.charAt(0)
if (targetFlag=="B")
target = "_blank"
if (targetFlag=="P")
target = "_parent"
if (targetFlag=="R")
target = "basefrm"
if (targetFlag=="S")
target = "_self"
if (targetFlag=="T")
target = "_top"
if (optionFlags.length > 1) {
protocolFlag = optionFlags.charAt(1)
if (protocolFlag=="h")
protocol = "http://"
if (protocolFlag=="s")
protocol = "https://"
if (protocolFlag=="f")
protocol = "ftp://"
if (protocolFlag=="m")
protocol = "mailto:"
}
item.link = protocol+linkData;
item.target = target
}
//Function created for backwards compatibility purposes
//Function contents voided in March 2004
function oldGLnk(target, description, linkData)
{
}
function preLoadIcons() {
arImageSrc = new Array (
"ftv2vertline.gif",
"ftv2mlastnode.gif",
"ftv2mnode.gif",
"ftv2plastnode.gif",
"ftv2pnode.gif",
"ftv2blank.gif",
"ftv2lastnode.gif",
"ftv2node.gif",
"ftv2folderclosed.gif",
"ftv2folderopen.gif",
"ftv2doc.gif"
)
arImageList = new Array ();
for (counter in arImageSrc) {
arImageList[counter] = new Image();
arImageList[counter].src = ICONPATH + arImageSrc[counter];
}
}
//Open some folders for initial layout, if necessary
function setInitialLayout() {
if (browserVersion > 0 && !STARTALLOPEN)
clickOnNodeObj(foldersTree);
if (!STARTALLOPEN && (browserVersion > 0) && PRESERVESTATE)
PersistentFolderOpening();
}
//Used with NS4 and STARTALLOPEN
function renderAllTree(nodeObj, parent) {
var i=0;
nodeObj.renderOb(parent)
if (supportsDeferral)
for (i=nodeObj.nChildren-1; i>=0; i--)
renderAllTree(nodeObj.children[i], nodeObj.navObj)
else
for (i=0 ; i < nodeObj.nChildren; i++)
renderAllTree(nodeObj.children[i], null)
}
function hideWholeTree(nodeObj, hideThisOne, nodeObjMove) {
var i=0;
var heightContained=0;
var childrenMove=nodeObjMove;
if (hideThisOne)
nodeObj.escondeBlock()
if (browserVersion == 2)
nodeObj.navObj.moveBy(0, 0-nodeObjMove)
for (i=0 ; i < nodeObj.nChildren; i++) {
heightContainedInChild = hideWholeTree(nodeObj.children[i], true, childrenMove)
if (browserVersion == 2) {
heightContained = heightContained + heightContainedInChild + nodeObj.children[i].navObj.clip.height
childrenMove = childrenMove + heightContainedInChild
}
}
return heightContained;
}
// Simulating inserAdjacentHTML on NS6
// Code by thor@jscript.dk
// ******************************************
if(typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement){
HTMLElement.prototype.insertAdjacentElement = function (where,parsedNode)
{
switch (where){
case 'beforeBegin':
this.parentNode.insertBefore(parsedNode,this)
break;
case 'afterBegin':
this.insertBefore(parsedNode,this.firstChild);
break;
case 'beforeEnd':
this.appendChild(parsedNode);
break;
case 'afterEnd':
if (this.nextSibling)
this.parentNode.insertBefore(parsedNode,this.nextSibling);
else this.parentNode.appendChild(parsedNode);
break;
}
}
HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr)
{
var r = this.ownerDocument.createRange();
r.setStartBefore(this);
var parsedHTML = r.createContextualFragment(htmlStr);
this.insertAdjacentElement(where,parsedHTML)
}
}
function getElById(idVal) {
if (document.getElementById != null)
return document.getElementById(idVal)
if (document.all != null)
return document.all[idVal]
alert("Problem getting element by id")
return null
}
// Functions for cookies
// Note: THESE FUNCTIONS ARE OPTIONAL. No cookies are used unless
// the PRESERVESTATE variable is set to 1 (default 0)
// The separator currently in use is ^ (chr 94)
// ***********************************************************
function PersistentFolderOpening()
{
var stateInCookie;
var fldStr=""
var fldArr
var fldPos=0
var id
var nodeObj
stateInCookie = GetCookie("clickedFolder");
SetCookie('clickedFolder', "") //at the end of function it will be back, minus null cases
if(stateInCookie!=null)
{
fldArr = stateInCookie.split(cookieCutter)
for (fldPos=0; fldPos<fldArr.length; fldPos++)
{
fldStr=fldArr[fldPos]
if (fldStr != "") {
nodeObj = findObj(fldStr)
if (nodeObj!=null) //may have been deleted
if (nodeObj.setState) {
nodeObj.forceOpeningOfAncestorFolders()
clickOnNodeObj(nodeObj);
}
else
alert("Internal id is not pointing to a folder anymore.\nConsider giving an ID to the tree and external IDs to the individual nodes.")
}
}
}
}
function storeAllNodesInClickCookie(treeNodeObj)
{
var currentOpen
var i = 0
if (typeof treeNodeObj.setState != "undefined") //is folder
{
currentOpen = GetCookie("clickedFolder")
if (currentOpen == null)
currentOpen = ""