• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<!-- Javascript for accordion menus, included by index.php, shared with OpenCL man pages -->
2<script type="text/javascript">
3<!--
4var temp, temp2, cookieArray, cookieArray2, cookieCount;
5function initiate(){
6  cookieCount=0;
7  if(document.cookie){
8    cookieArray=document.cookie.split(";");
9    cookieArray2=new Array();
10    for(i in cookieArray){
11      cookieArray2[cookieArray[i].split("=")[0].replace(/ /g,"")]=cookieArray[i].split("=")[1].replace(/ /g,"");
12    }
13  }
14  cookieArray=(document.cookie.indexOf("state=")>=0)?cookieArray2["state"].split(","):new Array();
15  temp=document.getElementById("containerul");
16  for(var o=0;o<temp.getElementsByTagName("li").length;o++){
17    if(temp.getElementsByTagName("li")[o].getElementsByTagName("ul").length>0){
18      temp2 = document.createElement("span");
19      temp2.className = "symbols";
20      temp2.style.backgroundImage = (cookieArray.length>0)?((cookieArray[cookieCount]=="true")?"url(bullets-contract.gif)":"url(bullets-expand.gif)"):"url(bullets-expand.gif)";
21      temp2.onmousedown=function(){
22        showhide(this.parentNode);
23        writeCookie();
24      }
25      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild)
26      temp.getElementsByTagName("li")[o].getElementsByTagName("ul")[0].style.display = "none";
27      if(cookieArray[cookieCount]=="true"){
28        showhide(temp.getElementsByTagName("li")[o]);
29      }
30      cookieCount++;
31    }
32    else{
33      temp2 = document.createElement("span");
34      temp2.className = "symbols";
35      temp2.style.backgroundImage = "url(bullets-end.gif)";
36      temp.getElementsByTagName("li")[o].insertBefore(temp2,temp.getElementsByTagName("li")[o].firstChild);
37    }
38  }
39}
40
41function showhide(el){
42  el.getElementsByTagName("ul")[0].style.display=(el.getElementsByTagName("ul")[0].style.display=="block")?"none":"block";
43  el.getElementsByTagName("span")[0].style.backgroundImage=(el.getElementsByTagName("ul")[0].style.display=="block")?"url(bullets-contract.gif)":"url(bullets-expand.gif)";
44}
45
46function writeCookie(){ // Runs through the menu and puts the "states" of each nested list into an array, the array is then joined together and assigned to a cookie.
47  cookieArray=new Array()
48  for(var q=0;q<temp.getElementsByTagName("li").length;q++){
49    if(temp.getElementsByTagName("li")[q].childNodes.length>0){
50      if(temp.getElementsByTagName("li")[q].childNodes[0].nodeName=="SPAN" && temp.getElementsByTagName("li")[q].getElementsByTagName("ul").length>0){
51        cookieArray[cookieArray.length]=(temp.getElementsByTagName("li")[q].getElementsByTagName("ul")[0].style.display=="block");
52      }
53    }
54  }
55  document.cookie="state="+cookieArray.join(",")+";expires="+new Date(new Date().getTime() + 365*24*60*60*1000).toGMTString();
56}
57//-->
58</script>
59