2 function setCurrState(setting) {
3 document.cookie = "currState=" + escape(setting)
6 // retrieve cookie data
7 function getCurrState() {
8 var label = "currState="
9 var labelLen = label.length
10 var cLen = document.cookie.length
14 if (document.cookie.substring(i,j) == label) {
15 var cEnd = document.cookie.indexOf(";",j)
17 cEnd = document.cookie.length
19 return unescape(document.cookie.substring(j,cEnd))
21 i = document.cookie.indexOf(";",j)
23 i = document.cookie.length
30 // **function that updates persistent storage of state**
31 // toggles an outline mother entry, storing new value in the cookie
35 var currState = getCurrState() // of whole outline
36 var expanded = currState.substring(n-1,n) // of clicked item
37 newString += currState.substring(0,n-1)
38 newString += expanded ^ 1 // Bitwise XOR clicked item
39 newString += currState.substring(n,currState.length)
40 setCurrState(newString) // write new state back to cookie
44 // **functions used in assembling updated outline**
45 // returns the proper GIF file name for each entry's control
47 var mom = db[n].mother // is entry a parent?
48 var expanded = getCurrState().substring(n-1,n) // of clicked item
59 // returns the proper status line text based on the icon style
60 function getGIFStatus(n) {
61 var mom = db[n].mother // is entry a parent
62 var expanded = getCurrState().substring(n-1,n) // of rolled item
64 return "No further items"
67 return "Click to collapse nested items"
70 return "Click to expand nested items"
73 // returns padded spaces (in multiples of 3) for indenting
76 for (var i = 1; i <= n; i++) {
82 // initialize 'current state' storage field
83 if (getCurrState() == "" || getCurrState().length != db.length) {
85 for (i = 2; i <= db.length; i++) {
88 setCurrState(initState)
91 // see if user is running a Mac browser for special case handling
93 return (navigator.userAgent.indexOf("Macintosh") >= 0) ? true :false
100 <SCRIPT LANGUAGE="JavaScript">
102 // build new outline based on the values of the cookie
103 // and data points in the outline data array.
104 // This fires each time the user clicks on a control,
105 // because the HREF for each one reloads the current document.
106 var prevIndentDisplayed = 0
107 var showMyDaughter = 0
108 document.write( "<CENTER><H3>Call Tree</H3></CENTER><HR>" )
109 var newOutline = "<PRE><H4>" // let padded spaces make indents
111 // cycle through each entry in the outline array
112 for (var i = 1; i <= db.length; i++) {
113 var theGIF = getGIF(i) // get the image
114 var theGIFStatus = getGIFStatus(i) // get the status message
115 var currIndent = db[i].indent // get the indent level
116 var expanded = getCurrState().substring(i-1,i) // current state
117 // display entry only if it meets one of three criteria
118 if (currIndent == 0 || currIndent <= prevIndentDisplayed || (showMyDaughter == 1 && (currIndent - prevIndentDisplayed == 1))) {
119 newOutline += pad(currIndent)
120 newOutline += "<A HREF=\"javascript:history.go(0)\" onMouseOver=\"window.parent.status=\'" + theGIFStatus + "\';return true;\" onClick=\"toggle(" + i + ")\"><IMG SRC=\"" + theGIF + "\" HEIGHT=11 WIDTH=11 BORDER=0></A>"
121 newOutline += " <A HREF=\"" + db[i].URL + "\" TARGET=\"bottom_target\" onMouseOver=\"window.parent.status=\'View " + db[i].display + "...\';return true;\">" + db[i].display + "</A><BR>"
122 prevIndentDisplayed = currIndent
123 showMyDaughter = expanded
126 newOutline += "</H4></PRE><HR>"
127 document.write(newOutline)