diff --git a/archetypes/default.md b/archetypes/default.md index 1a437f3..21255a1 100644 --- a/archetypes/default.md +++ b/archetypes/default.md @@ -26,6 +26,10 @@ flowchartDiagrams: enable: false options: "" +sequenceDiagrams: + enable: false + options: "" + --- diff --git a/exampleSite/config.toml b/exampleSite/config.toml index 4e72e0a..8d8c433 100644 --- a/exampleSite/config.toml +++ b/exampleSite/config.toml @@ -101,10 +101,14 @@ copyright = "" # default: author.name ↓ # 默认为下面配 clientId = "" # Your client ID clientSecret = "" # Your client secret - [params.flowchartDiagrams]# see https://blog.olowolo.com/example-site/post/js-sequence-diagrams/ + [params.flowchartDiagrams]# see https://blog.olowolo.com/example-site/post/js-flowchart-diagrams/ enable = false options = "" + [params.sequenceDiagrams] # see https://blog.olowolo.com/example-site/post/js-sequence-diagrams/ + enable = false + options = "" # default: "{theme: 'simple'}" + [params.busuanzi] # count web traffic by busuanzi # 是否使用不蒜子统计站点访问量 enable = false siteUV = true diff --git a/exampleSite/content/post/js-sequence-diagrams.md b/exampleSite/content/post/js-sequence-diagrams.md new file mode 100644 index 0000000..3ca3a1c --- /dev/null +++ b/exampleSite/content/post/js-sequence-diagrams.md @@ -0,0 +1,95 @@ +--- +title: "JS Sequence Diagrams" +date: 2015-03-04T21:57:45+08:00 +draft: false + +sequenceDiagrams: + enable: true + options: "{theme: 'hand'}" +--- + +## Usage + +```sequence +Andrew->China: Says Hello +Note right of China: China thinks\nabout it +China-->Andrew: How are you? +Andrew->>China: I am good thanks! +``` + + + + ```sequence + Andrew->China: Says Hello + Note right of China: China thinks\nabout it + China-->Andrew: How are you? + Andrew->>China: I am good thanks! + ``` + +## Configuration + +Configure for all home and regular pages: + +```toml +[params.sequenceDiagrams] + enable = true + options = "{theme: 'hand'}" +``` + +Configure for a single post in the front matter (**Params in front matter have higher precedence**): + +```yml +sequenceDiagrams: + enable: true + options: "{theme: 'hand'}" +``` + +### Options + +```js +options = { + // Change the styling of the diagram, typically one of 'simple', 'hand'. New themes can be registered with registerTheme(...). + theme: string, + + // CSS style to apply to the diagram's svg tag. (Only supported if using snap.svg) + css_class: string, +} +``` + +See more information from https://github.com/bramp/js-sequence-diagrams. + +## Examples + +```sequence +Title: Here is a title +A->B: Normal line +B-->C: Dashed line +C->>D: Open arrow +D-->>A: Dashed open arrow +``` + + ```sequence + Title: Here is a title + A->B: Normal line + B-->C: Dashed line + C->>D: Open arrow + D-->>A: Dashed open arrow + ``` + +--- + +```sequence +# Example of a comment. +Note left of A: Note to the\n left of A +Note right of A: Note to the\n right of A +Note over A: Note over A +Note over A,B: Note over both A and B +``` + + ```sequence + # Example of a comment. + Note left of A: Note to the\n left of A + Note right of A: Note to the\n right of A + Note over A: Note over A + Note over A,B: Note over both A and B + ``` diff --git a/layouts/partials/scripts.html b/layouts/partials/scripts.html index 01e5e16..4122086 100644 --- a/layouts/partials/scripts.html +++ b/layouts/partials/scripts.html @@ -21,6 +21,22 @@ +{{- end -}} + + +{{- if and (or .Params.sequenceDiagrams.enable (and .Site.Params.sequenceDiagrams.enable (ne .Params.sequenceDiagrams.enable false))) (or .IsPage .IsHome) -}} + + + + + + {{- end }} diff --git a/src/js/even.js b/src/js/even.js index ca83a93..6b544a4 100644 --- a/src/js/even.js +++ b/src/js/even.js @@ -224,4 +224,23 @@ Even.flowchart = function () { } } +Even.sequence = function () { + if (!window.Diagram) return + + const blocks = document.querySelectorAll('pre code.language-sequence') + for (let i = 0; i < blocks.length; i++) { + const block = blocks[i] + const rootElement = block.parentElement + + const container = document.createElement('div') + const id = `js-sequence-diagrams-${i}` + container.id = id + container.className = 'align-center' + rootElement.parentElement.replaceChild(container, rootElement) + + const diagram = Diagram.parse(block.childNodes[0].nodeValue) + diagram.drawSVG(id, window.sequenceDiagramsOptions ? window.sequenceDiagramsOptions : {theme: 'simple'}) + } +} + export {Even} diff --git a/src/js/main.js b/src/js/main.js index bae31d9..289b8dc 100644 --- a/src/js/main.js +++ b/src/js/main.js @@ -10,6 +10,7 @@ $(document).ready(function () { }) Even.flowchart() +Even.sequence() hljs.initHighlighting() Even.highlight() diff --git a/static/dist/even.min.js b/static/dist/even.min.js index f6e2fd8..548a4e4 100644 --- a/static/dist/even.min.js +++ b/static/dist/even.min.js @@ -1,2 +1,2 @@ -!function(e){var n={};function t(o){if(n[o])return n[o].exports;var a=n[o]={i:o,l:!1,exports:{}};return e[o].call(a.exports,a,a.exports,t),a.l=!0,a.exports}t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)}([function(e,n,t){"use strict";var o=t(1);t(2),$(document).ready(function(){o.Even.backToTop(),o.Even.mobileNavbar(),o.Even.toc(),o.Even.fancybox()}),o.Even.flowchart(),hljs.initHighlighting(),o.Even.highlight()},function(e,n,t){"use strict";Object.defineProperty(n,"__esModule",{value:!0});var o={};o.backToTop=function(){var e=$("#back-to-top");$(window).scroll(function(){$(window).scrollTop()>100?e.fadeIn(1e3):e.fadeOut(1e3)}),e.click(function(){$("body,html").animate({scrollTop:0})})},o.mobileNavbar=function(){var e=$("#mobile-navbar"),n=$(".mobile-navbar-icon"),t=new Slideout({panel:document.getElementById("mobile-panel"),menu:document.getElementById("mobile-menu"),padding:180,tolerance:70});t.disableTouch(),n.click(function(){t.toggle()}),t.on("beforeopen",function(){e.addClass("fixed-open"),n.addClass("icon-click").removeClass("icon-out")}),t.on("beforeclose",function(){e.removeClass("fixed-open"),n.addClass("icon-out").removeClass("icon-click")}),$("#mobile-panel").on("touchend",function(){t.isOpen()&&n.click()})},o._initToc=function(){var e=$(".post-toc"),n=$(".post-footer");if(e.length){var t=e.offset().top-20,o=n.offset().top-e.height()-20,a={start:{position:"absolute",top:t},process:{position:"fixed",top:20},end:{position:"absolute",top:o}};$(window).scroll(function(){var n=$(window).scrollTop();no?e.css(a.end):e.css(a.process)})}var r=$(".toc-link"),c=$(".headerlink"),i=$(".post-toc-content li"),l=$.map(c,function(e){return $(e).offset().top}),s=$.map(l,function(e){return e-30});$(window).scroll(function(){var e=$(window).scrollTop(),n=function(e,n){for(var t=0;te[t]&&n<=e[t+1])return t;return n>e[e.length-1]?e.length-1:-1}(s,e);if($(r).removeClass("active"),$(i).removeClass("has-active"),-1!==n){$(r[n]).addClass("active");for(var t=r[n].parentNode;"NAV"!==t.tagName;)$(t).addClass("has-active"),t=t.parentNode.parentNode}})},o.fancybox=function(){$.fancybox&&($(".post-content").each(function(){$(this).find("img").each(function(){$(this).wrap('')})}),$(".fancybox").fancybox({selector:".fancybox",protect:!0}))},o.highlight=function(){for(var e=document.querySelectorAll("pre code"),n=0;n'+(i+1)+"";for(var l="",s=0;s'+a[s]+"";t.className+=" highlight";var d=document.createElement("figure");d.className=t.className,d.innerHTML='
'+c+'
'+l+"
",o.parentElement.replaceChild(d,o)}},o.toc=function(){var e=document.getElementById("post-toc");if(null!==e){var n=document.getElementById("TableOfContents");null===n?e.parentNode.removeChild(e):(this._refactorToc(n),this._linkToc(),this._initToc())}},o._refactorToc=function(e){for(var n=e.children[0],t=n,o=void 0;1===t.children.length&&"UL"===(o=t.children[0].children[0]).tagName;)t=o;t!==n&&e.replaceChild(t,n)},o._linkToc=function(){for(var e=document.querySelectorAll("#TableOfContents a:first-child"),n=0;nh"+t),a=0;a'+r.innerHTML}},o.flowchart=function(){if(window.flowchart)for(var e=document.querySelectorAll("pre code.language-flowchart"),n=0;n100?e.fadeIn(1e3):e.fadeOut(1e3)}),e.click(function(){$("body,html").animate({scrollTop:0})})},o.mobileNavbar=function(){var e=$("#mobile-navbar"),n=$(".mobile-navbar-icon"),t=new Slideout({panel:document.getElementById("mobile-panel"),menu:document.getElementById("mobile-menu"),padding:180,tolerance:70});t.disableTouch(),n.click(function(){t.toggle()}),t.on("beforeopen",function(){e.addClass("fixed-open"),n.addClass("icon-click").removeClass("icon-out")}),t.on("beforeclose",function(){e.removeClass("fixed-open"),n.addClass("icon-out").removeClass("icon-click")}),$("#mobile-panel").on("touchend",function(){t.isOpen()&&n.click()})},o._initToc=function(){var e=$(".post-toc"),n=$(".post-footer");if(e.length){var t=e.offset().top-20,o=n.offset().top-e.height()-20,a={start:{position:"absolute",top:t},process:{position:"fixed",top:20},end:{position:"absolute",top:o}};$(window).scroll(function(){var n=$(window).scrollTop();no?e.css(a.end):e.css(a.process)})}var r=$(".toc-link"),c=$(".headerlink"),i=$(".post-toc-content li"),l=$.map(c,function(e){return $(e).offset().top}),s=$.map(l,function(e){return e-30});$(window).scroll(function(){var e=$(window).scrollTop(),n=function(e,n){for(var t=0;te[t]&&n<=e[t+1])return t;return n>e[e.length-1]?e.length-1:-1}(s,e);if($(r).removeClass("active"),$(i).removeClass("has-active"),-1!==n){$(r[n]).addClass("active");for(var t=r[n].parentNode;"NAV"!==t.tagName;)$(t).addClass("has-active"),t=t.parentNode.parentNode}})},o.fancybox=function(){$.fancybox&&($(".post-content").each(function(){$(this).find("img").each(function(){$(this).wrap('')})}),$(".fancybox").fancybox({selector:".fancybox",protect:!0}))},o.highlight=function(){for(var e=document.querySelectorAll("pre code"),n=0;n'+(i+1)+"";for(var l="",s=0;s'+a[s]+"";t.className+=" highlight";var d=document.createElement("figure");d.className=t.className,d.innerHTML='
'+c+'
'+l+"
",o.parentElement.replaceChild(d,o)}},o.toc=function(){var e=document.getElementById("post-toc");if(null!==e){var n=document.getElementById("TableOfContents");null===n?e.parentNode.removeChild(e):(this._refactorToc(n),this._linkToc(),this._initToc())}},o._refactorToc=function(e){for(var n=e.children[0],t=n,o=void 0;1===t.children.length&&"UL"===(o=t.children[0].children[0]).tagName;)t=o;t!==n&&e.replaceChild(t,n)},o._linkToc=function(){for(var e=document.querySelectorAll("#TableOfContents a:first-child"),n=0;nh"+t),a=0;a'+r.innerHTML}},o.flowchart=function(){if(window.flowchart)for(var e=document.querySelectorAll("pre code.language-flowchart"),n=0;n 100) {\r\n $backToTop.fadeIn(1000)\r\n } else {\r\n $backToTop.fadeOut(1000)\r\n }\r\n })\r\n\r\n $backToTop.click(function () {\r\n $('body,html').animate({ scrollTop: 0 })\r\n })\r\n}\r\n\r\nEven.mobileNavbar = function () {\r\n const $mobileNav = $('#mobile-navbar')\r\n const $mobileNavIcon = $('.mobile-navbar-icon')\r\n const slideout = new Slideout({\r\n 'panel': document.getElementById('mobile-panel'),\r\n 'menu': document.getElementById('mobile-menu'),\r\n 'padding': 180,\r\n 'tolerance': 70\r\n })\r\n slideout.disableTouch()\r\n\r\n $mobileNavIcon.click(function () {\r\n slideout.toggle()\r\n })\r\n\r\n slideout.on('beforeopen', function () {\r\n $mobileNav.addClass('fixed-open')\r\n $mobileNavIcon.addClass('icon-click').removeClass('icon-out')\r\n })\r\n\r\n slideout.on('beforeclose', function () {\r\n $mobileNav.removeClass('fixed-open')\r\n $mobileNavIcon.addClass('icon-out').removeClass('icon-click')\r\n })\r\n\r\n $('#mobile-panel').on('touchend', function () {\r\n slideout.isOpen() && $mobileNavIcon.click()\r\n })\r\n}\r\n\r\nEven._initToc = function () {\r\n const SPACING = 20\r\n const $toc = $('.post-toc')\r\n const $footer = $('.post-footer')\r\n\r\n if ($toc.length) {\r\n const minScrollTop = $toc.offset().top - SPACING\r\n const maxScrollTop = $footer.offset().top - $toc.height() - SPACING\r\n\r\n const tocState = {\r\n start: {\r\n 'position': 'absolute',\r\n 'top': minScrollTop\r\n },\r\n process: {\r\n 'position': 'fixed',\r\n 'top': SPACING\r\n },\r\n end: {\r\n 'position': 'absolute',\r\n 'top': maxScrollTop\r\n }\r\n }\r\n\r\n $(window).scroll(function () {\r\n const scrollTop = $(window).scrollTop()\r\n\r\n if (scrollTop < minScrollTop) {\r\n $toc.css(tocState.start)\r\n } else if (scrollTop > maxScrollTop) {\r\n $toc.css(tocState.end)\r\n } else {\r\n $toc.css(tocState.process)\r\n }\r\n })\r\n }\r\n\r\n const HEADERFIX = 30\r\n const $toclink = $('.toc-link')\r\n const $headerlink = $('.headerlink')\r\n const $tocLinkLis = $('.post-toc-content li')\r\n\r\n const headerlinkTop = $.map($headerlink, function (link) {\r\n return $(link).offset().top\r\n })\r\n\r\n const headerLinksOffsetForSearch = $.map(headerlinkTop, function (offset) {\r\n return offset - HEADERFIX\r\n })\r\n\r\n const searchActiveTocIndex = function (array, target) {\r\n for (let i = 0; i < array.length - 1; i++) {\r\n if (target > array[i] && target <= array[i + 1]) return i\r\n }\r\n if (target > array[array.length - 1]) return array.length - 1\r\n return -1\r\n }\r\n\r\n $(window).scroll(function () {\r\n const scrollTop = $(window).scrollTop()\r\n const activeTocIndex = searchActiveTocIndex(headerLinksOffsetForSearch, scrollTop)\r\n\r\n $($toclink).removeClass('active')\r\n $($tocLinkLis).removeClass('has-active')\r\n\r\n if (activeTocIndex !== -1) {\r\n $($toclink[activeTocIndex]).addClass('active')\r\n let ancestor = $toclink[activeTocIndex].parentNode\r\n while (ancestor.tagName !== 'NAV') {\r\n $(ancestor).addClass('has-active')\r\n ancestor = ancestor.parentNode.parentNode\r\n }\r\n }\r\n })\r\n}\r\n\r\nEven.fancybox = function () {\r\n if ($.fancybox) {\r\n $('.post-content').each(function () {\r\n $(this).find('img').each(function () {\r\n $(this).wrap(``)\r\n })\r\n })\r\n\r\n $('.fancybox').fancybox({\r\n selector: '.fancybox',\r\n protect: true\r\n })\r\n }\r\n}\r\n\r\nEven.highlight = function () {\r\n const blocks = document.querySelectorAll('pre code')\r\n for (let i = 0; i < blocks.length; i++) {\r\n const block = blocks[i]\r\n const rootElement = block.parentElement\r\n const lineCodes = block.innerHTML.split(/\\n/)\r\n if (lineCodes[lineCodes.length - 1] === '') lineCodes.pop()\r\n const lineLength = lineCodes.length\r\n\r\n let codeLineHtml = ''\r\n for (let i = 0; i < lineLength; i++) {\r\n codeLineHtml += `
${i + 1}
`\r\n }\r\n\r\n let codeHtml = ''\r\n for (let i = 0; i < lineLength; i++) {\r\n codeHtml += `
${lineCodes[i]}
`\r\n }\r\n\r\n block.className += ' highlight'\r\n const figure = document.createElement('figure')\r\n figure.className = block.className\r\n figure.innerHTML = `
${codeLineHtml}
${codeHtml}
`\r\n\r\n rootElement.parentElement.replaceChild(figure, rootElement)\r\n }\r\n}\r\n\r\nEven.toc = function () {\r\n const tocContainer = document.getElementById('post-toc')\r\n if (tocContainer !== null) {\r\n const toc = document.getElementById('TableOfContents')\r\n if (toc === null) {\r\n // toc = true, but there are no headings\r\n tocContainer.parentNode.removeChild(tocContainer)\r\n } else {\r\n this._refactorToc(toc)\r\n this._linkToc()\r\n this._initToc()\r\n }\r\n }\r\n}\r\n\r\nEven._refactorToc = function (toc) {\r\n // when headings do not start with `h1`\r\n const oldTocList = toc.children[0]\r\n let newTocList = oldTocList\r\n let temp\r\n while (newTocList.children.length === 1 && (temp = newTocList.children[0].children[0]).tagName === 'UL') newTocList = temp\r\n\r\n if (newTocList !== oldTocList) toc.replaceChild(newTocList, oldTocList)\r\n}\r\n\r\nEven._linkToc = function () {\r\n const links = document.querySelectorAll('#TableOfContents a:first-child')\r\n for (let i = 0; i < links.length; i++) links[i].className += ' toc-link'\r\n\r\n for (let num = 1; num <= 6; num++) {\r\n const headers = document.querySelectorAll('.post-content>h' + num)\r\n for (let i = 0; i < headers.length; i++) {\r\n const header = headers[i]\r\n header.innerHTML = `${header.innerHTML}`\r\n }\r\n }\r\n}\r\n\r\nEven.flowchart = function () {\r\n if (!window.flowchart) return\r\n\r\n const blocks = document.querySelectorAll('pre code.language-flowchart')\r\n for (let i = 0; i < blocks.length; i++) {\r\n const block = blocks[i]\r\n const rootElement = block.parentElement\r\n\r\n const container = document.createElement('div')\r\n const id = `js-flowchart-diagrams-${i}`\r\n container.id = id\r\n container.className = 'align-center'\r\n rootElement.parentElement.replaceChild(container, rootElement)\r\n\r\n const diagram = flowchart.parse(block.childNodes[0].nodeValue)\r\n diagram.drawSVG(id, window.flowchartDiagramsOptions ? window.flowchartDiagramsOptions : {})\r\n }\r\n}\r\n\r\nexport {Even}\r\n\n\n\n// WEBPACK FOOTER //\n// ./js/even.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/bootstrap 48484a6346e81e67fcd1","webpack:///./js/main.js","webpack:///./js/even.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","_even","$","document","ready","Even","backToTop","mobileNavbar","toc","fancybox","flowchart","sequence","hljs","initHighlighting","highlight","$backToTop","window","scroll","scrollTop","fadeIn","fadeOut","click","animate","$mobileNav","$mobileNavIcon","slideout","Slideout","panel","getElementById","menu","padding","tolerance","disableTouch","toggle","on","addClass","removeClass","isOpen","_initToc","$toc","$footer","length","minScrollTop","offset","top","maxScrollTop","height","tocState","start","position","process","end","css","$toclink","$headerlink","$tocLinkLis","headerlinkTop","map","link","headerLinksOffsetForSearch","activeTocIndex","array","target","searchActiveTocIndex","ancestor","parentNode","tagName","each","this","find","wrap","src","title","selector","protect","blocks","querySelectorAll","block","rootElement","parentElement","lineCodes","innerHTML","split","pop","lineLength","codeLineHtml","codeHtml","className","figure","createElement","replaceChild","tocContainer","removeChild","_refactorToc","_linkToc","oldTocList","children","newTocList","temp","links","num","headers","header","id","container","parse","childNodes","nodeValue","drawSVG","flowchartDiagramsOptions","Diagram","sequenceDiagramsOptions","theme"],"mappings":"aACA,IAAAA,KAGA,SAAAC,EAAAC,GAGA,GAAAF,EAAAE,GACA,OAAAF,EAAAE,GAAAC,QAGA,IAAAC,EAAAJ,EAAAE,IACAG,EAAAH,EACAI,GAAA,EACAH,YAUA,OANAI,EAAAL,GAAAM,KAAAJ,EAAAD,QAAAC,IAAAD,QAAAF,GAGAG,EAAAE,GAAA,EAGAF,EAAAD,QAKAF,EAAAQ,EAAAF,EAGAN,EAAAS,EAAAV,EAGAC,EAAAU,EAAA,SAAAR,EAAAS,EAAAC,GACAZ,EAAAa,EAAAX,EAAAS,IACAG,OAAAC,eAAA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GAAKA,EACfC,EAAUjB,UAAY,eACtBT,EAAYC,cAAcW,aAAac,EAAW1B,GAElCgC,QAAQL,MAAM5B,EAAM6B,WAAW,GAAGC,WAC1CC,QAAQL,EAAIvF,OAAO+F,wBAA0B/F,OAAO+F,yBAA2BC,MAAO,eAI1F3G","file":"even.min.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 48484a6346e81e67fcd1","import {Even} from './even.js'\r\n\r\nimport '../css/style.scss'\r\n\r\n$(document).ready(function () {\r\n Even.backToTop()\r\n Even.mobileNavbar()\r\n Even.toc()\r\n Even.fancybox()\r\n})\r\n\r\nEven.flowchart()\r\nEven.sequence()\r\n\r\nhljs.initHighlighting()\r\nEven.highlight()\r\n\n\n\n// WEBPACK FOOTER //\n// ./js/main.js","'use strict'\r\n\r\nconst Even = {}\r\n\r\nEven.backToTop = function () {\r\n const $backToTop = $('#back-to-top')\r\n\r\n $(window).scroll(function () {\r\n if ($(window).scrollTop() > 100) {\r\n $backToTop.fadeIn(1000)\r\n } else {\r\n $backToTop.fadeOut(1000)\r\n }\r\n })\r\n\r\n $backToTop.click(function () {\r\n $('body,html').animate({ scrollTop: 0 })\r\n })\r\n}\r\n\r\nEven.mobileNavbar = function () {\r\n const $mobileNav = $('#mobile-navbar')\r\n const $mobileNavIcon = $('.mobile-navbar-icon')\r\n const slideout = new Slideout({\r\n 'panel': document.getElementById('mobile-panel'),\r\n 'menu': document.getElementById('mobile-menu'),\r\n 'padding': 180,\r\n 'tolerance': 70\r\n })\r\n slideout.disableTouch()\r\n\r\n $mobileNavIcon.click(function () {\r\n slideout.toggle()\r\n })\r\n\r\n slideout.on('beforeopen', function () {\r\n $mobileNav.addClass('fixed-open')\r\n $mobileNavIcon.addClass('icon-click').removeClass('icon-out')\r\n })\r\n\r\n slideout.on('beforeclose', function () {\r\n $mobileNav.removeClass('fixed-open')\r\n $mobileNavIcon.addClass('icon-out').removeClass('icon-click')\r\n })\r\n\r\n $('#mobile-panel').on('touchend', function () {\r\n slideout.isOpen() && $mobileNavIcon.click()\r\n })\r\n}\r\n\r\nEven._initToc = function () {\r\n const SPACING = 20\r\n const $toc = $('.post-toc')\r\n const $footer = $('.post-footer')\r\n\r\n if ($toc.length) {\r\n const minScrollTop = $toc.offset().top - SPACING\r\n const maxScrollTop = $footer.offset().top - $toc.height() - SPACING\r\n\r\n const tocState = {\r\n start: {\r\n 'position': 'absolute',\r\n 'top': minScrollTop\r\n },\r\n process: {\r\n 'position': 'fixed',\r\n 'top': SPACING\r\n },\r\n end: {\r\n 'position': 'absolute',\r\n 'top': maxScrollTop\r\n }\r\n }\r\n\r\n $(window).scroll(function () {\r\n const scrollTop = $(window).scrollTop()\r\n\r\n if (scrollTop < minScrollTop) {\r\n $toc.css(tocState.start)\r\n } else if (scrollTop > maxScrollTop) {\r\n $toc.css(tocState.end)\r\n } else {\r\n $toc.css(tocState.process)\r\n }\r\n })\r\n }\r\n\r\n const HEADERFIX = 30\r\n const $toclink = $('.toc-link')\r\n const $headerlink = $('.headerlink')\r\n const $tocLinkLis = $('.post-toc-content li')\r\n\r\n const headerlinkTop = $.map($headerlink, function (link) {\r\n return $(link).offset().top\r\n })\r\n\r\n const headerLinksOffsetForSearch = $.map(headerlinkTop, function (offset) {\r\n return offset - HEADERFIX\r\n })\r\n\r\n const searchActiveTocIndex = function (array, target) {\r\n for (let i = 0; i < array.length - 1; i++) {\r\n if (target > array[i] && target <= array[i + 1]) return i\r\n }\r\n if (target > array[array.length - 1]) return array.length - 1\r\n return -1\r\n }\r\n\r\n $(window).scroll(function () {\r\n const scrollTop = $(window).scrollTop()\r\n const activeTocIndex = searchActiveTocIndex(headerLinksOffsetForSearch, scrollTop)\r\n\r\n $($toclink).removeClass('active')\r\n $($tocLinkLis).removeClass('has-active')\r\n\r\n if (activeTocIndex !== -1) {\r\n $($toclink[activeTocIndex]).addClass('active')\r\n let ancestor = $toclink[activeTocIndex].parentNode\r\n while (ancestor.tagName !== 'NAV') {\r\n $(ancestor).addClass('has-active')\r\n ancestor = ancestor.parentNode.parentNode\r\n }\r\n }\r\n })\r\n}\r\n\r\nEven.fancybox = function () {\r\n if ($.fancybox) {\r\n $('.post-content').each(function () {\r\n $(this).find('img').each(function () {\r\n $(this).wrap(``)\r\n })\r\n })\r\n\r\n $('.fancybox').fancybox({\r\n selector: '.fancybox',\r\n protect: true\r\n })\r\n }\r\n}\r\n\r\nEven.highlight = function () {\r\n const blocks = document.querySelectorAll('pre code')\r\n for (let i = 0; i < blocks.length; i++) {\r\n const block = blocks[i]\r\n const rootElement = block.parentElement\r\n const lineCodes = block.innerHTML.split(/\\n/)\r\n if (lineCodes[lineCodes.length - 1] === '') lineCodes.pop()\r\n const lineLength = lineCodes.length\r\n\r\n let codeLineHtml = ''\r\n for (let i = 0; i < lineLength; i++) {\r\n codeLineHtml += `
${i + 1}
`\r\n }\r\n\r\n let codeHtml = ''\r\n for (let i = 0; i < lineLength; i++) {\r\n codeHtml += `
${lineCodes[i]}
`\r\n }\r\n\r\n block.className += ' highlight'\r\n const figure = document.createElement('figure')\r\n figure.className = block.className\r\n figure.innerHTML = `
${codeLineHtml}
${codeHtml}
`\r\n\r\n rootElement.parentElement.replaceChild(figure, rootElement)\r\n }\r\n}\r\n\r\nEven.toc = function () {\r\n const tocContainer = document.getElementById('post-toc')\r\n if (tocContainer !== null) {\r\n const toc = document.getElementById('TableOfContents')\r\n if (toc === null) {\r\n // toc = true, but there are no headings\r\n tocContainer.parentNode.removeChild(tocContainer)\r\n } else {\r\n this._refactorToc(toc)\r\n this._linkToc()\r\n this._initToc()\r\n }\r\n }\r\n}\r\n\r\nEven._refactorToc = function (toc) {\r\n // when headings do not start with `h1`\r\n const oldTocList = toc.children[0]\r\n let newTocList = oldTocList\r\n let temp\r\n while (newTocList.children.length === 1 && (temp = newTocList.children[0].children[0]).tagName === 'UL') newTocList = temp\r\n\r\n if (newTocList !== oldTocList) toc.replaceChild(newTocList, oldTocList)\r\n}\r\n\r\nEven._linkToc = function () {\r\n const links = document.querySelectorAll('#TableOfContents a:first-child')\r\n for (let i = 0; i < links.length; i++) links[i].className += ' toc-link'\r\n\r\n for (let num = 1; num <= 6; num++) {\r\n const headers = document.querySelectorAll('.post-content>h' + num)\r\n for (let i = 0; i < headers.length; i++) {\r\n const header = headers[i]\r\n header.innerHTML = `${header.innerHTML}`\r\n }\r\n }\r\n}\r\n\r\nEven.flowchart = function () {\r\n if (!window.flowchart) return\r\n\r\n const blocks = document.querySelectorAll('pre code.language-flowchart')\r\n for (let i = 0; i < blocks.length; i++) {\r\n const block = blocks[i]\r\n const rootElement = block.parentElement\r\n\r\n const container = document.createElement('div')\r\n const id = `js-flowchart-diagrams-${i}`\r\n container.id = id\r\n container.className = 'align-center'\r\n rootElement.parentElement.replaceChild(container, rootElement)\r\n\r\n const diagram = flowchart.parse(block.childNodes[0].nodeValue)\r\n diagram.drawSVG(id, window.flowchartDiagramsOptions ? window.flowchartDiagramsOptions : {})\r\n }\r\n}\r\n\r\nEven.sequence = function () {\r\n if (!window.Diagram) return\r\n\r\n const blocks = document.querySelectorAll('pre code.language-sequence')\r\n for (let i = 0; i < blocks.length; i++) {\r\n const block = blocks[i]\r\n const rootElement = block.parentElement\r\n\r\n const container = document.createElement('div')\r\n const id = `js-sequence-diagrams-${i}`\r\n container.id = id\r\n container.className = 'align-center'\r\n rootElement.parentElement.replaceChild(container, rootElement)\r\n\r\n const diagram = Diagram.parse(block.childNodes[0].nodeValue)\r\n diagram.drawSVG(id, window.sequenceDiagramsOptions ? window.sequenceDiagramsOptions : {theme: 'simple'})\r\n }\r\n}\r\n\r\nexport {Even}\r\n\n\n\n// WEBPACK FOOTER //\n// ./js/even.js"],"sourceRoot":""} \ No newline at end of file