@mhg/blog
Version:
3 lines (2 loc) • 21.8 kB
JavaScript
document.addEventListener("error",function(e){const t=e.target;if("img"!==t.tagName.toLowerCase())return;const o=t.parentElement;if(!o)return;const n=o.className,s=o.parentElement;if(!s)return;const a=s.className;t.classList.add("error"),"fancybox"===n&&"fancybox"===a?(s.classList.add("hideFancybox"),s.classList.remove("fancybox"),o.classList.remove("fancybox")):"img-bg"===n&&"img-wrap"===a&&s.classList.add("hideFancybox")},!0),document.addEventListener("DOMContentLoaded",function(){volantis.requestAnimationFrame(()=>{VolantisApp.init(),VolantisApp.subscribe();const e=new VolantisFancyBox;e.bind("#post-body img[fancybox]"),highlightKeyWords.startFromURL(),locationHash(),volantis.pjax.push(()=>{VolantisApp.pjaxReload(),e.bind("#post-body img[fancybox]"),sessionStorage.setItem("domTitle",document.title),highlightKeyWords.startFromURL()},"app.js"),volantis.pjax.send(()=>{volantis.dom.switcher.removeClass("active"),volantis.dom.header.removeClass("z_search-open"),volantis.dom.wrapper.removeClass("sub"),volantis.EventListener.remove()},"app.js")})});const locationHash=()=>{if(window.location.hash){let e=decodeURI(window.location.hash.split("#")[1]).replace(/\ /g,"-"),t=document.getElementById(e);e&&!t&&(e=decodeURIComponent(window.location.hash.split("#")[1]).replace(/\ /g,"-"),t=document.getElementById(e)),t&&setTimeout(()=>{window.location.hash.startsWith("#fn")?VolantisApp.scrolltoElement(t,VolantisApp.getScrollCorrection()-VolantisApp.REM,"instant",!0):window.location.hash.startsWith("#mjx")?VolantisApp.scrolltoElement(t,VolantisApp.getScrollCorrection()+VolantisApp.REM,"instant",!0):VolantisApp.scrolltoElement(t,VolantisApp.REM,"instant",!0)},500)}};Object.freeze(locationHash);const VolantisApp=(()=>{const e={},t=parseFloat(getComputedStyle(document.documentElement).fontSize);let o=80;e.init=()=>{volantis.dom.header&&(o=volantis.dom.header.clientHeight+t),window.onresize=()=>{document.documentElement.clientWidth<500?volantis.isMobile=1:volantis.isMobile=0,volantis.isMobile!=volantis.isMobileOld&&(e.setGlobalHeaderMenuEvent(),e.setHeader(),e.setHeaderSearch())},volantis.scroll.push(volantis.debounce(e.scrollEventCallBack),"scrollEventCallBack")},e.event=()=>{volantis.dom.$(document.getElementById("scroll-down"))?.on("click",function(){e.scrolltoElement(volantis.dom.bodyAnchor)});const t=document.querySelector("#l_side");if(t){t.querySelectorAll("section").length||document.querySelector("#l_main").classList.add("no_sidebar")}if(document.getElementById("last-update-show")){const t=volantis.GLOBAL_CONFIG.sidebar.webinfo.lastupd;t.enable&&t.friendlyShow&&(document.getElementById("last-update-show").innerHTML=e.utilTimeAgo(volantis.GLOBAL_CONFIG.lastupdate))}if(document.getElementById("webinfo-runtime-count")){let e=new Date(volantis.GLOBAL_CONFIG.sidebar.webinfo.runtime.data),t=(new Date).getTime()-e.getTime(),o=Math.floor(t/864e5);document.getElementById("webinfo-runtime-count").innerHTML=`${o} ${volantis.GLOBAL_CONFIG.sidebar.webinfo.runtime.unit}`}if(document.querySelector(".tag-subtree.parent-tag > a > .tag-switcher-wrapper")){const e=document.querySelectorAll(".tag-subtree.parent-tag > a > .tag-switcher-wrapper");for(const t of e)t.addEventListener("click",e=>{e.target.closest(".tag-subtree.parent-tag").classList.toggle("expanded"),e.preventDefault()})}document.body.oncopy=function(){e.messageCopyright()}},e.restData=()=>{o=volantis.dom.header?volantis.dom.header.clientHeight+t:80},e.setIsMobile=()=>{document.documentElement.clientWidth<500?(volantis.isMobile=1,volantis.isMobileOld=1):(volantis.isMobile=0,volantis.isMobileOld=0)},e.scrolltoElement=(e,t=o,n=null,s=!1)=>{let a={top:e.getBoundingClientRect().top+document.documentElement.scrollTop-t};n&&(a.behavior=n),s&&(a.observer=s),volantis.scroll.to(e,a)},e.scrollEventCallBack=()=>{const e=volantis.dom.bodyAnchor.offsetTop-o,t=volantis.scroll.getScrollTop();volantis.dom.topBtn&&(t>volantis.dom.bodyAnchor.offsetTop?(volantis.dom.topBtn.addClass("show"),volantis.scroll.del>0?volantis.dom.topBtn.removeClass("hl"):volantis.dom.topBtn.addClass("hl")):volantis.dom.topBtn.removeClass("show").removeClass("hl")),volantis.dom.header&&(t-e>-1?volantis.dom.header.addClass("show"):volantis.dom.header.removeClass("show")),pdata.ispage&&volantis.dom.wrapper&&(volantis.scroll.del>0&&t>100?volantis.dom.wrapper.addClass("sub"):volantis.scroll.del<0&&volantis.dom.wrapper.removeClass("sub")),volantis.isMobile&&(pdata.ispage&&volantis.dom.tocTarget&&volantis.dom.toc&&(volantis.dom.tocTarget.removeClass("active"),volantis.dom.toc.removeClass("active")),volantis.dom.mPhoneList&&volantis.dom.mPhoneList.forEach(function(e){volantis.dom.$(e).hide()}))},e.setScrollAnchor=()=>{volantis.dom.topBtn&&volantis.dom.bodyAnchor&&volantis.dom.topBtn.click(t=>{t.preventDefault(),t.stopPropagation(),e.scrolltoElement(volantis.dom.bodyAnchor),t.stopImmediatePropagation()})},e.setHeader=()=>{pdata.ispage&&(volantis.dom.wrapper.find(".nav-sub .title").html(document.title.split(" - ")[0]),volantis.dom.comment=volantis.dom.$(document.getElementById("s-comment")),volantis.dom.commentTarget=volantis.dom.$(document.querySelector("#l_main article#comments")),volantis.dom.commentTarget?volantis.dom.comment.click(t=>{t.preventDefault(),t.stopPropagation(),volantis.cleanContentVisibility(),e.scrolltoElement(volantis.dom.commentTarget),t.stopImmediatePropagation()}):volantis.dom.comment.style.display="none",volantis.isMobile&&(volantis.dom.toc=volantis.dom.$(document.getElementById("s-toc")),volantis.dom.tocTarget=volantis.dom.$(document.querySelector("#l_side .toc-wrapper")),volantis.dom.tocTarget?(volantis.dom.toc.click(e=>{e.stopPropagation(),volantis.dom.tocTarget.toggleClass("active"),volantis.dom.toc.toggleClass("active")}),volantis.dom.$(document).click(function(e){e.stopPropagation(),volantis.dom.tocTarget&&volantis.dom.tocTarget.removeClass("active"),volantis.dom.toc.removeClass("active")})):volantis.dom.toc&&(volantis.dom.toc.style.display="none")))},e.setHeaderMenuSelection=()=>{volantis.dom.headerMenu=volantis.dom.$(document.querySelectorAll("#l_header .navigation,#l_cover .navigation,#l_side .navigation")),volantis.dom.headerMenu.forEach(e=>{let t=volantis.dom.$(e).find("li a.active");t&&t.removeClass("active");let o=volantis.dom.$(e).find("div a.active");o&&o.removeClass("active")});var e=location.pathname.replace(/\/|%|\./g,"");0==e.length&&(e="home");var t=e.match(/page\d{0,}$/g);t&&(t=t[0],e=e.split(t)[0]);var o=e.match(/index.html/);o&&(o=o[0],e=e.split(o)[0]),(e=CSS.escape(e))&&volantis.dom.headerMenu&&volantis.dom.headerMenu.forEach(t=>{let o=t.querySelector("[active-action=action-"+e+"]");o&&volantis.dom.$(o).addClass("active")})},e.setGlobalHeaderMenuEvent=()=>{volantis.isMobile?document.querySelectorAll("#l_header .m-phone li").forEach(function(e){e.querySelector(".list-v")&&volantis.dom.$(e).click(function(e){e.stopPropagation(),e.currentTarget.parentElement.childNodes.forEach(function(e){"[object HTMLLIElement]"==Object.prototype.toString.call(e)&&e.childNodes.forEach(function(e){"[object HTMLUListElement]"==Object.prototype.toString.call(e)&&volantis.dom.$(e).hide()})});let t=e.currentTarget.children;for(let o=0;o<t.length;o++){const e=t[o];"menu"===volantis.dom.$(e).title?volantis.dom.$(e).display="flex":volantis.dom.$(e).show()}},0)}):document.querySelectorAll("#wrapper .m-pc li > a[href]").forEach(function(e){volantis.dom.$(e.parentElement).click(function(e){e.stopPropagation(),e.target.origin==e.target.baseURI&&document.querySelectorAll("#wrapper .m-pc .list-v").forEach(function(e){volantis.dom.$(e).hide()})},0)}),e.setPageHeaderMenuEvent()},e.setPageHeaderMenuEvent=()=>{volantis.isMobile&&volantis.dom.$(document).click(function(e){volantis.dom.mPhoneList.forEach(function(e){volantis.dom.$(e).hide()})})},e.setHeaderSearch=()=>{volantis.isMobile&&volantis.dom.switcher&&(volantis.dom.switcher.click(function(e){e.stopPropagation(),volantis.dom.header.toggleClass("z_search-open"),volantis.dom.switcher.toggleClass("active")},!1),volantis.dom.$(document).click(function(e){volantis.dom.header.removeClass("z_search-open"),volantis.dom.switcher.removeClass("active")},!1),volantis.dom.search.click(function(e){e.stopPropagation()},!1))},e.setTabs=()=>{let e=document.querySelectorAll("#l_main .tabs .nav-tabs");e&&e.forEach(function(e){e.querySelectorAll("a").forEach(function(e){volantis.dom.$(e).on("click",e=>{e.preventDefault(),e.stopPropagation();const t=volantis.dom.$(e.target.parentElement.parentElement.parentElement);return t.find(".nav-tabs .active").removeClass("active"),volantis.dom.$(e.target.parentElement).addClass("active"),t.find(".tab-content .active").removeClass("active"),t.find(e.target.className).addClass("active"),!1})})})},e.mathjaxRef=()=>{let n=document.querySelectorAll("mjx-container a[href]");n.forEach(function(s,a){n[a].click=()=>{};let l=decodeURIComponent(n[a].getAttribute("href").split("#")[1]).replace(/\ /g,"-");volantis.dom.$(s).on("click",n=>{n.stopPropagation(),n.preventDefault();let s=document.getElementById(l);s&&e.scrolltoElement(s,o+t,"instant")})})},e.footnotes=()=>{let n=document.querySelectorAll("#l_main a[rel=footnote],#footnotelist a[rev=footnote],#l_main .footnote-backref, #l_main .footnote-ref > a");n.forEach(function(s,a){n[a].click=()=>{};let l=decodeURIComponent(n[a].getAttribute("href").split("#")[1]).replace(/\ /g,"-");volantis.dom.$(s).on("click",n=>{n.stopPropagation(),n.preventDefault();let s=document.getElementById(l);s&&e.scrolltoElement(s,o-t,"instant")})})},e.utilCopyCode=t=>{document.querySelectorAll(t).forEach(t=>{t.insertAdjacentHTML("beforebegin",'<button class="btn-copy" data-clipboard-snippet=""><i class="fa-solid fa-copy"></i><span>COPY</span></button>');const o=t.previousSibling;o.onclick=n=>{n.stopPropagation();const s=o.querySelector("i"),a=o.querySelector("span");t.focus();const l=new Range;l.selectNodeContents(t),document.getSelection().removeAllRanges(),document.getSelection().addRange(l);const i=document.getSelection().toString();e.utilWriteClipText(i).then(()=>{e.messageCopyright(),o.classList.add("copied"),s.classList.remove("fa-copy"),s.classList.add("fa-check-circle"),a.innerText="COPIED",setTimeout(()=>{s.classList.remove("fa-check-circle"),s.classList.add("fa-copy"),a.innerText="COPY"},2e3)})["catch"](e=>{VolantisApp.message("系统提示",e,{icon:"fa fa-exclamation-circle red"}),o.classList.add("copied-failed"),s.classList.remove("fa-copy"),s.classList.add("fa-exclamation-circle"),a.innerText="COPY FAILED",setTimeout(()=>{s.classList.remove("fa-exclamation-circle"),s.classList.add("fa-copy"),a.innerText="COPY"})})}})},e.utilWriteClipText=e=>navigator.clipboard.writeText(e).then(()=>Promise.resolve())["catch"](t=>{const o=document.createElement("textarea");o.setAttribute("readonly","readonly"),document.body.appendChild(o),o.innerHTML=e,o.select();try{let e=document.execCommand("copy");return document.body.removeChild(o),e&&"unsuccessful"!==e?Promise.resolve():Promise.reject("复制文本失败!")}catch(t){return document.body.removeChild(o),Promise.reject("当前浏览器不支持复制功能,请检查更新或更换其他浏览器操作!")}}),e.utilTimeAgo=e=>{const t=6e4,o=36e5,n=24*o,s=7*n,a=30*n,l=(new Date).getTime()-e,i=l/t,r=l/o,c=l/n,d=l/s,m=l/a;if(l<0)result="";else if(m>=1&&m<7)result=" "+parseInt(m)+" 月前";else if(d>=1&&d<4)result=" "+parseInt(d)+" 周前";else if(c>=1&&c<7)result=" "+parseInt(c)+" 天前";else if(r>=1&&r<24)result=" "+parseInt(r)+" 小时前";else if(i>=1&&i<60)result=" "+parseInt(i)+" 分钟前";else if(l>=0&&l<=t)result="刚刚";else{const t=new Date;t.setTime(e);const o=t.getFullYear(),n=t.getMonth()+1<10?"0"+(t.getMonth()+1):t.getMonth()+1,s=t.getDate()<10?"0"+t.getDate():t.getDate();t.getHours()<10?t.getHours():t.getHours(),t.getMinutes()<10?t.getMinutes():t.getMinutes(),t.getSeconds()<10?t.getSeconds():t.getSeconds();result=o+"-"+n+"-"+s}return result},e.message=(e,t,o={},n=null)=>{function s(e,t,o,n){const{icon:s,time:a,position:l,transitionIn:i,transitionOut:r,messageColor:c,titleColor:d,backgroundColor:m,zindex:u,displayMode:g}=o;iziToast.show({layout:"2",icon:"Fontawesome",closeOnEscape:"true",displayMode:g||"replace",transitionIn:i||volantis.GLOBAL_CONFIG.plugins.message.transitionIn,transitionOut:r||volantis.GLOBAL_CONFIG.plugins.message.transitionOut,messageColor:c||volantis.GLOBAL_CONFIG.plugins.message.messageColor,titleColor:d||volantis.GLOBAL_CONFIG.plugins.message.titleColor,backgroundColor:m||volantis.GLOBAL_CONFIG.plugins.message.backgroundColor,zindex:u||volantis.GLOBAL_CONFIG.plugins.message.zindex,icon:s||volantis.GLOBAL_CONFIG.plugins.message.icon["default"],timeout:a||volantis.GLOBAL_CONFIG.plugins.message.time["default"],position:l||volantis.GLOBAL_CONFIG.plugins.message.position,title:e,message:t,onClosed:()=>{n&&n()}})}"undefined"==typeof iziToast?(volantis.css(volantis.GLOBAL_CONFIG.cdn.izitoast_css),volantis.js(volantis.GLOBAL_CONFIG.cdn.izitoast_js,()=>{s(e,t,o,n)})):s(e,t,o,n)},e.question=(e,t,o={},n=null,s=null,a=null)=>{function l(e,t,o,n,s,a){const{icon:l,time:i,position:r,transitionIn:c,transitionOut:d,messageColor:m,titleColor:u,backgroundColor:g,zindex:p}=o;iziToast.question({id:"question",icon:"Fontawesome",close:!1,overlay:!0,displayMode:"once",position:"center",messageColor:m||volantis.GLOBAL_CONFIG.plugins.message.messageColor,titleColor:u||volantis.GLOBAL_CONFIG.plugins.message.titleColor,backgroundColor:g||volantis.GLOBAL_CONFIG.plugins.message.backgroundColor,zindex:p||volantis.GLOBAL_CONFIG.plugins.message.zindex,icon:l||volantis.GLOBAL_CONFIG.plugins.message.icon.quection,timeout:i||volantis.GLOBAL_CONFIG.plugins.message.time.quection,title:e,message:t,buttons:[["<button><b>是</b></button>",(e,t)=>{e.hide({transitionOut:d||"fadeOut"},t,"button"),n&&n(e,t)}],["<button><b>否</b></button>",(e,t)=>{e.hide({transitionOut:d||"fadeOut"},t,"button"),s&&s(e,t)}]],onClosed:(e,t,o)=>{a&&a(e,t,o)}})}"undefined"==typeof iziToast?(volantis.css(volantis.GLOBAL_CONFIG.cdn.izitoast_css),volantis.js(volantis.GLOBAL_CONFIG.cdn.izitoast_js,()=>{l(e,t,o,n,s,a)})):l(e,t,o,n,s,a)},e.hideMessage=(e=null)=>{const t=document.querySelector(".iziToast");function o(e){iziToast.hide({},t),e&&e()}t?"undefined"==typeof iziToast?(volantis.css(volantis.GLOBAL_CONFIG.cdn.izitoast_css),volantis.js(volantis.GLOBAL_CONFIG.cdn.izitoast_js,()=>{o(e)})):o(e):e&&e()};let n=0;return e.messageCopyright=()=>{volantis.GLOBAL_CONFIG.plugins.message.enable&&volantis.GLOBAL_CONFIG.plugins.message.copyright.enable&&n<1&&(n++,VolantisApp.message(volantis.GLOBAL_CONFIG.plugins.message.copyright.title,volantis.GLOBAL_CONFIG.plugins.message.copyright.message,{icon:volantis.GLOBAL_CONFIG.plugins.message.copyright.icon,transitionIn:"flipInX",transitionOut:"flipOutX",displayMode:1}))},{init:()=>{e.init(),e.event()},subscribe:()=>{e.setIsMobile(),e.setHeader(),e.setHeaderMenuSelection(),e.setGlobalHeaderMenuEvent(),e.setHeaderSearch(),e.setScrollAnchor(),e.setTabs(),e.footnotes(),e.mathjaxRef()},pjaxReload:()=>{e.event(),e.restData(),e.setHeader(),e.setHeaderMenuSelection(),e.setPageHeaderMenuEvent(),e.setScrollAnchor(),e.setTabs(),e.footnotes(),e.mathjaxRef(),document.querySelector("#l_header .nav-main").querySelectorAll(".list-v:not(.menu-phone)").forEach(function(e){e.removeAttribute("style")}),document.querySelector("#l_header .menu-phone.list-v").removeAttribute("style"),n=0},utilCopyCode:e.utilCopyCode,utilWriteClipText:e.utilWriteClipText,utilTimeAgo:e.utilTimeAgo,message:e.message,question:e.question,hideMessage:e.hideMessage,messageCopyright:e.messageCopyright,scrolltoElement:e.scrolltoElement,getScrollCorrection:()=>o,REM:t}})();Object.freeze(VolantisApp);class VolantisFancyBox{constructor(e=!0){this.option={Hash:!1,groupAll:!0,caption:(e,t)=>t.thumbEl?.alt||"",contentClick:"iterateZoom",Thumbs:{showOnStart:!1},Images:{content:(e,t)=>{const o=t.thumbEl;if(!o)return"";const n=o.closest("picture");if(o.classList.remove("content-in"),o.hasAttribute("data-src")&&o.setAttribute("src",o.getAttribute("data-src")),n){n.classList.remove("lazy");const e=n.getElementsByTagName("source");for(let t=0;t<e.length;t++){const o=e[t];o.hasAttribute("data-srcset")&&o.setAttribute("srcset",o.getAttribute("data-srcset"))}return n.outerHTML}return o.outerHTML},Panzoom:{maxScale:1}},Toolbar:{display:{left:["infobar"],middle:["zoomIn","zoomOut","toggle1to1","rotateCCW","rotateCW","flipX","flipY"],right:["slideshow","download","thumbs","close"]}}},e&&this.#e()}async#e(){await this.loadFancybox(),document.querySelector(".md .gallery img, .fancybox")&&this.groupBind()}async loadFancybox(){if("undefined"==typeof Fancybox)try{await volantis.css(volantis.GLOBAL_CONFIG.cdn.fancybox_css),await volantis.js(volantis.GLOBAL_CONFIG.cdn.fancybox_js)}catch(e){console.error("Failed to load Fancybox:",e)}}async bind(e){e&&(await this.loadFancybox(),"undefined"!=typeof Fancybox&&(Fancybox.unbind(e),Fancybox.bind(e,this.option),Fancybox.close()))}async groupBind(e,t="default"){await this.loadFancybox(),this.#t(e,t);const o=new Set,n=document.querySelectorAll(".gallery");for(let s=0;s<n.length;s++){const e=n[s];e.querySelector("img")&&o.add(e.getAttribute("data-group")||"default")}t&&o.add(t),"undefined"!=typeof Fancybox&&o.forEach(e=>{Fancybox.unbind(`[data-fancybox="${e}"]`),Fancybox.bind(`[data-fancybox="${e}"]`,this.option)})}#t(e,t){if(!e)return;const o=document.querySelectorAll(e);for(let n=0;n<o.length;n++){const e=o[n];if(e.hasAttribute("fancybox"))continue;e.setAttribute("fancybox","");const s=document.createElement("a");s.setAttribute("href",e.src||e.dataset?.src),s.setAttribute("data-caption",e.alt||""),s.setAttribute("data-fancybox",t),s.classList.add("fancybox"),s.append(e.cloneNode()),e.replaceWith(s)}}}const highlightKeyWords=(()=>{let e={markNum:0,markNextId:-1,startFromURL:()=>{const t=decodeURI(new URL(location.href).searchParams.get("keyword")),o=t?t.split(" "):[],n=document.querySelector("#l_main");1==o.length&&"null"==o[0]||(e.start(o,n),e.scrollToFirstHighlightKeywordMark())},scrollToFirstHighlightKeywordMark:()=>{volantis.cleanContentVisibility(),e.scrollToNextHighlightKeywordMark("0")||volantis.requestAnimationFrame(e.scrollToFirstHighlightKeywordMark)},scrollToNextHighlightKeywordMark:t=>{let o=t||(e.markNextId+1)%e.markNum;e.markNextId=parseInt(o);let n=document.getElementById("keyword-mark-"+e.markNextId);return n||(e.markNextId=(e.markNextId+1)%e.markNum,n=document.getElementById("keyword-mark-"+e.markNextId)),n&&volantis.scroll.to(n,{addTop:-volantis.dom.header.offsetHeight-5,behavior:"instant"}),n},start:(t,o)=>{if(e.markNum=0,!t.length||!o||1==t.length&&"null"==t[0])return;console.log(t);const n=document.createTreeWalker(o,NodeFilter.SHOW_TEXT,null),s=[];for(;n.nextNode();)n.currentNode.parentNode.matches("button, select, textarea")||s.push(n.currentNode);s.forEach(o=>{const[n]=e.getIndexByWord(t,o.nodeValue);if(!n.length)return;const s=e.mergeIntoSlice(0,o.nodeValue.length,n);e.highlightText(o,s,"keyword"),e.highlightStyle()})},getIndexByWord:(e,t,o=!1)=>{const n=[],s=new Set;return e.forEach(e=>{const a=document.createElement("div");a.innerText=e;const l=(e=a.innerHTML).length;if(0===l)return;let i=0,r=-1;for(o||(t=t.toLowerCase(),e=e.toLowerCase());(r=t.indexOf(e,i))>-1;)n.push({position:r,word:e}),s.add(e),i=r+l}),n.sort((e,t)=>e.position!==t.position?e.position-t.position:t.word.length-e.word.length),[n,s]},mergeIntoSlice:(e,t,o)=>{let n=o[0],{position:s,word:a}=n;const l=[],i=new Set;for(;s+a.length<=t&&0!==o.length;){i.add(a),l.push({position:s,length:a.length});const e=s+a.length;for(o.shift();0!==o.length&&(n=o[0],s=n.position,a=n.word,e>s);)o.shift()}return{hits:l,start:e,end:t,count:i.size}},highlightText:(t,o,n)=>{const s=t.nodeValue;let a=o.start;const l=[];for(const{position:i,length:r}of o.hits){const t=document.createTextNode(s.substring(a,i));a=i+r;let o=document.createElement("mark");o.className=n,o=e.highlightStyle(o),o.appendChild(document.createTextNode(s.substr(i,r))),l.push(t,o)}t.nodeValue=s.substring(a,o.end),l.forEach(e=>{t.parentNode.insertBefore(e,t)})},highlightStyle:t=>{if(t)return t.id="keyword-mark-"+e.markNum,e.markNum++,t.style.background="transparent",t.style["border-bottom"]="1px dashed #ff2a2a",t.style.color="#ff2a2a",t.style["font-weight"]="bold",t}};return{startFromURL:()=>{e.startFromURL()}}})();Object.freeze(highlightKeyWords);const DOMController={visible:(e,t=!0)=>{e&&(e.style.display=!0===t?"block":"none")},remove:e=>{document.querySelectorAll(e).forEach(e=>{e.remove()})},removeList:e=>{e.forEach(e=>{DOMController.remove(e)})},setAttribute:(e,t,o)=>{document.querySelectorAll(e).forEach(e=>{e.setAttribute(t,o)})},setAttributeList:e=>{e.forEach(e=>{DOMController.setAttribute(e[0],e[1],e[2])})},setStyle:(e,t,o)=>{document.querySelectorAll(e).forEach(e=>{e.style[t]=o})},setStyleList:e=>{e.forEach(e=>{DOMController.setStyle(e[0],e[1],e[2])})},fadeIn:e=>{if(e)return e.style.visibility="visible",e.style.opacity=1,e.style.display="block",e.style.transition="all 0.5s linear",e},fadeOut:e=>{if(e)return e.style.visibility="hidden",e.style.opacity=0,e.style.display="none",e.style.transition="all 0.5s linear",e},fadeToggle:e=>{if(e)return e="hidden"==e.style.visibility?DOMController.fadeIn(e):DOMController.fadeOut(e)},fadeToggleList:e=>{e.forEach(e=>{DOMController.fadeToggle(e)})},hasClass:(e,t)=>{if(e)return e.className.match(new RegExp("(\\s|^)"+t+"(\\s|$)"))},addClass:(e,t)=>{if(e)return e.classList.add(t),e},removeClass:(e,t)=>{if(e)return e.classList.remove(t),e},toggleClass:(e,t)=>{if(e)return DOMController.hasClass(e,t)?DOMController.removeClass(e,t):DOMController.addClass(e,t),e},toggleClassList:e=>{e.forEach(e=>{DOMController.toggleClass(e[0],e[1])})}};Object.freeze(DOMController);
//# sourceMappingURL=../maps/js/app.js.map