From 27404344781f7e0bbd7b11a6898624f4d3d149d8 Mon Sep 17 00:00:00 2001 From: javajianghu Date: Mon, 20 May 2024 16:20:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=AD=97=E6=95=B0=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/js/countable.js | 60 +++++++++++++++++++++++++++++ assets/js/docsify-pagination.min.js | 1 + assets/js/docsify-sidebar.min.js | 2 + index.html | 20 ++++++++++ 4 files changed, 83 insertions(+) create mode 100644 assets/js/countable.js create mode 100644 assets/js/docsify-pagination.min.js create mode 100644 assets/js/docsify-sidebar.min.js diff --git a/assets/js/countable.js b/assets/js/countable.js new file mode 100644 index 0000000..248d4ce --- /dev/null +++ b/assets/js/countable.js @@ -0,0 +1,60 @@ +//default values +var defaultOptions = { + countable: true, + position: "top", + margin: "10px", + float: "right", + fontsize: "0.9em", + color: "rgb(90,90,90)", + language: "english", + isExpected: true, +} + +// Docsify plugin functions +function plugin(hook, vm) { + if (!defaultOptions.countable) { + return + } + let wordsCount + hook.beforeEach(function (content) { + // Match regex every time you start parsing .md + wordsCount = content.match(/([\u4e00-\u9fa5]+?|[a-zA-Z0-9]+)/g).length + return content + }) + hook.afterEach(function (html, next) { + let str = wordsCount + " words" + let readTime = Math.ceil(wordsCount / 400) + " min" + //Determine whether to use the Chinese style according to the attribute "language" + if (defaultOptions.language === "chinese") { + str = wordsCount + " 字" + readTime = Math.ceil(wordsCount / 400) + " 分钟" + } + + //add html string + next( + ` + ${defaultOptions.position === "bottom" ? html : ""} +
+ + ${str} + ${defaultOptions.isExpected ? `  |  ${readTime}` : ""} + +
+
+ ${defaultOptions.position !== "bottom" ? html : ""} + ` + ) + }) +} + +// Docsify plugin options +window.$docsify["count"] = Object.assign( + defaultOptions, + window.$docsify["count"] +) +window.$docsify.plugins = [].concat(plugin, window.$docsify.plugins) diff --git a/assets/js/docsify-pagination.min.js b/assets/js/docsify-pagination.min.js new file mode 100644 index 0000000..83a77fa --- /dev/null +++ b/assets/js/docsify-pagination.min.js @@ -0,0 +1 @@ +!function(t){("object"!=typeof exports||"undefined"==typeof module)&&"function"==typeof define&&define.amd?define(t):t()}(function(){"use strict";var i="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function t(t,e){return t(e={exports:{}},e.exports),e.exports}var c=t(function(t,e){function n(t,e){return e.querySelector(t)}(e=t.exports=function(t,e){return n(t,e=e||document)}).all=function(t,e){return(e=e||document).querySelectorAll(t)},e.engine=function(t){if(!t.one)throw new Error(".one callback required");if(t.all)return n=t.one,e.all=t.all,e;throw new Error(".all callback required")}}),e=(c.all,c.engine,t(function(e){var n=eval;try{n("export default global")}catch(t){try{n("export default self")}catch(t){try{e.exports=i}catch(t){try{self.global=self}catch(t){window.global=window}}}}}));try{var a=c}catch(t){a=c}var e=e.Element,e=e&&e.prototype||{},r=e.matches||e.webkitMatchesSelector||e.mozMatchesSelector||e.msMatchesSelector||e.oMatchesSelector,s=function(t,e){if(!t||1!==t.nodeType)return!1;if(r)return r.call(t,e);for(var n=a.all(e,t.parentNode),i=0;i ul > li"),c("p",e)),this.hyperlink=m(t))}var b=function(){return'
'},k=function(t,e){a=e,r=t.route.path,o={},["previousText","nextText"].forEach(function(n){var i=a[n];"string"==typeof i?o[n]=i:Object.keys(i).some(function(t){var e=r&&-1\n \n
\n \n \n \n '+i+'\n
\n
'+t.prev.name+"
\n ",t.prev&&e.crossChapterText&&'
'+t.prev.chapterName+"
",t.prev&&"
\n \n ",t.next&&'\n \n "].filter(Boolean).join("")};window.$docsify=window.$docsify||{},window.$docsify.plugins=[function(t,e){var n=d({},(e.config,{previousText:"PREVIOUS",nextText:"NEXT",crossChapter:!1,crossChapterText:!1}),e.config.pagination||{});function i(){var t=c("."+h);t&&(t.innerHTML=k(function(t,e){e=e.crossChapter;try{var n=t.router.toURL(t.route.path),i=g(c.all(".sidebar-nav li a")).filter(function(t){return!s(t,".section-link")}),a=i.find(x(n)),r=g((p(a,"ul")||{}).children).filter(function(t){return"LI"===t.tagName.toUpperCase()}),o=e?i.findIndex(x(n)):r.findIndex(function(t){t=m(t);return t&&x(n,t)}),l=e?i:r;return{route:t.route,prev:new y(l[o-1]).toJSON(),next:new y(l[o+1]).toJSON()}}catch(t){return{route:{}}}}(e,n),n))}t.afterEach(function(t){return t+b()}),t.doneEach(i)}].concat(window.$docsify.plugins||[])}); \ No newline at end of file diff --git a/assets/js/docsify-sidebar.min.js b/assets/js/docsify-sidebar.min.js new file mode 100644 index 0000000..70110f0 --- /dev/null +++ b/assets/js/docsify-sidebar.min.js @@ -0,0 +1,2 @@ +/*! docsify-sidebar 5.0.6 | (c) Mark Battistella */ +"use strict";($docsify=$docsify||{}).plugins=[].concat(function(o,t){var e,s={name:"",url:"",copyYear:"",policy:!0,terms:!0,cookies:!0,customStyle:"body"};Object.assign(s,$docsify.autoFooter||{});if(!((e=s)&&e.constructor===Object&&0').concat(t,""):"string"==typeof o&&(a=(i(o)?''):'')).concat(t,""))),a&&(e="".concat(r.toLowerCase().replace(/\s+/g,"-")),a='').concat(a,"")),a},o="",t='Copyright © '.concat(s.copyYear&&s.copyYear<=t?"".concat(s.copyYear).concat(s.copyYear"),e=c(s.url,s.name,"","footer-text-author"),r=c(s.policy,"Policy","_policy","footer-links-policy"),a=c(s.terms,"Terms","_terms","footer-links-terms"),c=c(s.cookies,"Cookies","_cookies","footer-links-cookies"),l.innerHTML='