mirror of https://github.com/jpanther/congo.git
11 lines
29 KiB
JavaScript
11 lines
29 KiB
JavaScript
|
var e,t,fuse,showButton,hideButton,wrapper,modal,input,output,first,last,searchVisible,indexed,hasResults,scriptBundle,copyText,copiedText;const browserIsDark=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches,sitePreference=document.documentElement.getAttribute("data-default-appearance"),userPreference=localStorage.getItem("appearance"),switcher=document.getElementById("appearance-switcher");(browserIsDark&&userPreference===null||browserIsDark&&userPreference==="dark"||sitePreference==="dark"&&userPreference===null||sitePreference==="dark"&&userPreference==="dark"||userPreference==="dark")&&document.documentElement.classList.add("dark"),document.documentElement.getAttribute("data-auto-appearance")==="true"&&window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change",a=>{a.matches?document.documentElement.classList.add("dark"):document.documentElement.classList.remove("dark")}),window.addEventListener("DOMContentLoaded",a=>{switcher&&(switcher.addEventListener("click",()=>{document.documentElement.classList.toggle("dark"),localStorage.setItem("appearance",document.documentElement.classList.contains("dark")?"dark":"light")}),switcher.addEventListener("contextmenu",a=>{a.preventDefault(),localStorage.removeItem("appearance")}))}),e=this,t=function(){"use strict";var Y,X,y,W,N,a,L,t,i,D,e,Q,R,S,T,U,V,z,x,q,v,_,aa,ab,n,r,af,H,M,s,K,ac,B,m;function ag(a,d){var b=Object.keys(a),c;return Object.getOwnPropertySymbols&&(c=Object.getOwnPropertySymbols(a),d&&(c=c.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),b.push.apply(b,c)),b}function l(c){for(var a=1,b;a<arguments.length;a++)b=null!=arguments[a]?arguments[a]:{},a%2?ag(Object(b),!0).forEach(function(a){F(c,a,b[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(c,Object.getOwnPropertyDescriptors(b)):ag(Object(b)).forEach(function(a){Object.defineProperty(c,a,Object.getOwnPropertyDescriptor(b,a))});return c}function G(a){return G="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},G(a)}function b(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}function ae(d,c){for(var b=0,a;b<c.length;b++)a=c[b],a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(d,a.key,a)}function c(a,b,c){return b&&ae(a.prototype,b),c&&ae(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function F(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function j(b,a){if("function"!=typeof a&&null!==a)throw new TypeError("Super expression must either be null or a function");Object.defineProperty(b,"prototype",{value:Object.create(a&&a.prototype,{constructor:{value:b,writable:!0,configurable:!0}}),writable:!1}),a&&E(b,a)}function p(a){return p=Object.setPrototypeOf?Object.getPrototypeOf:function(a){return a.__proto__||Object.getPrototypeOf(a)},p(a)}function E(a,b){return E=Object.setPrototypeOf||function(a,b){return a.__proto__=b,a},E(a,b)}function al(b,a){if(a&&("object"==typeof a||"function"==typeof a))return a;if(void 0!==a)throw new TypeError("Derived constructors may only return object or undefined");return function(a){if(void 0===a)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return a}(b)}function h(a){var b=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){})),!0}catch(a){return!1}}();return function(){var c,d=p(a),e;return b?(e=p(this).constructor,c=Reflect.construct(d,arguments,e)):c=d.apply(this,arguments),al(this,c)}}function k(a){return function(a){if(Array.isArray(a))return u(a)}(a)||function(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}(a)||function(a,c){if
|
||
|
<a class="flex items-center px-3 py-2 rounded-md appearance-none bg-neutral-100 dark:bg-neutral-700 focus:bg-primary-100 hover:bg-primary-100 dark:hover:bg-primary-900 dark:focus:bg-primary-900 focus:outline-dotted focus:outline-transparent focus:outline-2" href="${b.item.permalink}" tabindex="0">
|
||
|
<div class="grow">
|
||
|
<div class="-mb-1 text-lg font-bold">${b.item.title}</div>
|
||
|
<div class="text-sm text-neutral-500 dark:text-neutral-400">${b.item.section}<span class="px-2 text-primary-500">·</span>${b.item.date}</span></div>
|
||
|
<div class="text-sm italic">${b.item.summary}</div>
|
||
|
</div>
|
||
|
<div class="ml-2 ltr:block rtl:hidden text-neutral-500">→</div>
|
||
|
<div class="mr-2 ltr:hidden rtl:block text-neutral-500">←</div>
|
||
|
</a>
|
||
|
</li>`}),hasResults=!0):(a="",hasResults=!1),output.innerHTML=a,b.length>0&&(first=output.firstChild.firstElementChild,last=output.lastChild.firstElementChild)}scriptBundle=document.getElementById("script-bundle"),copyText=scriptBundle?scriptBundle.getAttribute("data-copy"):"Copy",copiedText=scriptBundle?scriptBundle.getAttribute("data-copied"):"Copied";function createCopyButton(b){const a=document.createElement("button");a.className="copy-button",a.type="button",a.ariaLabel=copyText,a.innerText=copyText,a.addEventListener("click",()=>copyCodeToClipboard(a,b)),addCopyButtonToDom(a,b)}async function copyCodeToClipboard(c,a){const b=a.querySelector(":last-child > .chroma > code").innerText;try{result=await navigator.permissions.query({name:"clipboard-write"}),result.state=="granted"||result.state=="prompt"?await navigator.clipboard.writeText(b):copyCodeBlockExecCommand(b,a)}catch(c){copyCodeBlockExecCommand(b,a)}finally{codeWasCopied(c)}}function copyCodeBlockExecCommand(e,b){const a=document.createElement("textArea");a.contentEditable="true",a.readOnly="false",a.className="copy-textarea",a.value=e,b.insertBefore(a,b.firstChild);const c=document.createRange();c.selectNodeContents(a);const d=window.getSelection();d.removeAllRanges(),d.addRange(c),a.setSelectionRange(0,999999),document.execCommand("copy"),b.removeChild(a)}function codeWasCopied(a){a.blur(),a.innerText=copiedText,setTimeout(function(){a.innerText=copyText},2e3)}function addCopyButtonToDom(c,a){a.insertBefore(c,a.firstChild);const b=document.createElement("div");b.className="highlight-wrapper",a.parentNode.insertBefore(b,a),b.appendChild(a)}window.addEventListener("DOMContentLoaded",a=>{document.querySelectorAll(".highlight").forEach(a=>createCopyButton(a))})
|