istio.io/js/navtree.min.js

6 lines
2.6 KiB
JavaScript

---
---
{% assign home = site.baseurl %}
function makeNavTree(e,t,n){for(var r=[],o=0;o<t.length;o++){var l=t[o],c=l.path[n];if("index.md"!=c){for(var i=null,d=0;d<r.length;d++)if(r[d].name===c){i=r[d];break}null===i&&(i={name:c,doc:null,children:[]},r.push(i)),l.path.length>n+1?i.children.push(l):i.doc=l}else null!=e&&(e.doc=l)}for(o=0;o<r.length;o++)i=r[o],i.children=makeNavTree(i,i.children,n+1);return r.sort(function(e,t){return e.doc.order<t.doc.order?-1:e.doc.order>t.doc.order?1:0}),r}function outputNavBarTree(e){document.writeln("<ul class='list-unstyled tree'>");for(var t=0;t<e.length;t++){var n=e[t];0==n.children.length&&(n.doc.url==location.pathname?document.write("<li class='doc-side-nav-list-item'><a class='current' href='"):document.write("<li class='doc-side-nav-list-item'><a href='"),document.write("{{home}}"),document.write(n.doc.url),document.write("'>"),document.write(n.doc.title),document.writeln("</a>"),9999==n.doc.order&&document.writeln("(please set order: front matter for this document)"),document.writeln("</li>"))}for(var t=0;t<e.length;t++){var n=e[t];n.children.length>0&&(document.writeln("<li class='doc-side-nav-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==n.doc?document.writeln(n.name):document.writeln(n.doc.title),document.writeln("</a>"),document.writeln("</label>"),9999==n.doc.order&&document.writeln("(please set order: front matter for this document)"),outputNavBarTree(n.children),document.writeln("</li>"))}document.writeln("</ul>")}function genNavBarTree(e){var t=makeNavTree(null,e,0);outputNavBarTree(t)}function outputSectionNavTree(e){document.writeln("<ul>");for(var t=0;t<e.length;t++){var n=e[t];0==n.children.length&&(document.write("<li class='file'>"),document.write("<a href='{{home}}"),document.write(n.doc.url),document.write("'>"),document.write(n.doc.title),document.write("</a>. "+n.doc.overview),document.writeln("</li>"))}for(var t=0;t<e.length;t++){var n=e[t];n.children.length>0&&(document.write("<li class='directory'>"),null==n.doc?document.writeln(n.name):(document.write("<a href='"),document.write("{{home}}"),document.write(n.doc.url),document.write("'>"),document.write(n.doc.title),document.write("</a>"),document.writeln("")),outputSectionNavTree(n.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>")}