added firebase support and views to theme

This commit is contained in:
Nuno Coração
2022-09-12 12:49:52 +01:00
parent d0b0dfe002
commit 11320067eb
581 changed files with 1439 additions and 79715 deletions

View File

@@ -0,0 +1 @@
var scriptBundle=document.getElementById("script-bundle"),copyText=scriptBundle?scriptBundle.getAttribute("data-copy"):"Copy",copiedText=scriptBundle?scriptBundle.getAttribute("data-copied"):"Copied";function createCopyButton(t){const e=document.createElement("button");e.className="copy-button",e.type="button",e.ariaLabel=copyText,e.innerText=copyText,e.addEventListener("click",()=>copyCodeToClipboard(e,t)),addCopyButtonToDom(e,t)}async function copyCodeToClipboard(n,e){const t=e.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(t):copyCodeBlockExecCommand(t,e)}catch(n){copyCodeBlockExecCommand(t,e)}finally{codeWasCopied(n)}}function copyCodeBlockExecCommand(o,t){const e=document.createElement("textArea");e.contentEditable="true",e.readOnly="false",e.className="copy-textarea",e.value=o,t.insertBefore(e,t.firstChild);const n=document.createRange();n.selectNodeContents(e);const s=window.getSelection();s.removeAllRanges(),s.addRange(n),e.setSelectionRange(0,999999),document.execCommand("copy"),t.removeChild(e)}function codeWasCopied(e){e.blur(),e.innerText=copiedText,setTimeout(function(){e.innerText=copyText},2e3)}function addCopyButtonToDom(n,e){e.insertBefore(n,e.firstChild);const t=document.createElement("div");t.className="highlight-wrapper",e.parentNode.insertBefore(t,e),t.appendChild(e)}window.addEventListener("DOMContentLoaded",e=>{document.querySelectorAll(".highlight").forEach(e=>createCopyButton(e))})

View File

@@ -0,0 +1 @@
if(mediumZoom(document.querySelectorAll("img:not(.nozoom)"),{margin:24,background:'rgba(0,0,0,0.5)',scrollOffset:0}),typeof auth!='undefined'){var viewsCollection=db.collection('views'),update_views;function numberWithCommas(e){return e.toString().replace(/\B(?=(\d{3})+(?!\d))/g,',')}update_views=function(e,t){viewsCollection.doc(t).onSnapshot(s=>{var n,t=s.data();t&&(n=document.querySelectorAll("span[id='"+e+"']")[0].innerText.split(' ')[1],document.querySelectorAll("span[id='"+e+"']")[0].innerText=numberWithCommas(t.views)+" "+n)})},auth.signInAnonymously().then(()=>{var e,t,s,n=document.querySelectorAll("span[id^='views_']");for(s in n)e=n[s].id,t=e&&e.replaceAll("/","-"),t&&update_views(e,t)}).catch(e=>{var t=e.code,n=e.message;console.error(t,n)})}