PageSourceSearch

https://js8call.com/JS8Call-improved/navtree.js

js js8call.com collected 2026-09-24 09:32:52 UTC 33,741 bytes, 901 lines download raw bytes

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 */
25
26function initNavTree(toroot,relpath,allMembersFile) {
27  let navTreeSubIndices = [];
28  const ARROW_DOWN = '<span class="arrowhead opened"></span>';
29  const ARROW_RIGHT = '<span class="arrowhead closed"></span>';
30  const NAVPATH_COOKIE_NAME = ''+'navpath';
31  const fullSidebar = typeof page_layout!=='undefined' && page_layout==1;
32
33  function getScrollBarWidth () {
34    let outer = $('<div>').css({visibility: 'hidden', width: 100, overflow: 'scroll', scrollbarWidth: 'thin'}).appendTo('body');
35    let widthWithScroll = $('<div>').css({width: '100%'}).appendTo(outer).outerWidth();
36    outer.remove();
37    return 100 - widthWithScroll;
38  }
39  const scrollbarWidth = getScrollBarWidth();
40
41  function adjustSyncIconPosition() {
42    if (!fullSidebar) {
43      const nt = document.getElementById("nav-tree");
44      const hasVerticalScrollbar = nt.scrollHeight > nt.clientHeight;
45      $("#nav-sync").css({right:parseInt(hasVerticalScrollbar?scrollbarWidth:0)});
46    }
47  }
48
49  const getData = function(varName) {
50    const i = varName.lastIndexOf('/');
51    const n = i>=0 ? varName.substring(i+1) : varName;
52    const e = n.replace(/-/g,'_');
53    return window[e];
54  }
55
56  const stripPath = function(uri) {
57    return uri.substring(uri.lastIndexOf('/')+1);
58  }
59
60  const stripPath2 = function(uri) {
61    const i = uri.lastIndexOf('/');
62    const s = uri.substring(i+1);
63    const m = uri.substring(0,i+1).match(/\/d\w\/d\w\w\/$/);
64    return m ? uri.substring(i-6) : s;
65  }
66
67  const hashValue = function() {
68    return $(location).attr('hash').substring(1).replace(/[^\w-]/g,'');
69  }
70
71  const hashUrl = function() {
72    return '#'+hashValue();
73  }
74
75  const pathName = function() {
76    return $(location).attr('pathname').replace(/[^-A-Za-z0-9+&@#/%?=~_|!:,.;()]/g, '');
77  }
78
79  const storeLink = function(link) {
80    if (!$("#nav-sync").hasClass('sync')) {
81      Cookie.writeSetting(NAVPATH_COOKIE_NAME,link,0);
82    }
83  }
84
85  const deleteLink = function() {
86    Cookie.eraseSetting(NAVPATH_COOKIE_NAME);
87  }
88
89  const cachedLink = function() {
90    return Cookie.readSetting(NAVPATH_COOKIE_NAME,'');
91  }
92
93  const getScript = function(scriptName,func) {
94    const head = document.getElementsByTagName("head")[0];
95    const script = document.createElement('script');
96    script.id = scriptName;
97    script.type = 'text/javascript';
98    script.onload = function() { func(); adjustSyncIconPosition(); }
99    script.src = scriptName+'.js';
100    head.appendChild(script);
101  }
102
103  const createIndent = function(o,domNode,node) {
104    let level=-1;
105    let n = node;
106    while (n.parentNode) { level++; n=n.parentNode; }
107    if (node.childrenData) {
108      const imgNode = document.createElement("span");
109      imgNode.className = 'arrow';
110      imgNode.style.paddingLeft=(16*level).toString()+'px';
111      imgNode.innerHTML=ARROW_RIGHT;
112      node.plus_img = imgNode;
113      node.expandToggle = document.createElement("a");
114      node.expandToggle.href = "javascript:void(0)";
115      node.expandToggle.onclick = function() {
116        if (node.expanded) {
117          $(node.getChildrenUL()).slideUp("fast",adjustSyncIconPosition);
118          $(node.plus_img.childNodes[0]).removeClass('opened').addClass('closed');
119          node.expanded = false;
120        } else {
121          expandNode(o, node, false, true);
122        }
123      }
124      node.expandToggle.appendChild(imgNode);
125      domNode.appendChild(node.expandToggle);
126    } else {
127      let span = document.createElement("span");
128      span.className = 'arrow';
129      span.style.width   = 16*(level+1)+'px';
130      span.innerHTML = '&#160;';
131      domNode.appendChild(span);
132    }
133  }
134
135  let animationInProgress = false;
136
137  const gotoAnchor = function(anchor,aname) {
138    let pos, docContent = $('#doc-content');
139    let ancParent = $(anchor.parent());
140    if (ancParent.hasClass('memItemLeft') || ancParent.hasClass('memtitle')  ||
141        ancParent.hasClass('fieldname')   || ancParent.hasClass('fieldtype') ||
142        ancParent.is(':header')) {
143      pos = ancParent.offset().top;
144    } else if (anchor.position()) {
145      pos = anchor.offset().top;
146    }
147    if (pos) {
148      const dcOffset    = docContent.offset().top;
149      const dcHeight    = docContent.height();
150      const dcScrHeight = docContent[0].scrollHeight
151      const dcScrTop    = docContent.scrollTop();
152      let dist = Math.abs(Math.min(pos-dcOffset,dcScrHeight-dcHeight-dcScrTop));
153      animationInProgress = true;
154      docContent.animate({
155        scrollTop: pos + dcScrTop - dcOffset
156      },Math.max(50,Math.min(500,dist)),function() {
157        animationInProgress=false;
158        if (anchor.parent().attr('class')=='memItemLeft') {
159          let rows = $('.memberdecls tr[class$="'+hashValue()+'"]');
160          glowEffect(rows.children(),300); // member without details
161        } else if (anchor.parent().attr('class')=='fieldname') {
162          glowEffect(anchor.parent().parent(),1000); // enum value
163        } else if (anchor.parent().attr('class')=='fieldtype') {
164          glowEffect(anchor.parent().parent(),1000); // struct field
165        } else if (anchor.parent().is(":header")) {
166          glowEffect(anchor.parent(),1000); // section header
167        } else {
168          glowEffect(anchor.next(),1000); // normal member
169        }
170      });
171    }
172  }
173
174  function htmlToNode(html) {
175    const template = document.createElement('template');
176    template.innerHTML = html;
177    const nNodes = template.content.childNodes.length;
178    if (nNodes !== 1) {
179        throw new Error(`html parameter must represent a single node; got ${nNodes}. `);
180    }
181    return template.content.firstChild;
182  }
183
184  const newNode = function(o, po, text, link, childrenData, lastNode) {
185    const node = {
186      children     : [],
187      childrenData : childrenData,
188      depth        : po.depth + 1,
189      relpath      : po.relpath,
190      isLast       : lastNode,
191      li           : document.createElement("li"),
192      parentNode   : po,
193      itemDiv      : document.createElement("div"),
194      labelSpan    : document.createElement("span"),
195      expanded     : false,
196      childrenUL   : null,
197      getChildrenUL : function() {
198        if (!this.childrenUL) {
199          this.childrenUL = document.createElement("ul");
200          this.childrenUL.className = "children_ul";
201          this.childrenUL.style.display = "none";
202          this.li.appendChild(node.childrenUL);
203        }
204        return node.childrenUL;
205      },
206    };
207
208    node.itemDiv.className = "item";
209    node.labelSpan.className = "label";
210    createIndent(o,node.itemDiv,node);
211    node.itemDiv.appendChild(node.labelSpan);
212    node.li.appendChild(node.itemDiv);
213
214    const a = document.createElement("a");
215    node.labelSpan.appendChild(a);
216    po.getChildrenUL().appendChild(node.li);
217    a.appendChild(htmlToNode('<span>'+text+'</span>'));
218    if (link) {
219      let url;
220      if (link.substring(0,1)=='^') {
221        url = link.substring(1);
222        link = url;
223      } else {
224        url = node.relpath+link;
225      }
226      a.className = stripPath(link.replace('#',':'));
227      if (link.indexOf('#')!=-1) {
228        const aname = '#'+link.split('#')[1];
229        const srcPage = stripPath(pathName());
230        const targetPage = stripPath(link.split('#')[0]);
231        a.href = srcPage!=targetPage ? url : aname;
232        a.onclick = function() {
233          storeLink(link);
234          aPPar = $(a).parent().parent();
235          if (!aPPar.hasClass('selected')) {
236            $('.item').removeClass('selected');
237            $('.item').removeAttr('id');
238            aPPar.addClass('selected');
239            aPPar.attr('id','selected');
240          }
241          const anchor = $(aname);
242          gotoAnchor(anchor,aname);
243        };
244      } else {
245        a.href = url;
246        a.onclick = () => storeLink(link);
247      }
248    } else if (childrenData != null) {
249      a.className = "nolink";
250      a.href = "javascript:void(0)";
251      a.onclick = node.expandToggle.onclick;
252    }
253    return node;
254  }
255
256  const showRoot = function() {
257    const headerHeight = $("#top").height();
258    const footerHeight = $("#nav-path").height();
259    const windowHeight = $(window).height() - headerHeight - footerHeight;
260    (function() { // retry until we can scroll to the selected item
261      try {
262        const navtree=$('#nav-tree');
263        navtree.scrollTo('#selected',100,{offset:-windowHeight/2});
264      } catch (err) {
265        setTimeout(arguments.callee, 0);
266      }
267    })();
268  }
269
270  const expandNode = function(o, node, imm, setFocus) {
271    if (node.childrenData && !node.expanded) {
272      if (typeof(node.childrenData)==='string') {
273        const varName = node.childrenData;
274        getScript(node.relpath+varName,function() {
275          node.childrenData = getData(varName);
276          expandNode(o, node, imm, setFocus);
277        });
278      } else {
279        if (!node.childrenVisited) {
280          getNode(o, node);
281        }
282        $(node.getChildrenUL()).slideDown("fast",adjustSyncIconPosition);
283        $(node.plus_img.childNodes[0]).addClass('opened').removeClass('closed');
284        node.expanded = true;
285        if (setFocus) {
286          $(node.expandToggle).focus();
287        }
288      }
289    }
290  }
291
292  const glowEffect = function(n,duration) {
293    n.addClass('glow').delay(duration).queue(function(next) {
294      $(this).removeClass('glow');next();
295    });
296  }
297
298  const highlightAnchor = function() {
299    const aname = hashUrl();
300    const anchor = $(aname);
301    gotoAnchor(anchor,aname);
302  }
303
304  const selectAndHighlight = function(hash,n) {
305    let a;
306    if (hash) {
307      const link=stripPath(pathName())+':'+hash.substring(1);
308      a=$('.item a[class$="'+link+'"]');
309    }
310    if (a && a.length) {
311      a.parent().parent().addClass('selected');
312      a.parent().parent().attr('id','selected');
313      highlightAnchor();
314    } else if (n) {
315      $(n.itemDiv).addClass('selected');
316      $(n.itemDiv).attr('id','selected');
317    }
318    let topOffset=5;
319    if ($('#nav-tree-contents .item:first').hasClass('selected')) {
320      topOffset+=25;
321    }
322    showRoot();
323  }
324
325  const showNode = function(o, node, index, hash) {
326    if (node && node.childrenData) {
327      if (typeof(node.childrenData)==='string') {
328        const varName = node.childrenData;
329        getScript(node.relpath+varName,function() {
330          node.childrenData = getData(varName);
331          showNode(o,node,index,hash);
332        });
333      } else {
334        if (!node.childrenVisited) {
335          getNode(o, node);
336        }
337        $(node.getChildrenUL()).css({'display':'block'});
338        $(node.plus_img.childNodes[0]).removeClass('closed').addClass('opened');
339        node.expanded = true;
340        const n = node.children[o.breadcrumbs[index]];
341        if (index+1<o.breadcrumbs.length) {
342          showNode(o,n,index+1,hash);
343        } else if (typeof(n.childrenData)==='string') {
344          const varName = n.childrenData;
345          getScript(n.relpath+varName,function() {
346            n.childrenData = getData(varName);
347            node.expanded=false;
348            showNode(o,node,index,hash); // retry with child node expanded
349          });
350        } else {
351          const rootBase = stripPath(o.toroot.replace(/\..+$/, ''));
352          if (rootBase=="index" || rootBase=="pages" || rootBase=="search") {
353            expandNode(o, n, true, false);
354          }
355          selectAndHighlight(hash,n);
356        }
357      }
358    } else {
359      selectAndHighlight(hash);
360    }
361  }
362
363  const getNode = function(o, po) {
364    po.childrenVisited = true;
365    const l = po.childrenData.length-1;
366    for (let i in po.childrenData) {
367      const nodeData = po.childrenData[i];
368      po.children[i] = newNode(o, po, nodeData[0], nodeData[1], nodeData[2], i==l);
369    }
370  }
371
372  const gotoNode = function(o,subIndex,root,hash,relpath) {
373    const nti = navTreeSubIndices[subIndex][root+hash];
374    if (nti==undefined && hash.length>0) { // try root page without hash as fallback
375      gotoUrl(o,root,'',relpath);
376    } else {
377      o.breadcrumbs = $.extend(true, [], nti);
378      if (!o.breadcrumbs && root!=NAVTREE[0][1]) { // fallback: show index
379        navTo(o,NAVTREE[0][1],"",relpath);
380        $('.item').removeClass('selected');
381        $('.item').removeAttr('id');
382      }
383      if (o.breadcrumbs) {
384        o.breadcrumbs.unshift(0); // add 0 for root node
385        showNode(o, o.node, 0, hash);
386      }
387    }
388  }
389
390  const gotoUrl = function(o,root,hash,relpath) {
391    const url=root+hash;
392    let i=-1;
393    while (NAVTREEINDEX[i+1]<=url) i++;
394    if (i==-1) { i=0; root=NAVTREE[0][1]; } // fallback: show index
395    if (navTreeSubIndices[i]) {
396      gotoNode(o,i,root,hash,relpath)
397    } else {
398      getScript(relpath+'navtreeindex'+i,function() {
399        navTreeSubIndices[i] = window['NAVTREEINDEX'+i];
400        if (navTreeSubIndices[i]) {
401          gotoNode(o,i,root,hash,relpath);
402        }
403      });
404    }
405  }
406
407  const navTo = function(o,root,hash,relpath) {
408    const link = cachedLink();
409    if (link) {
410      const parts = link.split('#');
411      root = parts[0];
412      hash = parts.length>1 ? '#'+parts[1].replace(/[^\w-]/g,'') : '';
413    }
414    if (hash.match(/^#l\d+$/)) {
415      const anchor=$('a[name='+hash.substring(1)+']');
416      glowEffect(anchor.parent(),1000); // line number
417      hash='';
417 // strip line number anchors
418    }
419    gotoUrl(o,root,hash,relpath);
420  }
421
422  const showSyncOff = function(n,relpath) {
423    n.html('<div class="nav-sync-icon" title="'+SYNCOFFMSG+'"><span class="sync-icon-left"></span><span class="sync-icon-right"></span></div>');
424  }
425
426  const showSyncOn = function(n,relpath) {
427    n.html('<div class="nav-sync-icon active" title="'+SYNCONMSG+'"><span class="sync-icon-left"></span><span class="sync-icon-right"></span></div>');
428  }
429
430  const o = {
431    toroot : toroot,
432    node   : {
433      childrenData  : NAVTREE,
434      children      : [],
435      childrenUL    : document.createElement("ul"),
436      getChildrenUL : function() { return this.childrenUL },
437      li            : document.getElementById("nav-tree-contents"),
438      depth         : 0,
439      relpath       : relpath,
440      expanded      : false,
441      isLast        : true,
442      plus_img      : document.createElement("span"),
443    },
444  };
445  o.node.li.appendChild(o.node.childrenUL);
446  o.node.plus_img.className = 'arrow';
447  o.node.plus_img.innerHTML = ARROW_RIGHT;
448
449  const navSync = $('#nav-sync');
450  if (cachedLink()) {
451    showSyncOff(navSync,relpath);
452    navSync.removeClass('sync');
453  } else {
454    showSyncOn(navSync,relpath);
455  }
456
457  navSync.click(() => {
458    const navSync = $('#nav-sync');
459    if (navSync.hasClass('sync')) {
460      navSync.removeClass('sync');
461      showSyncOff(navSync,relpath);
462      storeLink(stripPath2(pathName())+hashUrl());
463    } else {
464      navSync.addClass('sync');
465      showSyncOn(navSync,relpath);
466      deleteLink();
467    }
468  });
469
470  navTo(o,toroot,hashUrl(),relpath);
471  showRoot();
472
473  $(window).bind('hashchange', () => {
474    if (!animationInProgress) {
475      if (window.location.hash && window.location.hash.length>1) {
476        let a;
477        if ($(location).attr('hash')) {
478          const clslink=stripPath(pathName())+':'+hashValue();
479          a=$('.item a[class$="'+clslink.replace(/</g,'\\3c ')+'"]');
480        }
481        if (a==null || !$(a).parent().parent().hasClass('selected')) {
482          $('.item').removeClass('selected');
483          $('.item').removeAttr('id');
484        }
485        const link=stripPath2(pathName());
486        navTo(o,link,hashUrl(),relpath);
487        } else {
488        $('#doc-content').scrollTop(0);
489        $('.item').removeClass('selected');
490        $('.item').removeAttr('id');
491        navTo(o,toroot,hashUrl(),relpath);
492      }
493    }
494  });
495
496  $(window).resize(function() { adjustSyncIconPosition(); });
497
498  let navtree_trampoline = {
499    updateContentTop : function() {}
500  }
501
502  function initResizable() {
503    let sidenav,mainnav,pagenav,container,navtree,content,header,footer,barWidth=6;
504    const RESIZE_COOKIE_NAME = ''+'width';
505    const PAGENAV_COOKIE_NAME = ''+'pagenav';
506    const fullSidebar = typeof page_layout!=='undefined' && page_layout==1;
507
508    function showHideNavBar() {
509      let bar = $('div.sm-dox');
510      if (fullSidebar && mainnav && bar) {
511        if (mainnav.width()<768) {
512          bar.hide();
513        } else {
514          bar.show();
515        }
516      }
517    }
518
519    function constrainPanelWidths(leftPanelWidth,rightPanelWidth,dragLeft) {
520      const contentWidth = container.width()-leftPanelWidth-rightPanelWidth;
521      const minContentWidth = 250;
522      const minPanelWidth = barWidth;
523      if (contentWidth<minContentWidth) // need to shrink panels
524      {
525        const deficit = minContentWidth - contentWidth;
526        if (dragLeft) { // dragging left handle -> try to keep right panel width
527          const shrinkLeft = Math.min(deficit, leftPanelWidth-minPanelWidth);
528          leftPanelWidth -= shrinkLeft;
529          const remainingDeficit = deficit - shrinkLeft;
530          const shrinkRight = Math.min(remainingDeficit, rightPanelWidth-minPanelWidth);
531          rightPanelWidth -= shrinkRight;
532        } else { // dragging right handle -> try to keep left panel width
533          const shrinkRight = Math.min(deficit, rightPanelWidth-minPanelWidth);
534          rightPanelWidth -= shrinkRight;
535          const remainingDeficit = deficit - shrinkRight;
536          const shrinkLeft = Math.min(remainingDeficit, leftPanelWidth-minPanelWidth);
537          leftPanelWidth -= shrinkLeft;
538        }
539      } else {
540        rightPanelWidth = pagenav.length ? Math.max(minPanelWidth,rightPanelWidth) : 0;
541        leftPanelWidth = Math.max(minPanelWidth,leftPanelWidth);
542        }
543      return { leftPanelWidth, rightPanelWidth }
544    }
545
546    function updateWidths(sidenavWidth,pagenavWidth,dragLeft)
547    {
548      const widths = constrainPanelWidths(sidenavWidth,pagenavWidth,dragLeft);
549      const widthStr = parseFloat(widths.leftPanelWidth)+"px";
550      content.css({marginLeft:widthStr});
551      if (fullSidebar) {
552        footer.css({marginLeft:widthStr});
553        if (mainnav) {
554          mainnav.css({marginLeft:widthStr});
555        }
556      }
557      sidenav.css({width:widthStr});
558      if (pagenav.length) {
559        container.css({gridTemplateColumns:'auto '+parseFloat(widths.rightPanelWidth)+'px'});
560        if (!dragLeft) {
561          pagenav.css({width:parseFloat(widths.rightPanelWidth-1)+'px'});
562        }
563      }
564      return widths;
565    }
566
567    function resizeWidth(dragLeft) {
568      const sidenavWidth = $(sidenav).outerWidth()-barWidth;
569      let pagenavWidth = pagenav.length ? $(pagenav).outerWidth() : 0;
570      const widths = updateWidths(sidenavWidth,pagenavWidth,dragLeft);
571      Cookie.writeSetting(RESIZE_COOKIE_NAME,widths.leftPanelWidth-barWidth);
572      if (pagenav.length) {
573        Cookie.writeSetting(PAGENAV_COOKIE_NAME,widths.rightPanelWidth);
574      }
575    }
576
577    function restoreWidth(sidenavWidth,pagenavWidth) {
578      updateWidths(sidenavWidth,pagenavWidth,false);
579      showHideNavBar();
580    }
581
582    function resizeHeight() {
583      const headerHeight = header.outerHeight();
584      const windowHeight = $(window).height();
585      let contentHeight;
586      const footerHeight = footer.outerHeight();
587      let navtreeHeight,sideNavHeight;
588      if (!fullSidebar) {
589        contentHeight = windowHeight - headerHeight - footerHeight - 1;
590        navtreeHeight = contentHeight;
591        sideNavHeight = contentHeight;
592      } else if (fullSidebar) {
593        contentHeight = windowHeight - footerHeight - 1;
594        navtreeHeight = windowHeight - headerHeight - 1;
595        sideNavHeight = windowHeight - 1;
596        if (mainnav) {
597          contentHeight -= mainnav.outerHeight();
598        }
599      }
600      navtree.css({height:navtreeHeight + "px"});
601      sidenav.css({height:sideNavHeight + "px"});
602      content.css({height:contentHeight + "px"});
603      resizeWidth(false);
604      showHideNavBar();
605      if (location.hash.slice(1)) {
606        (document.getElementById(location.hash.slice(1))||document.body).scrollIntoView();
607      }
608    }
609
610    header  = $("#top");
611    content = $("#doc-content");
612    footer  = $("#nav-path");
613    sidenav = $("#side-nav");
614    if (document.getElementById('main-nav')) {
615      mainnav = $("#main-nav");
616    }
617    navtree = $("#nav-tree");
618    pagenav   = $("#page-nav");
619    container = $("#container");
620    $(".side-nav-resizable").resizable({resize: function(e, ui) { resizeWidth(true); } });
621    $(sidenav).resizable({ minWidth: 0 });
622    if (pagenav.length) {
623      pagehandle  = $("#page-nav-resize-handle");
624      pagehandle.on('mousedown touchstart',function(e) { 
625         $('body').addClass('resizing');
626         pagehandle.addClass('dragging');
627         $(document).on('mousemove touchmove',function(e) {
628           const clientX = e.clientX || e.originalEvent.touches[0].clientX;
629           let pagenavWidth = container[0].offsetWidth-clientX+barWidth/2;
630           const sidenavWidth = sidenav.width();
631           const widths = constrainPanelWidths(sidenavWidth,pagenavWidth,false);
632           container.css({gridTemplateColumns:'auto '+parseFloat(widths.rightPanelWidth)+'px'});
633           pagenav.css({width:parseFloat(widths.rightPanelWidth-1)+'px'});
634           content.css({marginLeft:parseFloat(widths.leftPanelWidth)+'px'});
635           Cookie.writeSetting(PAGENAV_COOKIE_NAME,pagenavWidth);
636         });
637         $(document).on('mouseup touchend', function(e) {
638           $('body').removeClass('resizing');
639           pagehandle.removeClass('dragging');
640           $(document).off('mousemove mouseup touchmove touchend');
641         });
642      });
643    } else {
644      container.css({gridTemplateColumns:'auto'});
645    }
646    const width = parseInt(Cookie.readSetting(RESIZE_COOKIE_NAME,250));
647    const pagenavWidth = parseInt(Cookie.readSetting(PAGENAV_COOKIE_NAME,250));
648    if (width) { restoreWidth(width+barWidth,pagenavWidth); } else { resizeWidth(); }
649    const url = location.href;
650    const i=url.indexOf("#");
651    if (i>=0) window.location.hash=url.substr(i);
652    const _preventDefault = function(evt) { evt.preventDefault(); };
653    $("#splitbar").bind("dragstart", _preventDefault).bind("selectstart", _preventDefault);
654    $(window).ready(function() {
655      let lastWidth = -1;
656      let lastHeight = -1;
657      $(window).resize(function() {
658          const newWidth  = $(this).width(), newHeight = $(this).height();
659          if (newWidth!=lastWidth || newHeight!=lastHeight) {
660            resizeHeight();
661            navtree_trampoline.updateContentTop();
662            lastWidth = newWidth;
663            lastHeight = newHeight;
664          }
665      });
666      resizeHeight();
667      lastWidth = $(window).width();
668      lastHeight = $(window).height();
669      content.scroll(function() {
670        navtree_trampoline.updateContentTop();
671      });
672    });
673  }
674
675
676  function initPageToc() {
677    const topMapping = [];
678    const toc_contents = $('#page-nav-contents');
679    const content=$('<ul>').addClass('page-outline');
680
681    var entityMap = {
682      '&': '&amp;',
683      '<': '&lt;',
684      '>': '&gt;',
685      '"': '&quot;',
686      "'": '&#39;',
687      '/': '&#x2F;',
688      '`': '&#x60;',
689      '=': '&#x3D;'
690    };
691    function escapeHtml (string) {
692      return String(string).replace(/[&<>"'`=\/]/g, function (s) {
693        return entityMap[s];
694      });
695    }
696
697    // for ClassDef/GroupDef/ModuleDef/ConceptDef/DirDef
698    const groupSections = [];
699    let currentGroup = null;
700    $('h2.groupheader, h2.memtitle').each(function(){
701      const $element = $(this);
702      if ($element.hasClass('groupheader')) {
703        currentGroup = { groupHeader: $element, memTitles: [] };
704        groupSections.push(currentGroup);
705      } else if ($element.hasClass('memtitle') && currentGroup) {
706        currentGroup.memTitles.push($element);
707      }
708    });
709    groupSections.forEach(function(item){
710      const title = item.groupHeader.text().trim();
711      let id = item.groupHeader.attr('id');
712      const table = item.groupHeader.parents('table.memberdecls');
713      let rows = $();
714      if (table.length>0) {
715        rows = table.find("tr[class^='memitem:'] td.memItemRight, tr[class^='memitem:'] td.memItemLeft.anon, tr[class=groupHeader] td");
716      }
717      function hasSubItems() {
718        return item.memTitles.length>0 || rows.toArray().some(function(el) { return $(el).is(':visible'); });
719      }
720      const li = $('<li>').attr('id','nav-'+id);
721      const div = $('<div>').addClass('item');
722      const span = $('<span>').addClass('arrow').css({ paddingLeft:'0' });
723      if (hasSubItems()) {
724        span.append($('<span>').addClass('arrowhead opened'));
725      }
726      const ahref = $('<a>').attr('href','#'+id).append(title);
727      content.append(li.append(div.append(span).append(ahref)));
728      topMapping.push(id);
729      const ulStack = [];
730      ulStack.push(content);
731      if (hasSubItems()) {
732        let last_id = undefined;
733        let inMemberGroup = false;
734        // declaration sections have rows for items
735        rows.each(function(){
736          let td = $(this);
737          let tr = $(td).parent();
738          const is_anon_enum = td.contents().first().text().trim()=='{';
739          if (tr.hasClass('template')) {
740            tr = tr.prev();
741          }
742          id = $(tr).attr('id');
743          let text = is_anon_enum ? 'anonymous enum' : $(this).find(':first-child').text();
744          let isMemberGroupHeader = $(tr).hasClass('groupHeader');
745          if ($(tr).is(":visible") && last_id!=id && id!==undefined) {
746            if (isMemberGroupHeader && inMemberGroup) {
747              ulStack.pop();
748              inMemberGroup=false;
749            }
750            const li2 = $('<li>').attr('id','nav-'+id);
751            const div2 = $('<div>').addClass('item');
752            const span2 = $('<span>').addClass('arrow').css({ paddingLeft:parseInt(ulStack.length*16)+'px' });
753            const ahref = $('<a>').attr('href','#'+id).append(escapeHtml(text));
754            li2.append(div2.append(span2).append(ahref));
755            topMapping.push(id);
756            if (isMemberGroupHeader) {
757              span2.append($('<span>').addClass('arrowhead opened'));
758              ulStack[ulStack.length-1].append(li2);
759              const ul2 = $('<ul>');
760              ulStack.push(ul2);
761              li2.append(div2).append(ul2);
762              inMemberGroup=true;
763            } else {
764              ulStack[ulStack.length-1].append(li2);
765            }
766            last_id=id;
767          }
768        });
769        // detailed documentation has h2.memtitle sections for items
770        item.memTitles.forEach(function(data) {
771          const text = $(data).contents().not($(data).children().first()).text();
772          const name = text.replace(/\(\)(\s*\[\d+\/\d+\])?$/, '') // func() [2/8] -> func
773          id = $(data).find('span.permalink a').attr('href')
774          if (id!==undefined && name!==undefined) {
775            const li2 = $('<li>').attr('id','nav-'+id.substring(1));
776            const div2 = $('<div>').addClass('item');
777            const span2 = $('<span>').addClass('arrow').css({paddingLeft:parseInt(ulStack.length*16)+'px'});
778            const ahref = $('<a>').attr('href',id).append(escapeHtml(name));
779            ulStack[ulStack.length-1].append(li2.append(div2.append(span2).append(ahref)));
780            topMapping.push(id.substring(1));
781          }
782        });
783      }
784    });
785    if (allMembersFile.length) { // add entry linking to all members page
786      const url = location.href;
787      let srcBaseUrl = '';
788      let dstBaseUrl = '';
789      if (relpath.length) { // CREATE_SUBDIRS=YES -> find target location
790        srcBaseUrl = url.substring(0, url.lastIndexOf('/')) + '/' + relpath;
791        dstBaseUrl = allMembersFile.substr(0, allMembersFile.lastIndexOf('/'))+'/';
792      }
793      const pageName = url.split('/').pop().split('#')[0].replace(/(\.[^/.]+)$/, '-members$1');
794      const li = $('<li>');
795      const div = $('<div>').addClass('item');
796      const span = $('<span>').addClass('arrow').css({ paddingLeft:'0' });
797      const ahref = $('<a>').attr('href',srcBaseUrl+dstBaseUrl+pageName).addClass('noscroll');
798      content.append(li.append(div.append(span).append(ahref.append(LISTOFALLMEMBERS))));
799    }
800
801    if (groupSections.length==0) {
802      // for PageDef
803      const sectionTree = [], sectionStack = [];
804      $('h1.doxsection, h2.doxsection, h3.doxsection, h4.doxsection, h5.doxsection, h6.doxsection').each(function(){
805        const level = parseInt(this.tagName[1]);
806        const anchor = $(this).find('a.anchor').attr('id');
807        const node = { text: $(this).html(), id: anchor, children: [] };
808        while (sectionStack.length && sectionStack[sectionStack.length - 1].level >= level) sectionStack.pop();
809        (sectionStack.length ? sectionStack[sectionStack.length - 1].children : sectionTree).push(node);
810        sectionStack.push({ ...node, level });
811      });
812      if (sectionTree.length>0) {
813        function render(nodes, level=0) {
814          nodes.map(n => {
815            const li = $('<li>').attr('id','nav-'+n.id);
816            const div = $('<div>').addClass('item');
817            const span = $('<span>').addClass('arrow').attr('style','padding-left:'+parseInt(level*16)+'px;');
818            if (n.children.length > 0) { span.append($('<span>').addClass('arrowhead opened')); }
819            const url = $('<a>').attr('href','#'+n.id);
820            content.append(li.append(div.append(span).append(url.append(n.text))));
821            topMapping.push(n.id);
822            render(n.children,level+1);
823          });
824        }
825        render(sectionTree);
826      }
827    }
828
829    toc_contents.append(content);
830
831    $(".page-outline a[href]:not(.noscroll)").click(function(e) {
832      e.preventDefault();
833      const aname = $(this).attr("href");
834      gotoAnchor($(aname),aname);
835    });
836
837    let lastScrollSourceOffset = -1;
838    let lastScrollTargetOffset = -1;
839    let lastScrollTargetId = '';
840
841    navtree_trampoline.updateContentTop = function() {
842      const pagenavcontents = $("#page-nav-contents");
843      if (pagenavcontents.length) {
844        const content = $("#doc-content");
845        const height = content.height();
846        const navy = pagenavcontents.offset().top;
847        const yc = content.offset().top;
848        let offsets = []
849        for (let i=0;i<topMapping.length;i++) {
850          const heading = $('#'+topMapping[i]);
851          if (heading.parent().hasClass('doxsection')) {
852            offsets.push({id:topMapping[i],y:heading.parent().offset().top-yc});
853          } else {
854            offsets.push({id:topMapping[i],y:heading.offset().top-yc});
855          }
856        }
857        offsets.push({id:'',y:1e10});
858        let scrollTarget = undefined, numItems=0;
859        for (let i=0;i<topMapping.length;i++) {
860          const ys = offsets[i].y;
861          const ye = offsets[i+1].y;
862          const id = offsets[i].id;
863          const nav = $('#nav-'+id);
864          const margin = 10; // #pixels before content show as visible
865          if ((ys>margin || ye>margin) && (ys<height-margin || ye<height-margin)) {
866            if (!scrollTarget) scrollTarget=nav;
867            nav.addClass('vis'); // mark navigation entry as visible within content area
868            numItems+=1;
869          } else {
870            nav.removeClass('vis');
871          }
872        }
873        const contentScrollOffset = $('div.contents').offset().top;
874        if (scrollTarget && lastScrollTargetId!=scrollTarget.attr('id')) { // new item to scroll to
875          const scrollDown = contentScrollOffset<lastScrollSourceOffset;
876          const range = 22*numItems;
877          const my = range/2-height/2;
878          const ulOffset = $('ul.page-outline').offset().top-navy;
879          const targetPos=scrollTarget.offset().top-navy-ulOffset;
880          const targetOffset=targetPos+my;
881          if ( (scrollDown && targetOffset>lastScrollTargetOffset) ||
882              (!scrollDown && targetOffset<lastScrollTargetOffset)) 
883          { // force panel to scroll in the same direction as content window
884            pagenavcontents.stop(); // avoid build-up of history
885            pagenavcontents.scrollTo({ left:0, top:targetOffset },{ duration: 500, interrupt: true });
886            lastScrollTargetOffset = targetOffset;
887          }
888          lastScrollTargetId = scrollTarget.attr('id');
889        }
890        lastScrollSourceOffset = contentScrollOffset;
891      }
892    }
893    // TODO: find out how to avoid a timeout
894    setTimeout(() => {
895      navtree_trampoline.updateContentTop();
896    },200);
897  }
898  $(document).ready(function() { initPageToc(); initResizable(); });
899
900}
901/* @license-end */

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.