Hei_treemenu.js 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141
  1. //****************************************************************
  2. // Keep this copyright notice:
  3. // This copy of the script is the property of the owner of the
  4. // particular web site you were visiting.
  5. // Do not download the script's files from there.
  6. // For a free download and full instructions go to:
  7. // http://www.treeview.net
  8. //****************************************************************
  9. // Log of changes:
  10. //
  11. // 12 May 03 - Support for Safari Beta 3
  12. // 01 Mar 03 - VERSION 4.3 - Support for checkboxes
  13. // 21 Feb 03 - Added support for Opera 7
  14. // 22 Sep 02 - Added maySelect member for node-by-node control
  15. // of selection and highlight
  16. // 21 Sep 02 - Cookie values are now separated by cookieCutter
  17. // 12 Sep 02 - VERSION 4.2 - Can highlight Selected Nodes and
  18. // can preserve state through external (DB) IDs
  19. // 29 Aug 02 - Fine tune 'supportDeferral' for IE4 and IE Mac
  20. // 25 Aug 02 - Fixes: STARTALLOPEN, and multi-page frameless
  21. // 09 Aug 02 - Fix repeated folder on Mozilla 1.x
  22. // 31 Jul 02 - VERSION 4.1 - Dramatic speed increase for trees
  23. // with hundreds or thousands of nodes; changes to the control
  24. // flags of the gLnk function
  25. // 18 Jul 02 - Changes in pre-load images function
  26. // 13 Jun 02 - Add ICONPATH var to allow for gif subdir
  27. // 20 Apr 02 - Improve support for frame-less layout
  28. // 07 Apr 02 - Minor changes to support server-side dynamic feeding
  29. // (example: FavoritesManagerASP)
  30. // Definition of class Folder
  31. // *****************************************************************
  32. function Folder(folderDescription, hreference) //constructor
  33. {
  34. //constant data
  35. this.desc = folderDescription;
  36. this.hreference = hreference;
  37. this.id = -1;
  38. this.navObj = 0;
  39. this.iconImg = 0;
  40. this.nodeImg = 0;
  41. this.isLastNode = 0;
  42. this.iconSrc = ICONPATH + "ftv2folderopen.gif";
  43. this.iconSrcClosed = ICONPATH + "ftv2folderclosed.gif";
  44. this.children = new Array;
  45. this.nChildren = 0;
  46. this.level = 0;
  47. this.leftSideCoded = "";
  48. this.isLastNode=false;
  49. this.parentObj = null;
  50. this.maySelect=true;
  51. this.prependHTML = ""
  52. //dynamic data
  53. this.isOpen = false
  54. this.isLastOpenedFolder = false
  55. this.isRendered = 0
  56. //methods
  57. this.initialize = initializeFolder
  58. this.setState = setStateFolder
  59. this.addChild = addChild
  60. this.createIndex = createEntryIndex
  61. this.escondeBlock = escondeBlock
  62. this.esconde = escondeFolder
  63. this.folderMstr = folderMstr
  64. this.renderOb = drawFolder
  65. this.totalHeight = totalHeight
  66. this.subEntries = folderSubEntries
  67. this.linkHTML = linkFolderHTML
  68. this.blockStartHTML = blockStartHTML
  69. this.blockEndHTML = blockEndHTML
  70. this.nodeImageSrc = nodeImageSrc
  71. this.iconImageSrc = iconImageSrc
  72. this.getID = getID
  73. this.forceOpeningOfAncestorFolders = forceOpeningOfAncestorFolders
  74. }
  75. function initializeFolder(level, lastNode, leftSide)
  76. {
  77. var j=0
  78. var i=0
  79. nc = this.nChildren
  80. this.createIndex()
  81. this.level = level
  82. this.leftSideCoded = leftSide
  83. if (browserVersion == 0 || STARTALLOPEN==1)
  84. this.isOpen=true;
  85. if (level>0)
  86. if (lastNode) //the last child in the children array
  87. leftSide = leftSide + "0"
  88. else
  89. leftSide = leftSide + "1"
  90. this.isLastNode = lastNode
  91. if (nc > 0)
  92. {
  93. level = level + 1
  94. for (i=0 ; i < this.nChildren; i++)
  95. {
  96. if (i == this.nChildren-1)
  97. this.children[i].initialize(level, 1, leftSide)
  98. else
  99. this.children[i].initialize(level, 0, leftSide)
  100. }
  101. }
  102. }
  103. function drawFolder(insertAtObj)
  104. {
  105. var nodeName = ""
  106. var auxEv = ""
  107. var docW = ""
  108. var leftSide = leftSideHTML(this.leftSideCoded)
  109. if (browserVersion > 0)
  110. auxEv = "<a href='javascript:clickOnNode(\""+this.getID()+"\")'>"
  111. else
  112. auxEv = "<a>"
  113. nodeName = this.nodeImageSrc()
  114. if (this.level>0)
  115. if (this.isLastNode) //the last child in the children array
  116. 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>"
  117. else
  118. 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>"
  119. this.isRendered = 1
  120. if (browserVersion == 2) {
  121. if (!doc.yPos)
  122. doc.yPos=20
  123. }
  124. docW = this.blockStartHTML("folder");
  125. docW = docW + "<tr>" + leftSide + "<td valign=top>";
  126. if (USEICONS)
  127. {
  128. docW = docW + this.linkHTML(false)
  129. docW = docW + "<img id='folderIcon" + this.id + "' name='folderIcon" + this.id + "' src='" + this.iconImageSrc() + "' border=0></a>"
  130. }
  131. else
  132. {
  133. if (this.prependHTML == "")
  134. docW = docW + "<img src=" + ICONPATH + "ftv2blank.gif height=2 width=2>"
  135. }
  136. if (WRAPTEXT)
  137. docW = docW + "</td>"+this.prependHTML+"<td valign=middle width=100%>"
  138. else
  139. docW = docW + "</td>"+this.prependHTML+"<td valign=middle nowrap width=100%>"
  140. if (USETEXTLINKS)
  141. {
  142. docW = docW + this.linkHTML(true)
  143. docW = docW + this.desc + "</a>"
  144. }
  145. else
  146. docW = docW + this.desc
  147. docW = docW + "</td>"
  148. docW = docW + this.blockEndHTML()
  149. if (insertAtObj == null)
  150. {
  151. if (supportsDeferral) {
  152. doc.write("<div id=domRoot></div>") //transition between regular flow HTML, and node-insert DOM DHTML
  153. insertAtObj = getElById("domRoot")
  154. insertAtObj.insertAdjacentHTML("beforeEnd", docW)
  155. }
  156. else
  157. doc.write(docW)
  158. }
  159. else
  160. {
  161. insertAtObj.insertAdjacentHTML("afterEnd", docW)
  162. }
  163. if (browserVersion == 2)
  164. {
  165. this.navObj = doc.layers["folder"+this.id]
  166. if (USEICONS)
  167. this.iconImg = this.navObj.document.images["folderIcon"+this.id]
  168. this.nodeImg = this.navObj.document.images["nodeIcon"+this.id]
  169. doc.yPos=doc.yPos+this.navObj.clip.height
  170. }
  171. else if (browserVersion != 0)
  172. {
  173. this.navObj = getElById("folder"+this.id)
  174. if (USEICONS)
  175. this.iconImg = getElById("folderIcon"+this.id)
  176. this.nodeImg = getElById("nodeIcon"+this.id)
  177. }
  178. }
  179. function setStateFolder(isOpen)
  180. {
  181. var subEntries
  182. var totalHeight
  183. var fIt = 0
  184. var i=0
  185. var currentOpen
  186. if (isOpen == this.isOpen)
  187. return
  188. if (browserVersion == 2)
  189. {
  190. totalHeight = 0
  191. for (i=0; i < this.nChildren; i++)
  192. totalHeight = totalHeight + this.children[i].navObj.clip.height
  193. subEntries = this.subEntries()
  194. if (this.isOpen)
  195. totalHeight = 0 - totalHeight
  196. for (fIt = this.id + subEntries + 1; fIt < nEntries; fIt++)
  197. indexOfEntries[fIt].navObj.moveBy(0, totalHeight)
  198. }
  199. this.isOpen = isOpen;
  200. if (this.getID()!=root.getID() && PERSERVESTATE && !this.isOpen) //closing
  201. {
  202. currentOpen = GetCookie("clickedFolder")
  203. if (currentOpen != null) {
  204. currentOpen = currentOpen.replace(this.getID()+cookieCutter, "")
  205. SetCookie("clickedFolder", currentOpen)
  206. }
  207. }
  208. if (!this.isOpen && this.isLastOpenedfolder)
  209. {
  210. lastOpenedFolder = null;
  211. this.isLastOpenedfolder = false;
  212. }
  213. propagateChangesInState(this)
  214. }
  215. function propagateChangesInState(folder)
  216. {
  217. var i=0
  218. //Change icon
  219. if (folder.nChildren > 0 && folder.level>0) //otherwise the one given at render stays
  220. folder.nodeImg.src = folder.nodeImageSrc()
  221. //Change node
  222. if (USEICONS)
  223. folder.iconImg.src = folder.iconImageSrc()
  224. //Propagate changes
  225. for (i=folder.nChildren-1; i>=0; i--)
  226. if (folder.isOpen)
  227. folder.children[i].folderMstr(folder.navObj)
  228. else
  229. folder.children[i].esconde()
  230. }
  231. function escondeFolder()
  232. {
  233. this.escondeBlock()
  234. this.setState(0)
  235. }
  236. function linkFolderHTML(isTextLink) {
  237. var docW = "";
  238. if (this.hreference) {
  239. if( this.hreference != "RFQ" ) {
  240. //alert(this.hreference +" : "+this.hreference.indexOf("PUREstimateItemList.jsp"));
  241. if (USEFRAMES) { //1
  242. docW = docW + "<a href='" + this.hreference + "' target='work_list' " //main
  243. } else { //0
  244. docW = docW + "<a href='" + this.hreference + "' target='work_list' "
  245. }
  246. if (isTextLink) {
  247. docW += "id=\"itemTextLink"+this.id+"\" ";
  248. }
  249. if (browserVersion > 0)
  250. docW = docW + "onClick='javascript:clickOnFolder(\""+this.getID()+"\")'"
  251. docW = docW + ">"
  252. }
  253. else {
  254. //견적서 작성제출시 트리구조 구분자 없을땐 스크립터 호출
  255. //alert(this.hreference +" : "+this.hreference.indexOf("PUREstimateItemList.jsp"));
  256. if (this.getID() > 0) {
  257. docW = docW + "<a href='javascript:clickOnNode(\""+this.getID()+"\")' "
  258. if (isTextLink) {
  259. docW += "id=\"itemTextLink"+this.id+"\" ";
  260. }
  261. docW = docW + ">"
  262. }
  263. }
  264. } else {
  265. docW = docW + "<a>"
  266. }
  267. return docW;
  268. }
  269. function addChild(childNode)
  270. {
  271. this.children[this.nChildren] = childNode
  272. childNode.parentObj = this
  273. this.nChildren++
  274. return childNode
  275. }
  276. function folderSubEntries()
  277. {
  278. var i = 0
  279. var se = this.nChildren
  280. for (i=0; i < this.nChildren; i++){
  281. if (this.children[i].children) //is a folder
  282. se = se + this.children[i].subEntries()
  283. }
  284. return se
  285. }
  286. function nodeImageSrc() {
  287. var srcStr = "";
  288. if (this.isLastNode) //the last child in the children array
  289. {
  290. if (this.nChildren == 0)
  291. srcStr = ICONPATH + "ftv2lastnode.gif"
  292. else
  293. if (this.isOpen)
  294. srcStr = ICONPATH + "ftv2mlastnode.gif"
  295. else
  296. srcStr = ICONPATH + "ftv2plastnode.gif"
  297. }
  298. else
  299. {
  300. if (this.nChildren == 0)
  301. srcStr = ICONPATH + "ftv2node.gif"
  302. else
  303. if (this.isOpen)
  304. srcStr = ICONPATH + "ftv2mnode.gif"
  305. else
  306. srcStr = ICONPATH + "ftv2pnode.gif"
  307. }
  308. return srcStr;
  309. }
  310. function iconImageSrc() {
  311. if (this.isOpen)
  312. return(this.iconSrc)
  313. else
  314. return(this.iconSrcClosed)
  315. }
  316. // Definition of class Item (a document or link inside a Folder)
  317. // *************************************************************
  318. function Item(itemDescription, itemLink, target) // Constructor
  319. {
  320. // constant data
  321. this.desc = itemDescription
  322. this.link = itemLink
  323. this.id = -1 //initialized in initalize()
  324. this.navObj = 0 //initialized in render()
  325. this.iconImg = 0 //initialized in render()
  326. //this.iconSrc = ICONPATH + "ftv2doc.gif"
  327. this.iconSrc = ICONPATH + "ftv2folderclosed.gif"
  328. this.isRendered = 0
  329. this.isLastNode = false
  330. this.level = 0
  331. this.leftSideCoded = ""
  332. this.nChildren = 0
  333. this.target = target
  334. this.parentObj = null
  335. this.maySelect=true
  336. this.prependHTML = ""
  337. // methods
  338. this.initialize = initializeItem
  339. this.createIndex = createEntryIndex
  340. this.escondeBlock = escondeBlock
  341. this.esconde = escondeBlock
  342. this.folderMstr = folderMstr
  343. this.renderOb = drawItem
  344. this.totalHeight = totalHeight
  345. this.blockStartHTML = blockStartHTML
  346. this.blockEndHTML = blockEndHTML
  347. this.getID = getID
  348. this.forceOpeningOfAncestorFolders = forceOpeningOfAncestorFolders
  349. }
  350. function initializeItem(level, lastNode, leftSide)
  351. {
  352. this.createIndex()
  353. this.level = level
  354. this.leftSideCoded = leftSide
  355. this.isLastNode = lastNode
  356. }
  357. function drawItem(insertAtObj)
  358. {
  359. var leftSide = leftSideHTML(this.leftSideCoded)
  360. var docW = ""
  361. var fullLink = "href=\""+this.link+"\" target=\""+this.target+"\" onClick=\"clickOnLink('"+this.getID()+"\', '"+this.link+"','"+this.target+"');return false;\"";
  362. this.isRendered = 1
  363. if (this.level>0)
  364. if (this.isLastNode) //the last 'brother' in the children array
  365. {
  366. leftSide = leftSide + "<td valign=top><img src='" + ICONPATH + "ftv2lastnode.gif' width=16 height=22></td>"
  367. }
  368. else
  369. {
  370. leftSide = leftSide + "<td valign=top background=" + ICONPATH + "ftv2vertline.gif><img src='" + ICONPATH + "ftv2node.gif' width=16 height=22></td>"
  371. }
  372. docW = docW + this.blockStartHTML("item")
  373. docW = docW + "<tr>" + leftSide + "<td valign=top>"
  374. if (USEICONS)
  375. docW = docW + "<a " + fullLink + " id=\"itemIconLink"+this.id+"\">" + "<img id='itemIcon"+this.id+"' " + "src='"+this.iconSrc+"' border=0>" + "</a>"
  376. else
  377. if (this.prependHTML == "")
  378. docW = docW + "<img src=" + ICONPATH + "ftv2blank.gif height=2 width=3>"
  379. if (WRAPTEXT)
  380. docW = docW + "</td>"+this.prependHTML+"<td valign=middle width=100%>"
  381. else
  382. docW = docW + "</td>"+this.prependHTML+"<td valign=middle nowrap width=100%>"
  383. if (USETEXTLINKS)
  384. docW = docW + "<a " + fullLink + " id=\"itemTextLink"+this.id+"\">" + this.desc + "</a>"
  385. else
  386. docW = docW + this.desc
  387. docW = docW + "</td>"
  388. docW = docW + this.blockEndHTML()
  389. if (insertAtObj == null)
  390. {
  391. doc.write(docW)
  392. }
  393. else
  394. {
  395. insertAtObj.insertAdjacentHTML("afterEnd", docW)
  396. }
  397. if (browserVersion == 2) {
  398. this.navObj = doc.layers["item"+this.id]
  399. if (USEICONS)
  400. this.iconImg = this.navObj.document.images["itemIcon"+this.id]
  401. doc.yPos=doc.yPos+this.navObj.clip.height
  402. } else if (browserVersion != 0) {
  403. this.navObj = getElById("item"+this.id)
  404. if (USEICONS)
  405. this.iconImg = getElById("itemIcon"+this.id)
  406. }
  407. }
  408. // Methods common to both objects (pseudo-inheritance)
  409. // ********************************************************
  410. function forceOpeningOfAncestorFolders() {
  411. if (this.parentObj == null || this.parentObj.isOpen)
  412. return
  413. else {
  414. this.parentObj.forceOpeningOfAncestorFolders()
  415. clickOnNodeObj(this.parentObj)
  416. }
  417. }
  418. function escondeBlock()
  419. {
  420. if (browserVersion == 1 || browserVersion == 3) {
  421. if (this.navObj.style.display == "none")
  422. return
  423. this.navObj.style.display = "none"
  424. } else {
  425. if (this.navObj.visibility == "hiden")
  426. return
  427. this.navObj.visibility = "hiden"
  428. }
  429. }
  430. function folderMstr(domObj)
  431. {
  432. if (browserVersion == 1 || browserVersion == 3) {
  433. if (t==-1)
  434. return
  435. var str = new String(doc.links[t])
  436. if (str.slice(14,16) != "em")
  437. return
  438. }
  439. if (!this.isRendered)
  440. this.renderOb(domObj)
  441. else
  442. if (browserVersion == 1 || browserVersion == 3)
  443. this.navObj.style.display = "block"
  444. else
  445. this.navObj.visibility = "show"
  446. }
  447. function blockStartHTML(idprefix) {
  448. var idParam = "id='" + idprefix + this.id + "'"
  449. var docW = ""
  450. if (browserVersion == 2)
  451. docW = "<layer "+ idParam + " top=" + doc.yPos + " visibility=show>"
  452. else if (browserVersion != 0)
  453. docW = "<div " + idParam + " style='display:block; position:block;'>"
  454. docW = docW + "<table border=0 cellspacing=0 cellpadding=0 width='250'>"
  455. return docW
  456. }
  457. function blockEndHTML() {
  458. var docW = ""
  459. docW = "</table>"
  460. if (browserVersion == 2)
  461. docW = docW + "</layer>"
  462. else if (browserVersion != 0)
  463. docW = docW + "</div>"
  464. return docW
  465. }
  466. function createEntryIndex()
  467. {
  468. this.id = nEntries
  469. indexOfEntries[nEntries] = this
  470. nEntries++
  471. }
  472. // total height of subEntries open
  473. function totalHeight() //used with browserVersion == 2
  474. {
  475. var h = this.navObj.clip.height
  476. var i = 0
  477. if (this.isOpen) //is a folder and _is_ open
  478. for (i=0 ; i < this.nChildren; i++)
  479. h = h + this.children[i].totalHeight()
  480. return h
  481. }
  482. function leftSideHTML(leftSideCoded) {
  483. var i;
  484. var retStr = "";
  485. for (i=0; i<leftSideCoded.length; i++)
  486. {
  487. if (leftSideCoded.charAt(i) == "1")
  488. {
  489. retStr = retStr + "<td valign=top background=" + ICONPATH + "ftv2vertline.gif><img src='" + ICONPATH + "ftv2vertline.gif' width=16 height=22></td>"
  490. }
  491. if (leftSideCoded.charAt(i) == "0")
  492. {
  493. retStr = retStr + "<td valign=top><img src='" + ICONPATH + "ftv2blank.gif' width=16 height=22></td>"
  494. }
  495. }
  496. return retStr
  497. }
  498. function getID()
  499. {
  500. //define a .xID in all nodes (folders and items) if you want to PERVESTATE that
  501. //work when the tree changes. The value eXternal value must be unique for each
  502. //node and must node change when other nodes are added or removed
  503. //The value may be numeric or string, but cannot have the same char used in cookieCutter
  504. if (typeof this.xID != "undefined")
  505. return this.xID
  506. else
  507. return this.id
  508. }
  509. // Events
  510. // *********************************************************
  511. function clickOnFolder(folderId)
  512. {
  513. var clicked = findObj(folderId)
  514. if (!clicked.isOpen) {
  515. clickOnNodeObj(clicked)
  516. }
  517. if (lastOpenedFolder != null && lastOpenedFolder != folderId)
  518. clickOnNode(lastOpenedFolder); //sets lastOpenedFolder to null
  519. if (clicked.nChildren==0) {
  520. lastOpenedFolder = folderId;
  521. clicked.isLastOpenedfolder = true
  522. }
  523. if (isLinked(clicked.hreference)) {
  524. highlightObjLink(clicked);
  525. }
  526. }
  527. function clickOnNode(folderId)
  528. {
  529. clickOnNodeObj(findObj(folderId))
  530. }
  531. function clickOnNodeObj(folderObj)
  532. {
  533. var state = 0
  534. var currentOpen
  535. state = folderObj.isOpen
  536. folderObj.setState(!state) //open<->close
  537. if (folderObj.id!=root.id && PERSERVESTATE)
  538. {
  539. currentOpen = GetCookie("clickedFolder")
  540. if (currentOpen == null)
  541. currentOpen = ""
  542. if (!folderObj.isOpen) //closing
  543. {
  544. currentOpen = currentOpen.replace(folderObj.getID()+cookieCutter, "")
  545. SetCookie("clickedFolder", currentOpen)
  546. }
  547. else
  548. SetCookie("clickedFolder", currentOpen+folderObj.getID()+cookieCutter)
  549. }
  550. }
  551. function clickOnLink(clickedId, target, windowName) {
  552. highlightObjLink(findObj(clickedId));
  553. if (isLinked(target)) {
  554. window.open(target,windowName);
  555. }
  556. }
  557. function ld ()
  558. {
  559. return document.links.length-1
  560. }
  561. // Auxiliary Functions
  562. // *******************
  563. function findObj(id)
  564. {
  565. var i=0;
  566. var nodeObj;
  567. if (typeof root.xID != "undefined") {
  568. nodeObj = indexOfEntries[i];
  569. for(i=0;i<nEntries&&indexOfEntries[i].xID!=id;i++) //may need optimization
  570. ;
  571. id = i
  572. }
  573. if (id >= nEntries)
  574. return null; //example: node removed in DB
  575. else
  576. return indexOfEntries[id];
  577. }
  578. function isLinked(hrefText) {
  579. var result = true;
  580. result = (result && hrefText !=null);
  581. result = (result && hrefText != '');
  582. result = (result && hrefText.indexOf('undefined') < 0);
  583. result = (result && hrefText.indexOf('op') < 0);
  584. return result;
  585. }
  586. // Do highlighting by changing background and foreg. colors of folder or doc text
  587. function highlightObjLink(nodeObj) {
  588. if (!HIGHLIGHT || nodeObj==null || nodeObj.maySelect==false) {//node deleted in DB
  589. return;
  590. }
  591. if (browserVersion == 1 || browserVersion == 3) {
  592. var clickedDOMObj = getElById('itemTextLink'+nodeObj.id);
  593. if (clickedDOMObj != null) {
  594. if (lastClicked != null) {
  595. var prevClickedDOMObj = getElById('itemTextLink'+lastClicked.id);
  596. prevClickedDOMObj.style.color=lastClickedColor;
  597. prevClickedDOMObj.style.backgroundColor=lastClickedBgColor;
  598. }
  599. lastClickedColor = clickedDOMObj.style.color;
  600. lastClickedBgColor = clickedDOMObj.style.backgroundColor;
  601. clickedDOMObj.style.color=HIGHLIGHT_COLOR;
  602. clickedDOMObj.style.backgroundColor=HIGHLIGHT_BG;
  603. }
  604. }
  605. lastClicked = nodeObj;
  606. if (PERSERVESTATE)
  607. SetCookie('highlightedTreeviewLink', nodeObj.getID());
  608. }
  609. function gFld(description, hreference)
  610. {
  611. folder = new Folder(description, hreference);
  612. return folder;
  613. }
  614. function gLnk(optionFlags, description, linkData)
  615. {
  616. var fullLink = "";
  617. var targetFlag = "";
  618. var target = "";
  619. var protocolFlag = "";
  620. var protocol = "";
  621. if (optionFlags>=0) //is numeric (old style) or empty (error)
  622. {
  623. return oldGLnk(optionFlags, description, linkData)
  624. }
  625. targetFlag = optionFlags.charAt(0);
  626. if (targetFlag=="B")
  627. target = "_blank"
  628. if (targetFlag=="P")
  629. target = "_parent"
  630. if (targetFlag=="M")
  631. target = "work_list" //main
  632. if (targetFlag=="S")
  633. target = "_self"
  634. if (targetFlag=="T")
  635. target = "_top"
  636. if (optionFlags.length > 1) {
  637. protocolFlag = optionFlags.charAt(1)
  638. if (protocolFlag=="h")
  639. protocol = "http://"
  640. if (protocolFlag=="s")
  641. protocol = "https://"
  642. if (protocolFlag=="f")
  643. protocol = "ftp://"
  644. if (protocolFlag=="m")
  645. protocol = "mailto:"
  646. }
  647. fullLink = "'" + protocol + linkData + "' target=" + target
  648. linkItem = new Item(description, protocol+linkData, target)
  649. return linkItem
  650. }
  651. //Function created Aug 1, 2002 for backwards compatibility purposes
  652. function oldGLnk(target, description, linkData)
  653. {
  654. var fullLink = "";
  655. //Backwards compatibility code
  656. if (USEFRAMES)
  657. {
  658. if (target==0)
  659. {
  660. fullLink = "'"+linkData+"' target='work_list'"//main
  661. }
  662. else
  663. {
  664. if (target==1)
  665. fullLink = "'http://"+linkData+"' target='work_list'"//_blank
  666. else
  667. if (target==2)
  668. fullLink = "'http://"+linkData+"' target='work_list'"//main
  669. else
  670. fullLink = linkData+" target='work_list'"//_top
  671. }
  672. }
  673. else
  674. {
  675. if (target==0)
  676. {
  677. fullLink = "'"+linkData+"' target='work_list'"//_top
  678. }
  679. else
  680. {
  681. if (target==1)
  682. fullLink = "'http://"+linkData+"' target='work_list'" //_blank
  683. else
  684. fullLink = "'http://"+linkData+"' target='work_list'"//_top
  685. }
  686. }
  687. linkItem = new Item(description, fullLink)
  688. return linkItem
  689. }
  690. function insFld(parentFolder, childFolder)
  691. {
  692. return parentFolder.addChild(childFolder)
  693. }
  694. function insDoc(parentFolder, document)
  695. {
  696. return parentFolder.addChild(document)
  697. }
  698. function preLoadIcons() {
  699. var auxImg
  700. auxImg = new Image();
  701. auxImg.src = ICONPATH + "ftv2vertline.gif";
  702. auxImg.src = ICONPATH + "ftv2mlastnode.gif";
  703. auxImg.src = ICONPATH + "ftv2mnode.gif";
  704. auxImg.src = ICONPATH + "ftv2plastnode.gif";
  705. auxImg.src = ICONPATH + "ftv2pnode.gif";
  706. auxImg.src = ICONPATH + "ftv2blank.gif";
  707. auxImg.src = ICONPATH + "ftv2lastnode.gif";
  708. auxImg.src = ICONPATH + "ftv2node.gif";
  709. auxImg.src = ICONPATH + "ftv2folderclosed.gif";
  710. auxImg.src = ICONPATH + "ftv2folderopen.gif";
  711. auxImg.src = ICONPATH + "ftv2doc.gif";
  712. }
  713. //Open some folders for initial layout, if necessary
  714. function setInitialLayout() {
  715. if (browserVersion > 0 && !STARTALLOPEN)
  716. clickOnNodeObj(root);
  717. if (!STARTALLOPEN && (browserVersion > 0) && PERSERVESTATE)
  718. PersistentFolderOpening();
  719. }
  720. //Used with NS4 and STARTALLOPEN
  721. function renderAllTree(nodeObj, parent) {
  722. var i=0;
  723. nodeObj.renderOb(parent)
  724. if (supportsDeferral)
  725. for (i=nodeObj.nChildren-1; i>=0; i--)
  726. renderAllTree(nodeObj.children[i], nodeObj.navObj)
  727. else
  728. for (i=0 ; i < nodeObj.nChildren; i++)
  729. renderAllTree(nodeObj.children[i], null)
  730. }
  731. function hideWholeTree(nodeObj, hideThisOne, nodeObjMove) {
  732. var i=0;
  733. var heightContained=0;
  734. var childrenMove=nodeObjMove;
  735. if (hideThisOne)
  736. nodeObj.escondeBlock()
  737. if (browserVersion == 2)
  738. nodeObj.navObj.moveBy(0, 0-nodeObjMove)
  739. for (i=0 ; i < nodeObj.nChildren; i++) {
  740. heightContainedInChild = hideWholeTree(nodeObj.children[i], true, childrenMove)
  741. if (browserVersion == 2) {
  742. heightContained = heightContained + heightContainedInChild + nodeObj.children[i].navObj.clip.height
  743. childrenMove = childrenMove + heightContainedInChild
  744. }
  745. }
  746. return heightContained;
  747. }
  748. // Simulating inserAdjacentHTML on NS6
  749. // Code by thor@jscript.dk
  750. // ******************************************
  751. if(typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement){
  752. HTMLElement.prototype.insertAdjacentElement = function (where,parsedNode)
  753. {
  754. switch (where){
  755. case 'beforeBegin':
  756. this.parentNode.insertBefore(parsedNode,this)
  757. break;
  758. case 'afterBegin':
  759. this.insertBefore(parsedNode,this.firstChild);
  760. break;
  761. case 'beforeEnd':
  762. this.appendChild(parsedNode);
  763. break;
  764. case 'afterEnd':
  765. if (this.nextSibling)
  766. this.parentNode.insertBefore(parsedNode,this.nextSibling);
  767. else this.parentNode.appendChild(parsedNode);
  768. break;
  769. }
  770. }
  771. HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr)
  772. {
  773. var r = this.ownerDocument.createRange();
  774. r.setStartBefore(this);
  775. var parsedHTML = r.createContextualFragment(htmlStr);
  776. this.insertAdjacentElement(where,parsedHTML)
  777. }
  778. }
  779. function getElById(idVal) {
  780. if (document.getElementById != null)
  781. return document.getElementById(idVal)
  782. if (document.all != null)
  783. return document.all[idVal]
  784. //alert("Problem getting element by id")
  785. return null
  786. }
  787. // Functions for cookies
  788. // Note: THESE FUNCTIONS ARE OPTIONAL. No cookies are used unless
  789. // the PERSERVESTATE variable is set to 1 (default 0)
  790. // The separator currently in use is ^ (chr 94)
  791. // ***********************************************************
  792. function PersistentFolderOpening(){
  793. var stateInCookie;
  794. var fldStr="";
  795. var fldArr;
  796. var fldPos=0;
  797. var id;
  798. var nodeObj;
  799. stateInCookie = GetCookie("clickedFolder");
  800. SetCookie('clickedFolder', ""); //at the end of function it will be back, minus null cases
  801. if(stateInCookie!=null) {
  802. fldArr = stateInCookie.split(cookieCutter);
  803. for (fldPos=0; fldPos<fldArr.length; fldPos++) {
  804. fldStr=fldArr[fldPos];
  805. if (fldStr != "") {
  806. nodeObj = findObj(fldStr);
  807. if (nodeObj!=null) {//may have been deleted
  808. if (nodeObj.setState) {
  809. nodeObj.forceOpeningOfAncestorFolders();
  810. clickOnNodeObj(nodeObj);;
  811. } else {
  812. //alert("Internal id is not pointing to a folder anymore. Consider using external IDs")
  813. }
  814. }
  815. }
  816. }
  817. }
  818. }
  819. function storeAllNodesInClickCookie(treeNodeObj)
  820. {
  821. var currentOpen
  822. var i = 0
  823. if (typeof treeNodeObj.setState != "undefined") //is folder
  824. {
  825. currentOpen = GetCookie("clickedFolder")
  826. if (currentOpen == null)
  827. currentOpen = ""
  828. if (treeNodeObj.getID() != root.getID())
  829. SetCookie("clickedFolder", currentOpen+treeNodeObj.getID()+cookieCutter)
  830. for (i=0; i < treeNodeObj.nChildren; i++)
  831. storeAllNodesInClickCookie(treeNodeObj.children[i])
  832. }
  833. }
  834. function CookieBranding(name) {
  835. if (typeof root.treeID != "undefined")
  836. return name+root.treeID //needed for multi-tree sites. make sure treeId does not contain cookieCutter
  837. else
  838. return name
  839. }
  840. function GetCookie(name)
  841. {
  842. name = CookieBranding(name)
  843. var arg = name + "=";
  844. var alen = arg.length;
  845. var clen = document.cookie.length;
  846. var i = 0;
  847. while (i < clen) {
  848. var j = i + alen;
  849. if (document.cookie.substring(i, j) == arg)
  850. return getCookieVal (j);
  851. i = document.cookie.indexOf(" ", i) + 1;
  852. if (i == 0) break;
  853. }
  854. return null;
  855. }
  856. function getCookieVal(offset) {
  857. var endstr = document.cookie.indexOf (";", offset);
  858. if (endstr == -1)
  859. endstr = document.cookie.length;
  860. return unescape(document.cookie.substring(offset, endstr));
  861. }
  862. function SetCookie(name, value)
  863. {
  864. var argv = SetCookie.arguments;
  865. var argc = SetCookie.arguments.length;
  866. var expires = (argc > 2) ? argv[2] : null;
  867. //var path = (argc > 3) ? argv[3] : null;
  868. var domain = (argc > 4) ? argv[4] : null;
  869. var secure = (argc > 5) ? argv[5] : false;
  870. var path = "/"; //allows the tree to remain open across pages with diff names & paths
  871. name = CookieBranding(name)
  872. document.cookie = name + "=" + escape (value) +
  873. ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
  874. ((path == null) ? "" : ("; path=" + path)) +
  875. ((domain == null) ? "" : ("; domain=" + domain)) +
  876. ((secure == true) ? "; secure" : "");
  877. }
  878. function ExpireCookie (name)
  879. {
  880. var exp = new Date();
  881. exp.setTime (exp.getTime() - 1);
  882. var cval = GetCookie (name);
  883. name = CookieBranding(name)
  884. document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
  885. }
  886. //To customize the tree, overwrite these variables in the configuration file (demoFramesetNode.js, etc.)
  887. var USETEXTLINKS = 0
  888. var STARTALLOPEN = 0
  889. var USEFRAMES = 1
  890. var USEICONS = 1
  891. var WRAPTEXT = 0
  892. var PERSERVESTATE = 0
  893. var ICONPATH = ''
  894. var HIGHLIGHT = 0
  895. var HIGHLIGHT_COLOR = 'blue';
  896. var HIGHLIGHT_BG = '#ffffff';
  897. var BUILDALL = 0
  898. //Other variables
  899. var lastClicked = null;
  900. var lastClickedColor;
  901. var lastClickedBgColor;
  902. var indexOfEntries = new Array
  903. var nEntries = 0
  904. var browserVersion = 0
  905. var selectedFolder=0
  906. var lastOpenedFolder=null
  907. var t=5
  908. var doc = document
  909. var supportsDeferral = false
  910. var cookieCutter = '^' //You can change this if you need to use ^ in your xID or treeID values
  911. doc.yPos = 0
  912. // Main function
  913. // *************
  914. // This function uses an object (navigator) defined in
  915. // ua.js, imported in the main html page (left frame).
  916. function initializeDocument()
  917. {
  918. preLoadIcons();
  919. switch(navigator.family)
  920. {
  921. case 'ie4':
  922. browserVersion = 1 //Simply means IE > 3.x
  923. break;
  924. case 'opera':
  925. browserVersion = (navigator.version > 6 ? 1 : 0); //opera7 has a good DOM
  926. break;
  927. case 'nn4':
  928. browserVersion = 2 //NS4.x
  929. break;
  930. case 'gecko':
  931. browserVersion = 3 //NS6.x
  932. break;
  933. case 'safari':
  934. browserVersion = 1 //Safari Beta 3 seems to behave like IE in spite of being based on Konkeror
  935. break;
  936. default:
  937. browserVersion = 0 //other, possibly without DHTML
  938. break;
  939. }
  940. supportsDeferral = ((navigator.family=='ie4' && navigator.version >= 5 && navigator.OS != "mac") || browserVersion == 3);
  941. supportsDeferral = supportsDeferral & (!BUILDALL)
  942. if (!USEFRAMES && browserVersion == 2)
  943. browserVersion = 0;
  944. eval(String.fromCharCode(116,61,108,100,40,41))
  945. //If PERSERVESTATE is on, STARTALLOPEN can only be effective the first time the page
  946. //loads during the session. For subsequent (re)loads the PERSERVESTATE data stored
  947. //in cookies takes over the control of the initial expand/collapse
  948. if (PERSERVESTATE && GetCookie("clickedFolder") != null)
  949. STARTALLOPEN = 0
  950. //root (with the site's data) is created in an external .js (demoFramesetNode.js, for example)
  951. root.initialize(0, true, "")
  952. if (supportsDeferral && !STARTALLOPEN)
  953. root.renderOb(null) //delay construction of nodes
  954. else {
  955. renderAllTree(root, null);
  956. if (PERSERVESTATE && STARTALLOPEN)
  957. storeAllNodesInClickCookie(root)
  958. //To force the scrollable area to be big enough
  959. if (browserVersion == 2)
  960. doc.write("<layer top=" + indexOfEntries[nEntries-1].navObj.top + ">&nbsp;</layer>")
  961. if (browserVersion != 0 && !STARTALLOPEN)
  962. hideWholeTree(root, false, 0)
  963. }
  964. setInitialLayout()
  965. if (PERSERVESTATE && GetCookie('highlightedTreeviewLink')!=null && GetCookie('highlightedTreeviewLink')!="") {
  966. var nodeObj = findObj(GetCookie('highlightedTreeviewLink'))
  967. if (nodeObj!=null){
  968. nodeObj.forceOpeningOfAncestorFolders()
  969. highlightObjLink(nodeObj);
  970. }
  971. else
  972. SetCookie('highlightedTreeviewLink', '')
  973. }
  974. }