istio.io/archive/v0.4/js/navtree.min.js

4 lines
2.5 KiB
JavaScript

function makeNavTree(e,t,r){for(var n=[],o=0;o<t.length;o++){var l=t[o],i=l.path[r];if("index.md"!=i){for(var c=null,d=0;d<n.length;d++)if(n[d].name===i){c=n[d];break}null===c&&(c={name:i,doc:null,children:[]},n.push(c)),l.path.length>r+1?c.children.push(l):c.doc=l}else null!=e&&(e.doc=l)}for(o=0;o<n.length;o++)(c=n[o]).children=makeNavTree(c,c.children,r+1);return n.sort(function(e,t){return e.doc.order<t.doc.order?-1:e.doc.order>t.doc.order?1:0}),n}function outputSideBarTree(e){document.writeln("<ul class='list-unstyled tree'>");for(var t=0;t<e.length;t++){0==(r=e[t]).children.length&&(r.doc.url==location.pathname?document.write("<li class='sidebar-list-item'><a class='current' href='"):document.write("<li class='sidebar-list-item'><a href='"),document.write("/v0.4"),document.write(r.doc.url),document.write("' title='"),document.write(r.doc.overview),document.write("'>"),document.write(r.doc.title),document.writeln("</a>"),9999==r.doc.order&&document.writeln("(please set order: front matter for this document)"),document.writeln("</li>"))}for(t=0;t<e.length;t++){var r;(r=e[t]).children.length>0&&(document.writeln("<li class='sidebar-list-item'>"),document.writeln("<label class='tree-toggle'>"),document.writeln("<i class='fa fa-lg fa-caret-down'></i>"),document.writeln("<a class='tree-toggle-link' href='javascript:void 0;'>"),null==r.doc?document.writeln(r.name):document.writeln(r.doc.title),document.writeln("</a>"),document.writeln("</label>"),9999==r.doc.order&&document.writeln("(please set order: front matter for this document)"),outputSideBarTree(r.children),document.writeln("</li>"))}document.writeln("</ul>")}function genSideBarTree(e){outputSideBarTree(makeNavTree(null,e,0))}function outputSectionNavTree(e){document.writeln("<ul>");for(var t=0;t<e.length;t++){0==(r=e[t]).children.length&&(document.write("<li class='file'>"),document.write("<a href='/v0.4"),document.write(r.doc.url),document.write("'>"),document.write(r.doc.title),document.write("</a>. "+r.doc.overview),document.writeln("</li>"))}for(t=0;t<e.length;t++){var r;(r=e[t]).children.length>0&&(document.write("<li class='directory'>"),null==r.doc?document.writeln(r.name):(document.write("<a href='"),document.write("/v0.4"),document.write(r.doc.url),document.write("'>"),document.write(r.doc.title),document.write("</a>"),document.writeln("")),outputSectionNavTree(r.children),document.writeln("</li>"))}document.writeln("</ul>")}function genSectionNavTree(e){var t=makeNavTree(null,e,0);document.writeln("<div class='section-index'>"),outputSectionNavTree(t),document.writeln("</div>")}