1/*
2 @licstart  The following is the entire license notice for the JavaScript code in this file.
3
4 The MIT License (MIT)
5
6 Copyright (C) 1997-2020 by Dimitri van Heesch
7
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:
13
14 The above copyright notice and this permission notice shall be included in all copies or
15 substantial portions of the Software.
16
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.
22
23 @licend  The above is the entire license notice for the JavaScript code in this file
24 */
25var navTreeSubIndices = new Array();
26var arrowDown = '▼';
27var arrowRight = '►';
28
29function getData(varName)
30{
31  var i = varName.lastIndexOf('/');
32  var n = i>=0 ? varName.substring(i+1) : varName;
33  return eval(n.replace(/\-/g,'_'));
34}
35
36function stripPath(uri)
37{
38  return uri.substring(uri.lastIndexOf('/')+1);
39}
40
41function stripPath2(uri)
42{
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;
47}
48
49function hashValue()
50{
51  return $(location).attr('hash').substring(1).replace(/[^\w\-]/g,'');
52}
53
54function hashUrl()
55{
56  return '#'+hashValue();
57}
58
59function pathName()
60{
61  return $(location).attr('pathname').replace(/[^-A-Za-z0-9+&@#/%?=~_|!:,.;\(\)]/g, '');
62}
63
64function localStorageSupported()
65{
66  try {
67    return 'localStorage' in window && window['localStorage'] !== null && window.localStorage.getItem;
68  }
69  catch(e) {
70    return false;
71  }
72}
73
74function storeLink(link)
75{
76  if (!$("#nav-sync").hasClass('sync') && localStorageSupported()) {
77      window.localStorage.setItem('navpath',link);
78  }
79}
80
81function deleteLink()
82{
83  if (localStorageSupported()) {
84    window.localStorage.setItem('navpath','');
85  }
86}
87
88function cachedLink()
89{
90  if (localStorageSupported()) {
91    return window.localStorage.getItem('navpath');
92  } else {
93    return '';
94  }
95}
96
97function getScript(scriptName,func,show)
98{
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);
106}
107
108function createIndent(o,domNode,node,level)
109{
110  var level=-1;
111  var n = node;
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() {
122      if (node.expanded) {
123        $(node.getChildrenUL()).slideUp("fast");
124        node.plus_img.innerHTML=arrowRight;
125        node.expanded = false;
126      } else {
127        expandNode(o, node, false, false);
128      }
129    }
130    node.expandToggle.appendChild(imgNode);
131    domNode.appendChild(node.expandToggle);
132  } else {
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);
138  }
139}
140
141var animationInProgress = false;
142
143function gotoAnchor(anchor,aname,updateLocation)
144{
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'))
152  {
153    pos = ancParent.position().top;
154  } else if (anchor.position()) {
155    pos = anchor.position().top;
156  }
157  if (pos) {
158    var dist = Math.abs(Math.min(
159               pos-docContent.offset().top,
160               docContent[0].scrollHeight-
161               docContent.height()-docContent.scrollTop()));
162    animationInProgress=true;
163    docContent.animate({
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;
168    });
169  }
170}
171
172function newNode(o, po, text, link, childrenData, lastNode)
173{
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;
180
181  node.li = document.createElement("li");
182  po.getChildrenUL().appendChild(node.li);
183  node.parentNode = po;
184
185  node.itemDiv = document.createElement("div");
186  node.itemDiv.className = "item";
187
188  node.labelSpan = document.createElement("span");
189  node.labelSpan.className = "label";
190
191  createIndent(o,node.itemDiv,node,0);
192  node.itemDiv.appendChild(node.labelSpan);
193  node.li.appendChild(node.itemDiv);
194
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);
200  if (link) {
201    var url;
202    if (link.substring(0,1)=='^') {
203      url = link.substring(1);
204      link = url;
205    } else {
206      url = node.relpath+link;
207    }
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(){
215        storeLink(link);
216        if (!$(a).parent().parent().hasClass('selected'))
217        {
218          $('.item').removeClass('selected');
219          $('.item').removeAttr('id');
220          $(a).parent().parent().addClass('selected');
221          $(a).parent().parent().attr('id','selected');
222        }
223        var anchor = $(aname);
224        gotoAnchor(anchor,aname,true);
225      };
226    } else {
227      a.href = url;
228      a.onclick = function() { storeLink(link); }
229    }
230  } else {
231    if (childrenData != null)
232    {
233      a.className = "nolink";
234      a.href = "javascript:void(0)";
235      a.onclick = node.expandToggle.onclick;
236    }
237  }
238
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);
246    }
247    return node.childrenUL;
248  };
249
250  return node;
251}
252
253function showRoot()
254{
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
259    try {
260      var navtree=$('#nav-tree');
261      navtree.scrollTo('#selected',100,{offset:-windowHeight/2});
262    } catch (err) {
263      setTimeout(arguments.callee, 0);
264    }
265  })();
266}
267
268function expandNode(o, node, imm, showRoot)
269{
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);
276      }, showRoot);
277    } else {
278      if (!node.childrenVisited) {
279        getNode(o, node);
280      }
281      $(node.getChildrenUL()).slideDown("fast");
282      node.plus_img.innerHTML = arrowDown;
283      node.expanded = true;
284    }
285  }
286}
287
288function glowEffect(n,duration)
289{
290  n.addClass('glow').delay(duration).queue(function(next){
291    $(this).removeClass('glow');next();
292  });
293}
294
295function highlightAnchor()
296{
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
308  } else {
309    glowEffect(anchor.next(),1000); // normal member
310  }
311}
312
313function selectAndHighlight(hash,n)
314{
315  var a;
316  if (hash) {
317    var link=stripPath(pathName())+':'+hash.substring(1);
318    a=$('.item a[class$="'+link+'"]');
319  }
320  if (a && a.length) {
321    a.parent().parent().addClass('selected');
322    a.parent().parent().attr('id','selected');
323    highlightAnchor();
324  } else if (n) {
325    $(n.itemDiv).addClass('selected');
326    $(n.itemDiv).attr('id','selected');
327  }
328  var topOffset=5;
329  if (typeof page_layout!=='undefined' && page_layout==1) {
330    topOffset+=$('#top').outerHeight();
331  }
332  if ($('#nav-tree-contents .item:first').hasClass('selected')) {
333    topOffset+=25;
334  }
335  $('#nav-sync').css('top',topOffset+'px');
336  showRoot();
337}
338
339function showNode(o, node, index, hash)
340{
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);
347      },true);
348    } else {
349      if (!node.childrenVisited) {
350        getNode(o, node);
351      }
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);
358      } else {
359        if (typeof(n.childrenData)==='string') {
360          var varName = n.childrenData;
361          getScript(n.relpath+varName,function(){
362            n.childrenData = getData(varName);
363            node.expanded=false;
364            showNode(o,node,index,hash); // retry with child node expanded
365          },true);
366        } else {
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")
370          {
371            expandNode(o, n, true, true);
372          }
373          selectAndHighlight(hash,n);
374        }
375      }
376    }
377  } else {
378    selectAndHighlight(hash);
379  }
380}
381
382function removeToInsertLater(element) {
383  var parentNode = element.parentNode;
384  var nextSibling = element.nextSibling;
385  parentNode.removeChild(element);
386  return function() {
387    if (nextSibling) {
388      parentNode.insertBefore(element, nextSibling);
389    } else {
390      parentNode.appendChild(element);
391    }
392  };
393}
394
395function getNode(o, po)
396{
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],
403      i==l);
404  }
405  insertFunction();
406}
407
408function gotoNode(o,subIndex,root,hash,relpath)
409{
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');
416  }
417  if (o.breadcrumbs) {
418    o.breadcrumbs.unshift(0); // add 0 for root node
419    showNode(o, o.node, 0, hash);
420  }
421}
422
423function navTo(o,root,hash,relpath)
424{
425  var link = cachedLink();
426  if (link) {
427    var parts = link.split('#');
428    root = parts[0];
429    if (parts.length>1) hash = '#'+parts[1].replace(/[^\w\-]/g,'');
430    else hash='';
431  }
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
436  }
437  var url=root+hash;
438  var i=-1;
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)
443  } else {
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];
449      }
450      if (navTreeSubIndices[i]) {
451        gotoNode(o,i,root,hash,relpath);
452      }
453    },true);
454  }
455}
456
457function showSyncOff(n,relpath)
458{
459    n.html('<img src="'+relpath+'sync_off.png" title="'+SYNCOFFMSG+'"/>');
460}
461
462function showSyncOn(n,relpath)
463{
464    n.html('<img src="'+relpath+'sync_on.png" title="'+SYNCONMSG+'"/>');
465}
466
467function toggleSyncButton(relpath)
468{
469  var navSync = $('#nav-sync');
470  if (navSync.hasClass('sync')) {
471    navSync.removeClass('sync');
472    showSyncOff(navSync,relpath);
473    storeLink(stripPath2(pathName())+hashUrl());
474  } else {
475    navSync.addClass('sync');
476    showSyncOn(navSync,relpath);
477    deleteLink();
478  }
479}
480
481var loadTriggered = false;
482var readyTriggered = false;
483var loadObject,loadToRoot,loadUrl,loadRelPath;
484
485$(window).on('load',function(){
486  if (readyTriggered) { // ready first
487    navTo(loadObject,loadToRoot,loadUrl,loadRelPath);
488    showRoot();
489  }
490  loadTriggered=true;
491});
492
493function initNavTree(toroot,relpath)
494{
495  var o = new Object();
496  o.toroot = toroot;
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);
504  o.node.depth = 0;
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;
511
512  if (localStorageSupported()) {
513    var navSync = $('#nav-sync');
514    if (cachedLink()) {
515      showSyncOff(navSync,relpath);
516      navSync.removeClass('sync');
517    } else {
518      showSyncOn(navSync,relpath);
519    }
520    navSync.click(function(){ toggleSyncButton(relpath); });
521  }
522
523  if (loadTriggered) { // load before ready
524    navTo(o,toroot,hashUrl(),relpath);
525    showRoot();
526  } else { // ready before load
527    loadObject  = o;
528    loadToRoot  = toroot;
529    loadUrl     = hashUrl();
530    loadRelPath = relpath;
531    readyTriggered=true;
532  }
533
534  $(window).bind('hashchange', function(){
535     if (window.location.hash && window.location.hash.length>1){
536       var a;
537       if ($(location).attr('hash')){
538         var clslink=stripPath(pathName())+':'+hashValue();
539         a=$('.item a[class$="'+clslink.replace(/</g,'\\3c ')+'"]');
540       }
541       if (a==null || !$(a).parent().parent().hasClass('selected')){
542         $('.item').removeClass('selected');
543         $('.item').removeAttr('id');
544       }
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);
552     }
553  })
554}
555/* @license-end */
556