docsify/lib/docsify.min.js

3 lines
36 KiB
JavaScript
Raw Normal View History

2017-01-10 23:33:41 +08:00
var Docsify=function(){"use strict";function e(e,t,n){void 0===t&&(t="GET");var r=new XMLHttpRequest;return r.open(t,e),r.send(),{then:function(e,t){if(void 0===t&&(t=function(){}),n){var a=setInterval(function(e){return n({step:Math.floor(5*Math.random()+1)})},500);r.addEventListener("progress",n),r.addEventListener("loadend",function(e){n(e),clearInterval(a)})}r.addEventListener("error",t),r.addEventListener("load",function(n){var r=n.target;r.status>=400?t(r):e(r.response)})},abort:function(){return 4!==r.readyState&&r.abort()}}}function t(e,t){var n=[],r={};return e.forEach(function(e){var a=e.level||1,i=a-1;a>t||(r[i]?(r[i].children=r[i].children||[],r[i].children.push(e)):n.push(e),r[a]=e)}),n}function n(e){return e.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}function r(e){return null===e||void 0===e}function a(){var e=window.location;if(E===e.hash&&!r($))return $;var t=e.hash.match(/^#\/([^#]+)/);return t=t&&2===t.length?t[1]:/^#\//.test(e.hash)?"":e.pathname,$=t,E=e.hash,t}function i(){return document.body.clientWidth<=600}function s(e){var t=/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,.\/:;<=>?@\[\]^`{|}~]/g,n=!1,r="-";if(s.occurrences=s.occurrences||{},"string"!=typeof e)return"";n||(e=e.toLowerCase());var a=e.trim().replace(/<[^>\d]+>/g,"").replace(t,"").replace(/\s/g,r).replace(/-+/g,r).replace(/^(\d)/,"_$1"),i=s.occurrences[a];return s.occurrences.hasOwnProperty(a)?i++:i=0,s.occurrences[a]=i,i&&(a=a+"-"+i),a}function o(){function e(){for(var e,r=document.body.scrollTop,i=0,s=n.length;i<s;i+=1){var l=n[i];if(l.offsetTop>r){e||(e=l);break}e=l}if(e){var u=a[e.getAttribute("data-id")];u&&u!==o&&(o&&o.classList.remove("active"),u.classList.add("active"),o=u,!t&&o.scrollIntoView())}}if(!i()){for(var t=!1,n=document.querySelectorAll(".anchor"),r=document.querySelector("aside.sidebar"),a={},s=r.querySelectorAll("li"),o=r.querySelector("li.active"),l=0,u=s.length;l<u;l+=1){var c=s[l],p=c.querySelector("a").getAttribute("href");if("/"!==p){var d=p.match("#([^#]+)$");d&&d.length&&(p=d[0].slice(1))}a[decodeURIComponent(p)]=c}window.removeEventListener("scroll",e),window.addEventListener("scroll",e),r.addEventListener("mouseover",function(){t=!0}),r.addEventListener("mouseleave",function(){t=!1})}}function l(){var e=window.location.hash.match(/#[^#\/]+$/g);if(e&&e.length){var t=document.querySelector(decodeURIComponent(e[0]));return t&&setTimeout(function(){return t.scrollIntoView()},0),t}}function u(e,t){var n=window.location.href;if(e="object"==typeof e?e:document.querySelector(e)){var r;return[].slice.call(e.querySelectorAll("a")).sort(function(e,t){return t.href.length-e.href.length}).forEach(function(e){0!==n.indexOf(e.href)||r?t?e.parentNode.classList.remove("active"):e.classList.remove("active"):(t?e.parentNode.classList.add("active"):e.classList.add("active"),r=e)}),r}}function c(e){if(e="object"==typeof e?e:document.querySelector(e)){var t=document.body;if(e.addEventListener("click",function(){return t.classList.toggle("close")}),i()){var n=document.querySelector("aside.sidebar");document.body.addEventListener("click",function(r){r.target===e||e.contains(r.target)||t.classList.toggle("close"),n.contains(r.target)&&setTimeout(function(){return u(n,!0)},0)})}}}function p(e){void 0===e&&(e=0),document.body.scrollTop=e===!0?0:Number(e)}function d(){var e=document.querySelector("section.cover"),t=e.getBoundingClientRect().height;return function(){window.pageYOffset>=t||e.classList.contains("hidden")?document.body.classList.add("sticky"):document.body.classList.remove("sticky")}()}function g(e,t){return t={exports:{}},e(t,t.exports),t.exports}function h(e){return e?(/\/\//.test(e)||(e="https://github.com/"+e),e=e.replace(/^git\+/,""),'\n <a href="'+e+'" class="github-corner" aria-label="View source on Github">\n <svg viewBox="0 0 250 250" aria-hidden="true">\n <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>\n <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9
greedy:!0},"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,boolean:/\b(true|false)\b/,function:/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/},n.languages.javascript=n.languages.extend("clike",{keyword:/\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,function:/[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i}),n.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^\/])\/(?!\/)(\[.+?]|\\.|[^\/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0,greedy:!0}}),n.languages.insertBefore("javascript","string",{"template-string":{pattern:/`(?:\\\\|\\?[^\\])*?`/,greedy:!0,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:n.languages.javascript}},string:/[\s\S]+/}}}),n.languages.markup&&n.languages.insertBefore("markup","tag",{script:{pattern:/(<script[\w\W]*?>)[\w\W]*?(?=<\/script>)/i,lookbehind:!0,inside:n.languages.javascript,alias:"language-javascript"}}),n.languages.js=n.languages.javascript,function(){"undefined"!=typeof self&&self.Prism&&self.document&&document.querySelector&&(self.Prism.fileHighlight=function(){var e={js:"javascript",py:"python",rb:"ruby",ps1:"powershell",psm1:"powershell",sh:"bash",bat:"batch",h:"c",tex:"latex"};Array.prototype.forEach&&Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(t){for(var r,a=t.getAttribute("data-src"),i=t,s=/\blang(?:uage)?-(?!\*)(\w+)\b/i;i&&!s.test(i.className);)i=i.parentNode;if(i&&(r=(t.className.match(s)||[,""])[1]),!r){var o=(a.match(/\.(\w+)$/)||[,""])[1];r=e[o]||o}var l=document.createElement("code");l.className="language-"+r,t.textContent="",l.textContent="Loading…",t.appendChild(l);var u=new XMLHttpRequest;u.open("GET",a,!0),u.onreadystatechange=function(){4==u.readyState&&(u.status<400&&u.responseText?(l.textContent=u.responseText,n.highlightElement(l)):u.status>=400?l.textContent="✖ Error "+u.status+" while fetching file: "+u.statusText:l.textContent="✖ Error: File does not exist or is empty")},u.send(null)})},document.addEventListener("DOMContentLoaded",self.Prism.fileHighlight))}()}),M={},N=j,P=[],I={},W=/^!\s/,F=function(e,t){return e="object"==typeof e?e:document.querySelector(e),e.innerHTML=t,s.clear(),e},z=q({el:"#app",repo:"",maxLevel:6,subMaxLevel:0,sidebar:"",sidebarToggle:!1,loadSidebar:null,loadNavbar:null,router:!1,homepage:"README.md",coverpage:"",basePath:"",auto2top:!1},window.$docsify),R=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();if(R){for(var B in z){var D=R.getAttribute("data-"+n(B));z[B]=r(D)?z[B]:D||!0}z.loadSidebar===!0&&(z.loadSidebar="_sidebar.md"),z.loadNavbar===!0&&(z.loadNavbar="_navbar.md"),z.coverpage===!0&&(z.coverpage="_coverpage.md"),z.sidebar&&(z.sidebar=window[z.sidebar])}y(z);var H=null,G=null,V=function(t){var n=z.basePath+a();if(H===n)return t();var r=H=n;/\//.test(r)?r&&!/\/$/.test(r)&&(r=r.match(/(\S*\/)[^\/]+$/)[1]):r="";var i;i=n?/\/$/.test(n)?n+"README.md":n+".md":z.homepage||"README.md",z.coverpage&&i===z.homepage&&e(z.coverpage).then(_),G&&G.abort&&G.abort(),G=e(i,"GET",C),G.then(function(n){x(n),z.coverpage&&i!==z.homepage&&_(),z.loadSidebar?e(r+z.loadSidebar).then(function(e){L(e),t()}):t()},function(e){return x(null)}),z.loadNavbar&&e(r+z.loadNavbar).then(w)},Z=function(){var e=document.querySelector(z.el)||document.body,t=e!==docum