2 @licstart The following is the entire license notice for the JavaScript code in this file.
6 Copyright (C) 1997-2020 by Dimitri van Heesch
8 Permission is hereby granted, free of charge, to any person obtaining a copy of this software
9 and associated documentation files (the "Software"), to deal in the Software without restriction,
10 including without limitation the rights to use, copy, modify, merge, publish, distribute,
11 sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
14 The above copyright notice and this permission notice shall be included in all copies or
15 substantial portions of the Software.
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
18 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 @licend The above is the entire license notice for the JavaScript code in this file
25 var navTreeSubIndices = new Array();
26 var arrowDown = '▼';
27 var arrowRight = '►';
29 function getData(varName)
31 var i = varName.lastIndexOf('/');
32 var n = i>=0 ? varName.substring(i+1) : varName;
33 return eval(n.replace(/\-/g,'_'));
36 function stripPath(uri)
38 return uri.substring(uri.lastIndexOf('/')+1);
41 function stripPath2(uri)
43 var i = uri.lastIndexOf('/');
44 var s = uri.substring(i+1);
45 var m = uri.substring(0,i+1).match(/\/d\w\/d\w\w\/$/);
46 return m ? uri.substring(i-6) : s;
51 return $(location).attr('hash').substring(1).replace(/[^\w\-]/g,'');
56 return '#'+hashValue();
61 return $(location).attr('pathname').replace(/[^-A-Za-z0-9+&@#/%?=~_|!:,.;\(\)]/g, '');
64 function localStorageSupported()
67 return 'localStorage' in window && window['localStorage'] !== null && window.localStorage.getItem;
74 function storeLink(link)
76 if (!$("#nav-sync").hasClass('sync') && localStorageSupported()) {
77 window.localStorage.setItem('navpath',link);
83 if (localStorageSupported()) {
84 window.localStorage.setItem('navpath','');
90 if (localStorageSupported()) {
91 return window.localStorage.getItem('navpath');
97 function getScript(scriptName,func,show)
99 var head = document.getElementsByTagName("head")[0];
100 var script = document.createElement('script');
101 script.id = scriptName;
102 script.type = 'text/javascript';
103 script.onload = func;
104 script.src = scriptName+'.js';
105 head.appendChild(script);
108 function createIndent(o,domNode,node,level)
112 while (n.parentNode) { level++; n=n.parentNode; }
113 if (node.childrenData) {
114 var imgNode = document.createElement("span");
115 imgNode.className = 'arrow';
116 imgNode.style.paddingLeft=(16*level).toString()+'px';
117 imgNode.innerHTML=arrowRight;
118 node.plus_img = imgNode;
119 node.expandToggle = document.createElement("a");
120 node.expandToggle.href = "javascript:void(0)";
121 node.expandToggle.onclick = function() {
123 $(node.getChildrenUL()).slideUp("fast");
124 node.plus_img.innerHTML=arrowRight;
125 node.expanded = false;
127 expandNode(o, node, false, false);
130 node.expandToggle.appendChild(imgNode);
131 domNode.appendChild(node.expandToggle);
133 var span = document.createElement("span");
134 span.className = 'arrow';
135 span.style.width = 16*(level+1)+'px';
136 span.innerHTML = ' ';
137 domNode.appendChild(span);
141 var animationInProgress = false;
143 function gotoAnchor(anchor,aname,updateLocation)
145 var pos, docContent = $('#doc-content');
146 var ancParent = $(anchor.parent());
147 if (ancParent.hasClass('memItemLeft') ||
148 ancParent.hasClass('memtitle') ||
149 ancParent.hasClass('fieldname') ||
150 ancParent.hasClass('fieldtype') ||
151 ancParent.is(':header'))
153 pos = ancParent.position().top;
154 } else if (anchor.position()) {
155 pos = anchor.position().top;
158 var dist = Math.abs(Math.min(
159 pos-docContent.offset().top,
160 docContent[0].scrollHeight-
161 docContent.height()-docContent.scrollTop()));
162 animationInProgress=true;
164 scrollTop: pos + docContent.scrollTop() - docContent.offset().top
165 },Math.max(50,Math.min(500,dist)),function(){
166 if (updateLocation) window.location.href=aname;
167 animationInProgress=false;
172 function newNode(o, po, text, link, childrenData, lastNode)
174 var node = new Object();
175 node.children = Array();
176 node.childrenData = childrenData;
177 node.depth = po.depth + 1;
178 node.relpath = po.relpath;
179 node.isLast = lastNode;
181 node.li = document.createElement("li");
182 po.getChildrenUL().appendChild(node.li);
183 node.parentNode = po;
185 node.itemDiv = document.createElement("div");
186 node.itemDiv.className = "item";
188 node.labelSpan = document.createElement("span");
189 node.labelSpan.className = "label";
191 createIndent(o,node.itemDiv,node,0);
192 node.itemDiv.appendChild(node.labelSpan);
193 node.li.appendChild(node.itemDiv);
195 var a = document.createElement("a");
196 node.labelSpan.appendChild(a);
197 node.label = document.createTextNode(text);
198 node.expanded = false;
199 a.appendChild(node.label);
202 if (link.substring(0,1)=='^') {
203 url = link.substring(1);
206 url = node.relpath+link;
208 a.className = stripPath(link.replace('#',':'));
209 if (link.indexOf('#')!=-1) {
210 var aname = '#'+link.split('#')[1];
211 var srcPage = stripPath(pathName());
212 var targetPage = stripPath(link.split('#')[0]);
213 a.href = srcPage!=targetPage ? url : "javascript:void(0)";
214 a.onclick = function(){
216 if (!$(a).parent().parent().hasClass('selected'))
218 $('.item').removeClass('selected');
219 $('.item').removeAttr('id');
220 $(a).parent().parent().addClass('selected');
221 $(a).parent().parent().attr('id','selected');
223 var anchor = $(aname);
224 gotoAnchor(anchor,aname,true);
228 a.onclick = function() { storeLink(link); }
231 if (childrenData != null)
233 a.className = "nolink";
234 a.href = "javascript:void(0)";
235 a.onclick = node.expandToggle.onclick;
239 node.childrenUL = null;
240 node.getChildrenUL = function() {
241 if (!node.childrenUL) {
242 node.childrenUL = document.createElement("ul");
243 node.childrenUL.className = "children_ul";
244 node.childrenUL.style.display = "none";
245 node.li.appendChild(node.childrenUL);
247 return node.childrenUL;
255 var headerHeight = $("#top").height();
256 var footerHeight = $("#nav-path").height();
257 var windowHeight = $(window).height() - headerHeight - footerHeight;
258 (function (){ // retry until we can scroll to the selected item
260 var navtree=$('#nav-tree');
261 navtree.scrollTo('#selected',100,{offset:-windowHeight/2});
263 setTimeout(arguments.callee, 0);
268 function expandNode(o, node, imm, showRoot)
270 if (node.childrenData && !node.expanded) {
271 if (typeof(node.childrenData)==='string') {
272 var varName = node.childrenData;
273 getScript(node.relpath+varName,function(){
274 node.childrenData = getData(varName);
275 expandNode(o, node, imm, showRoot);
278 if (!node.childrenVisited) {
281 $(node.getChildrenUL()).slideDown("fast");
282 node.plus_img.innerHTML = arrowDown;
283 node.expanded = true;
288 function glowEffect(n,duration)
290 n.addClass('glow').delay(duration).queue(function(next){
291 $(this).removeClass('glow');next();
295 function highlightAnchor()
297 var aname = hashUrl();
298 var anchor = $(aname);
299 if (anchor.parent().attr('class')=='memItemLeft'){
300 var rows = $('.memberdecls tr[class$="'+hashValue()+'"]');
301 glowEffect(rows.children(),300); // member without details
302 } else if (anchor.parent().attr('class')=='fieldname'){
303 glowEffect(anchor.parent().parent(),1000); // enum value
304 } else if (anchor.parent().attr('class')=='fieldtype'){
305 glowEffect(anchor.parent().parent(),1000); // struct field
306 } else if (anchor.parent().is(":header")) {
307 glowEffect(anchor.parent(),1000); // section header
309 glowEffect(anchor.next(),1000); // normal member
313 function selectAndHighlight(hash,n)
317 var link=stripPath(pathName())+':'+hash.substring(1);
318 a=$('.item a[class$="'+link+'"]');
321 a.parent().parent().addClass('selected');
322 a.parent().parent().attr('id','selected');
325 $(n.itemDiv).addClass('selected');
326 $(n.itemDiv).attr('id','selected');
329 if (typeof page_layout!=='undefined' && page_layout==1) {
330 topOffset+=$('#top').outerHeight();
332 if ($('#nav-tree-contents .item:first').hasClass('selected')) {
335 $('#nav-sync').css('top',topOffset+'px');
339 function showNode(o, node, index, hash)
341 if (node && node.childrenData) {
342 if (typeof(node.childrenData)==='string') {
343 var varName = node.childrenData;
344 getScript(node.relpath+varName,function(){
345 node.childrenData = getData(varName);
346 showNode(o,node,index,hash);
349 if (!node.childrenVisited) {
352 $(node.getChildrenUL()).css({'display':'block'});
353 node.plus_img.innerHTML = arrowDown;
354 node.expanded = true;
355 var n = node.children[o.breadcrumbs[index]];
356 if (index+1<o.breadcrumbs.length) {
357 showNode(o,n,index+1,hash);
359 if (typeof(n.childrenData)==='string') {
360 var varName = n.childrenData;
361 getScript(n.relpath+varName,function(){
362 n.childrenData = getData(varName);
364 showNode(o,node,index,hash); // retry with child node expanded
367 /* vlamar01: Commented two lines below to ensure nav. tree expands on all selections */
368 //var rootBase = stripPath(o.toroot.replace(/\..+$/, ''));
369 //if (rootBase=="index" || rootBase=="pages" || rootBase=="search")
371 expandNode(o, n, true, true);
373 selectAndHighlight(hash,n);
378 selectAndHighlight(hash);
382 function removeToInsertLater(element) {
383 var parentNode = element.parentNode;
384 var nextSibling = element.nextSibling;
385 parentNode.removeChild(element);
388 parentNode.insertBefore(element, nextSibling);
390 parentNode.appendChild(element);
395 function getNode(o, po)
397 var insertFunction = removeToInsertLater(po.li);
398 po.childrenVisited = true;
399 var l = po.childrenData.length-1;
400 for (var i in po.childrenData) {
401 var nodeData = po.childrenData[i];
402 po.children[i] = newNode(o, po, nodeData[0], nodeData[1], nodeData[2],
408 function gotoNode(o,subIndex,root,hash,relpath)
410 var nti = navTreeSubIndices[subIndex][root+hash];
411 o.breadcrumbs = $.extend(true, [], nti ? nti : navTreeSubIndices[subIndex][root]);
412 if (!o.breadcrumbs && root!=NAVTREE[0][1]) { // fallback: show index
413 navTo(o,NAVTREE[0][1],"",relpath);
414 $('.item').removeClass('selected');
415 $('.item').removeAttr('id');
418 o.breadcrumbs.unshift(0); // add 0 for root node
419 showNode(o, o.node, 0, hash);
423 function navTo(o,root,hash,relpath)
425 var link = cachedLink();
427 var parts = link.split('#');
429 if (parts.length>1) hash = '#'+parts[1].replace(/[^\w\-]/g,'');
432 if (hash.match(/^#l\d+$/)) {
433 var anchor=$('a[name='+hash.substring(1)+']');
434 glowEffect(anchor.parent(),1000); // line number
435 hash=''; // strip line number anchors
439 while (NAVTREEINDEX[i+1]<=url) i++;
440 if (i==-1) { i=0; root=NAVTREE[0][1]; } // fallback: show index
441 if (navTreeSubIndices[i]) {
442 gotoNode(o,i,root,hash,relpath)
444 getScript(relpath+'navtreeindex'+i,function(){
445 navTreeSubIndices[i] = eval('NAVTREEINDEX'+i);
446 /* ensures first section is expanded when opening index */
447 if ((root=="index.html") && (!navTreeSubIndices[i]["index.html"].length)) {
448 navTreeSubIndices[i]["index.html"]=[0];
450 if (navTreeSubIndices[i]) {
451 gotoNode(o,i,root,hash,relpath);
457 function showSyncOff(n,relpath)
459 n.html('<img src="'+relpath+'sync_off.png" title="'+SYNCOFFMSG+'"/>');
462 function showSyncOn(n,relpath)
464 n.html('<img src="'+relpath+'sync_on.png" title="'+SYNCONMSG+'"/>');
467 function toggleSyncButton(relpath)
469 var navSync = $('#nav-sync');
470 if (navSync.hasClass('sync')) {
471 navSync.removeClass('sync');
472 showSyncOff(navSync,relpath);
473 storeLink(stripPath2(pathName())+hashUrl());
475 navSync.addClass('sync');
476 showSyncOn(navSync,relpath);
481 var loadTriggered = false;
482 var readyTriggered = false;
483 var loadObject,loadToRoot,loadUrl,loadRelPath;
485 $(window).on('load',function(){
486 if (readyTriggered) { // ready first
487 navTo(loadObject,loadToRoot,loadUrl,loadRelPath);
493 function initNavTree(toroot,relpath)
495 var o = new Object();
497 o.node = new Object();
498 o.node.li = document.getElementById("nav-tree-contents");
499 o.node.childrenData = NAVTREE;
500 o.node.children = new Array();
501 o.node.childrenUL = document.createElement("ul");
502 o.node.getChildrenUL = function() { return o.node.childrenUL; };
503 o.node.li.appendChild(o.node.childrenUL);
505 o.node.relpath = relpath;
506 o.node.expanded = false;
507 o.node.isLast = true;
508 o.node.plus_img = document.createElement("span");
509 o.node.plus_img.className = 'arrow';
510 o.node.plus_img.innerHTML = arrowRight;
512 if (localStorageSupported()) {
513 var navSync = $('#nav-sync');
515 showSyncOff(navSync,relpath);
516 navSync.removeClass('sync');
518 showSyncOn(navSync,relpath);
520 navSync.click(function(){ toggleSyncButton(relpath); });
523 if (loadTriggered) { // load before ready
524 navTo(o,toroot,hashUrl(),relpath);
526 } else { // ready before load
530 loadRelPath = relpath;
534 $(window).bind('hashchange', function(){
535 if (window.location.hash && window.location.hash.length>1){
537 if ($(location).attr('hash')){
538 var clslink=stripPath(pathName())+':'+hashValue();
539 a=$('.item a[class$="'+clslink.replace(/</g,'\\3c ')+'"]');
541 if (a==null || !$(a).parent().parent().hasClass('selected')){
542 $('.item').removeClass('selected');
543 $('.item').removeAttr('id');
545 var link=stripPath2(pathName());
546 navTo(o,link,hashUrl(),relpath);
547 } else if (!animationInProgress) {
548 $('#doc-content').scrollTop(0);
549 $('.item').removeClass('selected');
550 $('.item').removeAttr('id');
551 navTo(o,toroot,hashUrl(),relpath);