Chris@6: var navTreeSubIndices = new Array(); Chris@6: var arrowDown = '▼'; Chris@6: var arrowRight = '►'; Chris@1: Chris@3: function getData(varName) Chris@3: { Chris@3: var i = varName.lastIndexOf('/'); Chris@3: var n = i>=0 ? varName.substring(i+1) : varName; Chris@6: return eval(n.replace(/\-/g,'_')); Chris@3: } Chris@3: Chris@3: function stripPath(uri) Chris@3: { Chris@3: return uri.substring(uri.lastIndexOf('/')+1); Chris@3: } Chris@3: Chris@6: function stripPath2(uri) Chris@6: { Chris@6: var i = uri.lastIndexOf('/'); Chris@6: var s = uri.substring(i+1); Chris@6: var m = uri.substring(0,i+1).match(/\/d\w\/d\w\w\/$/); Chris@6: return m ? uri.substring(i-6) : s; Chris@6: } Chris@6: Chris@6: function hashValue() Chris@6: { Chris@6: return $(location).attr('hash').substring(1).replace(/[^\w\-]/g,''); Chris@6: } Chris@6: Chris@6: function hashUrl() Chris@6: { Chris@6: return '#'+hashValue(); Chris@6: } Chris@6: Chris@6: function pathName() Chris@6: { Chris@6: return $(location).attr('pathname').replace(/[^-A-Za-z0-9+&@#/%?=~_|!:,.;\(\)]/g, ''); Chris@6: } Chris@6: Chris@6: function localStorageSupported() Chris@6: { Chris@6: try { Chris@6: return 'localStorage' in window && window['localStorage'] !== null && window.localStorage.getItem; Chris@6: } Chris@6: catch(e) { Chris@6: return false; Chris@6: } Chris@6: } Chris@6: Chris@6: Chris@6: function storeLink(link) Chris@6: { Chris@6: if (!$("#nav-sync").hasClass('sync') && localStorageSupported()) { Chris@6: window.localStorage.setItem('navpath',link); Chris@6: } Chris@6: } Chris@6: Chris@6: function deleteLink() Chris@6: { Chris@6: if (localStorageSupported()) { Chris@6: window.localStorage.setItem('navpath',''); Chris@6: } Chris@6: } Chris@6: Chris@6: function cachedLink() Chris@6: { Chris@6: if (localStorageSupported()) { Chris@6: return window.localStorage.getItem('navpath'); Chris@6: } else { Chris@6: return ''; Chris@6: } Chris@6: } Chris@6: Chris@3: function getScript(scriptName,func,show) Chris@3: { Chris@6: var head = document.getElementsByTagName("head")[0]; Chris@3: var script = document.createElement('script'); Chris@3: script.id = scriptName; Chris@3: script.type = 'text/javascript'; Chris@6: script.onload = func; Chris@6: script.src = scriptName+'.js'; Chris@6: if ($.browser.msie && $.browser.version<=8) { Chris@6: // script.onload does not work with older versions of IE Chris@6: script.onreadystatechange = function() { Chris@6: if (script.readyState=='complete' || script.readyState=='loaded') { Chris@6: func(); if (show) showRoot(); Chris@6: } Chris@3: } Chris@6: } Chris@3: head.appendChild(script); Chris@3: } Chris@3: Chris@1: function createIndent(o,domNode,node,level) Chris@1: { Chris@6: var level=-1; Chris@6: var n = node; Chris@6: while (n.parentNode) { level++; n=n.parentNode; } Chris@6: if (node.childrenData) { Chris@6: var imgNode = document.createElement("span"); Chris@6: imgNode.className = 'arrow'; Chris@6: imgNode.style.paddingLeft=(16*level).toString()+'px'; Chris@6: imgNode.innerHTML=arrowRight; Chris@1: node.plus_img = imgNode; Chris@1: node.expandToggle = document.createElement("a"); Chris@1: node.expandToggle.href = "javascript:void(0)"; Chris@3: node.expandToggle.onclick = function() { Chris@3: if (node.expanded) { Chris@1: $(node.getChildrenUL()).slideUp("fast"); Chris@6: node.plus_img.innerHTML=arrowRight; Chris@1: node.expanded = false; Chris@3: } else { Chris@3: expandNode(o, node, false, false); Chris@1: } Chris@1: } Chris@1: node.expandToggle.appendChild(imgNode); Chris@1: domNode.appendChild(node.expandToggle); Chris@3: } else { Chris@6: var span = document.createElement("span"); Chris@6: span.className = 'arrow'; Chris@6: span.style.width = 16*(level+1)+'px'; Chris@6: span.innerHTML = ' '; Chris@6: domNode.appendChild(span); Chris@1: } Chris@6: } Chris@6: Chris@6: var animationInProgress = false; Chris@6: Chris@6: function gotoAnchor(anchor,aname,updateLocation) Chris@6: { Chris@6: var pos, docContent = $('#doc-content'); Chris@6: var ancParent = $(anchor.parent()); Chris@6: if (ancParent.hasClass('memItemLeft') || Chris@6: ancParent.hasClass('fieldname') || Chris@6: ancParent.hasClass('fieldtype') || Chris@6: ancParent.is(':header')) Chris@6: { Chris@6: pos = ancParent.position().top; Chris@6: } else if (anchor.position()) { Chris@6: pos = anchor.position().top; Chris@1: } Chris@6: if (pos) { Chris@6: var dist = Math.abs(Math.min( Chris@6: pos-docContent.offset().top, Chris@6: docContent[0].scrollHeight- Chris@6: docContent.height()-docContent.scrollTop())); Chris@6: animationInProgress=true; Chris@6: docContent.animate({ Chris@6: scrollTop: pos + docContent.scrollTop() - docContent.offset().top Chris@6: },Math.max(50,Math.min(500,dist)),function(){ Chris@6: if (updateLocation) window.location.href=aname; Chris@6: animationInProgress=false; Chris@6: }); Chris@6: } Chris@1: } Chris@1: Chris@1: function newNode(o, po, text, link, childrenData, lastNode) Chris@1: { Chris@1: var node = new Object(); Chris@1: node.children = Array(); Chris@1: node.childrenData = childrenData; Chris@1: node.depth = po.depth + 1; Chris@1: node.relpath = po.relpath; Chris@1: node.isLast = lastNode; Chris@1: Chris@1: node.li = document.createElement("li"); Chris@1: po.getChildrenUL().appendChild(node.li); Chris@1: node.parentNode = po; Chris@1: Chris@1: node.itemDiv = document.createElement("div"); Chris@1: node.itemDiv.className = "item"; Chris@1: Chris@1: node.labelSpan = document.createElement("span"); Chris@1: node.labelSpan.className = "label"; Chris@1: Chris@1: createIndent(o,node.itemDiv,node,0); Chris@1: node.itemDiv.appendChild(node.labelSpan); Chris@1: node.li.appendChild(node.itemDiv); Chris@1: Chris@1: var a = document.createElement("a"); Chris@1: node.labelSpan.appendChild(a); Chris@1: node.label = document.createTextNode(text); Chris@3: node.expanded = false; Chris@1: a.appendChild(node.label); Chris@3: if (link) { Chris@3: var url; Chris@3: if (link.substring(0,1)=='^') { Chris@3: url = link.substring(1); Chris@3: link = url; Chris@3: } else { Chris@3: url = node.relpath+link; Chris@3: } Chris@3: a.className = stripPath(link.replace('#',':')); Chris@3: if (link.indexOf('#')!=-1) { Chris@3: var aname = '#'+link.split('#')[1]; Chris@6: var srcPage = stripPath(pathName()); Chris@3: var targetPage = stripPath(link.split('#')[0]); Chris@6: a.href = srcPage!=targetPage ? url : "javascript:void(0)"; Chris@3: a.onclick = function(){ Chris@6: storeLink(link); Chris@3: if (!$(a).parent().parent().hasClass('selected')) Chris@3: { Chris@3: $('.item').removeClass('selected'); Chris@3: $('.item').removeAttr('id'); Chris@3: $(a).parent().parent().addClass('selected'); Chris@3: $(a).parent().parent().attr('id','selected'); Chris@3: } Chris@6: var anchor = $(aname); Chris@6: gotoAnchor(anchor,aname,true); Chris@3: }; Chris@3: } else { Chris@3: a.href = url; Chris@6: a.onclick = function() { storeLink(link); } Chris@3: } Chris@3: } else { Chris@6: if (childrenData != null) Chris@1: { Chris@1: a.className = "nolink"; Chris@1: a.href = "javascript:void(0)"; Chris@1: a.onclick = node.expandToggle.onclick; Chris@1: } Chris@1: } Chris@1: Chris@1: node.childrenUL = null; Chris@3: node.getChildrenUL = function() { Chris@3: if (!node.childrenUL) { Chris@1: node.childrenUL = document.createElement("ul"); Chris@1: node.childrenUL.className = "children_ul"; Chris@1: node.childrenUL.style.display = "none"; Chris@1: node.li.appendChild(node.childrenUL); Chris@1: } Chris@1: return node.childrenUL; Chris@1: }; Chris@1: Chris@1: return node; Chris@1: } Chris@1: Chris@1: function showRoot() Chris@1: { Chris@1: var headerHeight = $("#top").height(); Chris@1: var footerHeight = $("#nav-path").height(); Chris@1: var windowHeight = $(window).height() - headerHeight - footerHeight; Chris@3: (function (){ // retry until we can scroll to the selected item Chris@3: try { Chris@6: var navtree=$('#nav-tree'); Chris@3: navtree.scrollTo('#selected',0,{offset:-windowHeight/2}); Chris@3: } catch (err) { Chris@3: setTimeout(arguments.callee, 0); Chris@3: } Chris@3: })(); Chris@1: } Chris@1: Chris@3: function expandNode(o, node, imm, showRoot) Chris@1: { Chris@3: if (node.childrenData && !node.expanded) { Chris@3: if (typeof(node.childrenData)==='string') { Chris@3: var varName = node.childrenData; Chris@3: getScript(node.relpath+varName,function(){ Chris@3: node.childrenData = getData(varName); Chris@3: expandNode(o, node, imm, showRoot); Chris@3: }, showRoot); Chris@3: } else { Chris@3: if (!node.childrenVisited) { Chris@3: getNode(o, node); Chris@6: } if (imm || ($.browser.msie && $.browser.version>8)) { Chris@6: // somehow slideDown jumps to the start of tree for IE9 :-( Chris@3: $(node.getChildrenUL()).show(); Chris@3: } else { Chris@3: $(node.getChildrenUL()).slideDown("fast"); Chris@3: } Chris@6: node.plus_img.innerHTML = arrowDown; Chris@3: node.expanded = true; Chris@1: } Chris@3: } Chris@3: } Chris@3: Chris@6: function glowEffect(n,duration) Chris@6: { Chris@6: n.addClass('glow').delay(duration).queue(function(next){ Chris@6: $(this).removeClass('glow');next(); Chris@6: }); Chris@6: } Chris@6: Chris@3: function highlightAnchor() Chris@3: { Chris@6: var aname = hashUrl(); Chris@6: var anchor = $(aname); Chris@3: if (anchor.parent().attr('class')=='memItemLeft'){ Chris@6: var rows = $('.memberdecls tr[class$="'+hashValue()+'"]'); Chris@6: glowEffect(rows.children(),300); // member without details Chris@6: } else if (anchor.parent().attr('class')=='fieldname'){ Chris@6: glowEffect(anchor.parent().parent(),1000); // enum value Chris@6: } else if (anchor.parent().attr('class')=='fieldtype'){ Chris@6: glowEffect(anchor.parent().parent(),1000); // struct field Chris@3: } else if (anchor.parent().is(":header")) { Chris@6: glowEffect(anchor.parent(),1000); // section header Chris@3: } else { Chris@6: glowEffect(anchor.next(),1000); // normal member Chris@3: } Chris@6: gotoAnchor(anchor,aname,false); Chris@3: } Chris@3: Chris@6: function selectAndHighlight(hash,n) Chris@3: { Chris@6: var a; Chris@6: if (hash) { Chris@6: var link=stripPath(pathName())+':'+hash.substring(1); Chris@6: a=$('.item a[class$="'+link+'"]'); Chris@6: } Chris@6: if (a && a.length) { Chris@6: a.parent().parent().addClass('selected'); Chris@6: a.parent().parent().attr('id','selected'); Chris@6: highlightAnchor(); Chris@6: } else if (n) { Chris@6: $(n.itemDiv).addClass('selected'); Chris@6: $(n.itemDiv).attr('id','selected'); Chris@6: } Chris@6: if ($('#nav-tree-contents .item:first').hasClass('selected')) { Chris@6: $('#nav-sync').css('top','30px'); Chris@6: } else { Chris@6: $('#nav-sync').css('top','5px'); Chris@6: } Chris@6: showRoot(); Chris@6: } Chris@6: Chris@6: function showNode(o, node, index, hash) Chris@6: { Chris@6: if (node && node.childrenData) { Chris@3: if (typeof(node.childrenData)==='string') { Chris@3: var varName = node.childrenData; Chris@3: getScript(node.relpath+varName,function(){ Chris@3: node.childrenData = getData(varName); Chris@6: showNode(o,node,index,hash); Chris@3: },true); Chris@3: } else { Chris@3: if (!node.childrenVisited) { Chris@3: getNode(o, node); Chris@3: } Chris@6: $(node.getChildrenUL()).css({'display':'block'}); Chris@6: node.plus_img.innerHTML = arrowDown; Chris@3: node.expanded = true; Chris@3: var n = node.children[o.breadcrumbs[index]]; Chris@3: if (index+11) hash = '#'+parts[1].replace(/[^\w\-]/g,''); Chris@6: else hash=''; Chris@6: } Chris@6: if (hash.match(/^#l\d+$/)) { Chris@6: var anchor=$('a[name='+hash.substring(1)+']'); Chris@6: glowEffect(anchor.parent(),1000); // line number Chris@6: hash=''; // strip line number anchors Chris@6: } Chris@6: var url=root+hash; Chris@6: var i=-1; Chris@6: while (NAVTREEINDEX[i+1]<=url) i++; Chris@6: if (i==-1) { i=0; root=NAVTREE[0][1]; } // fallback: show index Chris@6: if (navTreeSubIndices[i]) { Chris@6: gotoNode(o,i,root,hash,relpath) Chris@6: } else { Chris@6: getScript(relpath+'navtreeindex'+i,function(){ Chris@6: navTreeSubIndices[i] = eval('NAVTREEINDEX'+i); Chris@6: if (navTreeSubIndices[i]) { Chris@6: gotoNode(o,i,root,hash,relpath); Chris@6: } Chris@6: },true); Chris@6: } Chris@6: } Chris@6: Chris@6: function showSyncOff(n,relpath) Chris@6: { Chris@6: n.html(''); Chris@6: } Chris@6: Chris@6: function showSyncOn(n,relpath) Chris@6: { Chris@6: n.html(''); Chris@6: } Chris@6: Chris@6: function toggleSyncButton(relpath) Chris@6: { Chris@6: var navSync = $('#nav-sync'); Chris@6: if (navSync.hasClass('sync')) { Chris@6: navSync.removeClass('sync'); Chris@6: showSyncOff(navSync,relpath); Chris@6: storeLink(stripPath2(pathName())+hashUrl()); Chris@6: } else { Chris@6: navSync.addClass('sync'); Chris@6: showSyncOn(navSync,relpath); Chris@6: deleteLink(); Chris@6: } Chris@1: } Chris@1: Chris@1: function initNavTree(toroot,relpath) Chris@1: { Chris@1: var o = new Object(); Chris@1: o.toroot = toroot; Chris@1: o.node = new Object(); Chris@1: o.node.li = document.getElementById("nav-tree-contents"); Chris@1: o.node.childrenData = NAVTREE; Chris@1: o.node.children = new Array(); Chris@1: o.node.childrenUL = document.createElement("ul"); Chris@1: o.node.getChildrenUL = function() { return o.node.childrenUL; }; Chris@1: o.node.li.appendChild(o.node.childrenUL); Chris@1: o.node.depth = 0; Chris@1: o.node.relpath = relpath; Chris@3: o.node.expanded = false; Chris@3: o.node.isLast = true; Chris@6: o.node.plus_img = document.createElement("span"); Chris@6: o.node.plus_img.className = 'arrow'; Chris@6: o.node.plus_img.innerHTML = arrowRight; Chris@1: Chris@6: if (localStorageSupported()) { Chris@6: var navSync = $('#nav-sync'); Chris@6: if (cachedLink()) { Chris@6: showSyncOff(navSync,relpath); Chris@6: navSync.removeClass('sync'); Chris@6: } else { Chris@6: showSyncOn(navSync,relpath); Chris@6: } Chris@6: navSync.click(function(){ toggleSyncButton(relpath); }); Chris@6: } Chris@6: Chris@6: $(window).load(function(){ Chris@6: navTo(o,toroot,hashUrl(),relpath); Chris@6: showRoot(); Chris@6: }); Chris@1: Chris@3: $(window).bind('hashchange', function(){ Chris@3: if (window.location.hash && window.location.hash.length>1){ Chris@3: var a; Chris@3: if ($(location).attr('hash')){ Chris@6: var clslink=stripPath(pathName())+':'+hashValue(); Chris@6: a=$('.item a[class$="'+clslink.replace(/