Add favicon

This commit is contained in:
Simon Detheridge 2023-10-17 14:59:28 +01:00
parent 346f3de193
commit 74e9f9feaf
Signed by: simon
GPG Key ID: 38640971DA1E704E
5 changed files with 3 additions and 3 deletions

View File

@ -25,5 +25,5 @@ function dropdown(){const o=window.matchMedia("(max-width: 767px)"),i=document.q
<span class="tootlink" ${n?"":'style="display: none;"'}>${i.uri}</span>
</div>
</div>
</div>`,o=DOMPurify.sanitize(o,{RETURN_DOM_FRAGMENT:!0});for(const r of o.querySelectorAll(".tootlink"))r.onclick=function(){return copyElementTextToClipboard(this)};t.appendChild(o)}}else document.getElementById("mastodon-comments-list").innerHTML="<div class='mastodon-comment'>No comments (yet)!</div>"}let MASTODON_POST_ID;function pagination(e=!0,l,s=!1){const c=document.querySelector(".gh-feed");if(!c)return;let t=!1;async function n(){var t=document.querySelector("link[rel=next]");if(t)try{var e=await(await fetch(t.href)).text(),n=(new DOMParser).parseFromString(e,"text/html"),o=n.querySelectorAll(".gh-feed:not(.gh-featured):not(.gh-related) > *");const r=document.createDocumentFragment(),a=[];o.forEach(function(e){e=document.importNode(e,!0);s&&(e.style.visibility="hidden"),r.appendChild(e),a.push(e)}),c.appendChild(r),l&&l(a,d);var i=n.querySelector("link[rel=next]");i&&i.href?t.href=i.href:(t.remove(),u&&u.remove())}catch(e){throw t.remove(),e}}const o=c.nextElementSibling||document.querySelector(".gh-footer"),u=document.querySelector(".gh-loadmore"),d=(!document.querySelector("link[rel=next]")&&u&&u.remove(),async function(){o.getBoundingClientRect().top<=window.innerHeight&&document.querySelector("link[rel=next]")&&await n()});const i=new IntersectionObserver(async function(e){if(!t){if(t=!0,e[0].isIntersecting)if(s)await n();else for(;o.getBoundingClientRect().top<=window.innerHeight&&document.querySelector("link[rel=next]");)await n();t=!1,document.querySelector("link[rel=next]")||i.disconnect()}});e?i.observe(o):u.addEventListener("click",n)}document.addEventListener("DOMContentLoaded",async e=>{let t,n;var o=/bot|google|baidu|bing|msn|teoma|slurp|yandex/i.test(navigator.userAgent),o=(0<document.getElementsByClassName("gh-sidebar").length&&(t=`https://${MASTODON_HOST}/api/v1/accounts/${MASTODON_ACCOUNT_ID}/statuses?exclude_replies=true&exclude_reblogs=true`),MASTODON_POST_ID&&!o&&(t=`https://${MASTODON_HOST}/api/v1/statuses/${MASTODON_POST_ID}/context`,n=!0),document.getElementById("mastodon-comments-list"));if(t&&o){var i=document.getElementById("toot-link-top"),r=document.getElementById("toot-link-clip"),a=`https://${MASTODON_HOST}/@s/`+MASTODON_POST_ID;i&&(i.href=a),r&&(r.innerText=a);let e=await(await fetch(t)).json();n&&(e=e.descendants);i=document.getElementById("mastodon-comments-header");return i&&(i.style.display=""),renderMastodonContent(e,o,n)}});const isOSLight=window.matchMedia("(prefers-color-scheme: light)").matches,localTheme=window.localStorage&&window.localStorage.getItem("lightTheme"),themeToggle=document.querySelector(".theme-toggle");function changeFavicon(){var e=document.documentElement.classList.contains("dark-theme")?"/img/favicon-dark.png":"/img/favicon.png",t=document.createElement("link"),n=document.getElementById("dynamic-favicon");t.id="dynamic-favicon",t.rel="shortcut icon",t.href=e,n&&document.head.removeChild(n),document.head.appendChild(t)}function changeTheme(e){document.documentElement.classList.remove("light-theme","dark-theme","has-light-text","has-dark-text"),e?document.documentElement.classList.add("light-theme","has-dark-text"):document.documentElement.classList.add("dark-theme","has-light-text"),window.localStorage&&window.localStorage.setItem("lightTheme",e?"light":"dark"),changeFavicon()}themeToggle.addEventListener("click",()=>{changeTheme(document.documentElement.classList.contains("dark-theme"))}),"light"===localTheme?changeTheme(!0):changeTheme(isOSLight);
</div>`,o=DOMPurify.sanitize(o,{RETURN_DOM_FRAGMENT:!0});for(const r of o.querySelectorAll(".tootlink"))r.onclick=function(){return copyElementTextToClipboard(this)};t.appendChild(o)}}else document.getElementById("mastodon-comments-list").innerHTML="<div class='mastodon-comment'>No comments (yet)!</div>"}let MASTODON_POST_ID;function pagination(e=!0,l,s=!1){const c=document.querySelector(".gh-feed");if(!c)return;let t=!1;async function n(){var t=document.querySelector("link[rel=next]");if(t)try{var e=await(await fetch(t.href)).text(),n=(new DOMParser).parseFromString(e,"text/html"),o=n.querySelectorAll(".gh-feed:not(.gh-featured):not(.gh-related) > *");const r=document.createDocumentFragment(),a=[];o.forEach(function(e){e=document.importNode(e,!0);s&&(e.style.visibility="hidden"),r.appendChild(e),a.push(e)}),c.appendChild(r),l&&l(a,d);var i=n.querySelector("link[rel=next]");i&&i.href?t.href=i.href:(t.remove(),u&&u.remove())}catch(e){throw t.remove(),e}}const o=c.nextElementSibling||document.querySelector(".gh-footer"),u=document.querySelector(".gh-loadmore"),d=(!document.querySelector("link[rel=next]")&&u&&u.remove(),async function(){o.getBoundingClientRect().top<=window.innerHeight&&document.querySelector("link[rel=next]")&&await n()});const i=new IntersectionObserver(async function(e){if(!t){if(t=!0,e[0].isIntersecting)if(s)await n();else for(;o.getBoundingClientRect().top<=window.innerHeight&&document.querySelector("link[rel=next]");)await n();t=!1,document.querySelector("link[rel=next]")||i.disconnect()}});e?i.observe(o):u.addEventListener("click",n)}document.addEventListener("DOMContentLoaded",async e=>{let t,n;var o=/bot|google|baidu|bing|msn|teoma|slurp|yandex/i.test(navigator.userAgent),o=(0<document.getElementsByClassName("gh-sidebar").length&&(t=`https://${MASTODON_HOST}/api/v1/accounts/${MASTODON_ACCOUNT_ID}/statuses?exclude_replies=true&exclude_reblogs=true`),MASTODON_POST_ID&&!o&&(t=`https://${MASTODON_HOST}/api/v1/statuses/${MASTODON_POST_ID}/context`,n=!0),document.getElementById("mastodon-comments-list"));if(t&&o){var i=document.getElementById("toot-link-top"),r=document.getElementById("toot-link-clip"),a=`https://${MASTODON_HOST}/@s/`+MASTODON_POST_ID;i&&(i.href=a),r&&(r.innerText=a);let e=await(await fetch(t)).json();n&&(e=e.descendants);i=document.getElementById("mastodon-comments-header");return i&&(i.style.display=""),renderMastodonContent(e,o,n)}});const isOSLight=window.matchMedia("(prefers-color-scheme: light)").matches,localTheme=window.localStorage&&window.localStorage.getItem("lightTheme"),themeToggle=document.querySelector(".theme-toggle");function changeFavicon(){var e=document.documentElement.classList.contains("dark-theme")?"/assets/images/favicon-dark.png":"/assets/images/favicon.png",t=document.createElement("link"),n=document.getElementById("dynamic-favicon");t.id="dynamic-favicon",t.rel="shortcut icon",t.href=e,n&&document.head.removeChild(n),document.head.appendChild(t)}function changeTheme(e){document.documentElement.classList.remove("light-theme","dark-theme","has-light-text","has-dark-text"),e?document.documentElement.classList.add("light-theme","has-dark-text"):document.documentElement.classList.add("dark-theme","has-light-text"),window.localStorage&&window.localStorage.setItem("lightTheme",e?"light":"dark"),changeFavicon()}themeToggle.addEventListener("click",()=>{changeTheme(document.documentElement.classList.contains("dark-theme"))}),"light"===localTheme?changeTheme(!0):changeTheme(isOSLight);
//# sourceMappingURL=source.js.map

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

BIN
assets/images/favicon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -5,7 +5,7 @@ const localTheme = window.localStorage && window.localStorage.getItem("lightThem
const themeToggle = document.querySelector(".theme-toggle")
function changeFavicon() {
const src = document.documentElement.classList.contains("dark-theme") ? "/img/favicon-dark.png" : "/img/favicon.png";
const src = document.documentElement.classList.contains("dark-theme") ? "/assets/images/favicon-dark.png" : "/assets/images/favicon.png";
const link = document.createElement('link'),
oldLink = document.getElementById('dynamic-favicon');
link.id = 'dynamic-favicon';