source: trunk/MESOSCALE/LMD_MM_MARS/SRC/WRFV2/tools/callgraph.page2 @ 1759

Last change on this file since 1759 was 11, checked in by aslmd, 14 years ago

spiga@svn-planeto:ajoute le modele meso-echelle martien

File size: 4.0 KB
Line 
1// set cookie data
2function setCurrState(setting) {
3        document.cookie = "currState=" + escape(setting)
4}
5
6// retrieve cookie data
7function getCurrState() {
8        var label = "currState="
9        var labelLen = label.length
10        var cLen = document.cookie.length
11        var i = 0
12        while (i < cLen) {
13                var j = i + labelLen
14                if (document.cookie.substring(i,j) == label) {
15                        var cEnd = document.cookie.indexOf(";",j)
16                        if (cEnd ==     -1) {
17                                cEnd = document.cookie.length
18                        }
19                        return unescape(document.cookie.substring(j,cEnd))
20                } else {
21                        i = document.cookie.indexOf(";",j)
22                        if ( i == -1 ) {
23                                i = document.cookie.length
24                        }
25                }
26        }
27        return ""
28}
29
30// **function that updates persistent storage of state**
31// toggles an outline mother entry, storing new value in the cookie
32function toggle(n) {
33        if (n != 0) {
34                var newString = ""
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
41        }
42}
43
44// **functions used in assembling updated outline**
45// returns the proper GIF file name for each entry's control
46function getGIF(n) {
47        var mom = db[n].mother  // is entry a parent?
48        var expanded = getCurrState().substring(n-1,n) // of clicked item
49        if (!mom) {
50                return "daughter.gif"
51        } else {
52                if (expanded == 1) {
53                        return "exploded.gif"
54                }
55        }
56        return "collapsd.gif"
57}
58
59// returns the proper status line text based on the icon style
60function getGIFStatus(n) {
61        var mom = db[n].mother  // is entry a parent
62        var expanded = getCurrState().substring(n-1,n) // of rolled item
63        if (!mom) {
64                return "No further items"
65        } else {
66                if (expanded == 1) {
67                        return "Click to collapse nested items"
68                }
69        }
70        return "Click to expand nested items"
71}
72
73// returns padded spaces (in multiples of 3) for indenting
74function pad(n) {
75        var result = ""
76        for (var i = 1; i <= n; i++) {
77                result += "   "
78        }
79        return result
80}
81
82// initialize 'current state' storage field
83if (getCurrState() == "" || getCurrState().length != db.length) {
84        initState = "1"
85        for (i = 2; i <= db.length; i++) {
86                initState += "0"
87        }
88        setCurrState(initState)
89}
90
91// see if user is running a Mac browser for special case handling
92function isMac() {
93        return (navigator.userAgent.indexOf("Macintosh") >= 0) ? true :false
94}
95// end -->
96</SCRIPT>
97</HEAD>
98
99<BODY>
100<SCRIPT LANGUAGE="JavaScript">
101<!-- start
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.
106var prevIndentDisplayed = 0
107var showMyDaughter = 0
108document.write( "<CENTER><H3>Call Tree</H3></CENTER><HR>" )
109var newOutline = "<PRE><H4>"   // let padded spaces make indents
110
111// cycle through each entry in the outline array
112for (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
124        }
125}
126newOutline += "</H4></PRE><HR>"
127document.write(newOutline)
128
129// end -->
130</SCRIPT>
131</BODY>
132</HTML>
133
Note: See TracBrowser for help on using the repository browser.