From 7baf50f9fa2ad679b094e0d8a2ca2d52bc5c2a05 Mon Sep 17 00:00:00 2001 From: x Date: Sat, 24 Jan 2026 20:52:53 +0100 Subject: [PATCH] feat: Refactor fullscreen toggle and theme initialization in JavaScript, and refine fullscreen CSS styling for improved appearance. --- public/s/css/f0ck.css | 10 ++++- public/s/js/theme.js | 86 ++++++++++++++++++++++--------------------- 2 files changed, 53 insertions(+), 43 deletions(-) diff --git a/public/s/css/f0ck.css b/public/s/css/f0ck.css index c5cbd5c..43d3aaa 100644 --- a/public/s/css/f0ck.css +++ b/public/s/css/f0ck.css @@ -1144,12 +1144,20 @@ html[theme="f0ck95d"] .admin-search button { } /* fullscreen */ +html[res="fullscreen"] ._204863 { + border-top: none; +} + +html[res="fullscreen"] .metadata { + border-bottom: none; +} + html[res="fullscreen"] .embed-responsive-16by9::before { padding-top: 32.99%; } html[res="fullscreen"] .container { - max-width: 100% !important; + max-width: 90% !important; padding: 0 !important; } diff --git a/public/s/js/theme.js b/public/s/js/theme.js index 64975e0..7cc4521 100644 --- a/public/s/js/theme.js +++ b/public/s/js/theme.js @@ -18,51 +18,53 @@ const Cookie = { const acttheme = Cookie.get('theme') ?? "w0bm"; const themecontainer = document.querySelector("li#themes > ul.dropdown-menu"); - if (!themecontainer) return; // Theme menu not present on this page - - const themes = [...themecontainer.querySelectorAll("li > a")].map(t => t.innerText.toLowerCase()); - if (acttheme !== document.documentElement.getAttribute("theme") && themes.includes(acttheme)) - document.documentElement.setAttribute("theme", acttheme); - // [...themecontainer.querySelectorAll("li > a")].forEach(t => t.addEventListener("click", e => { - // e.preventDefault(); - // const _theme = e.target.innerText.toLowerCase(); - // document.documentElement.setAttribute("theme", _theme); - // document.querySelector("#themes > a").setAttribute("content", _theme); - // Cookie.set("theme", _theme, { path: "/", days: 360 }); - // return false; - // })); - - document.addEventListener("keydown", e => { - if (e.target.tagName === "INPUT" || e.target.tagName === "TEXTAREA") - return; - const acttheme = Cookie.get('theme') ?? "w0bm"; + if (themecontainer) { const themes = [...themecontainer.querySelectorAll("li > a")].map(t => t.innerText.toLowerCase()); - const k = e.key; - // if (k === "t") { + if (acttheme !== document.documentElement.getAttribute("theme") && themes.includes(acttheme)) + document.documentElement.setAttribute("theme", acttheme); + // [...themecontainer.querySelectorAll("li > a")].forEach(t => t.addEventListener("click", e => { // e.preventDefault(); - // let i = themes.indexOf(acttheme); - // if (++i >= themes.length) - // i = 0; - // document.documentElement.setAttribute("theme", themes[i]); - // document.querySelector("#themes > a").setAttribute("content", themes[i]); - // Cookie.set("theme", themes[i], { path: "/", days: 360 }); - // } - }); + // const _theme = e.target.innerText.toLowerCase(); + // document.documentElement.setAttribute("theme", _theme); + // document.querySelector("#themes > a").setAttribute("content", _theme); + // Cookie.set("theme", _theme, { path: "/", days: 360 }); + // return false; + // })); - if (tbuttonfull = document.querySelector('svg#a_tfull')) { - tbuttonfull.addEventListener('click', e => { - let f = Cookie.get('fullscreen'); - if (f == 1) { - Cookie.set('fullscreen', 0); - document.querySelector('html').setAttribute('res', ''); - tbuttonfull.innerHTML = ``; - } - else { - Cookie.set('fullscreen', 1); - document.querySelector('html').setAttribute('res', 'fullscreen'); - tbuttonfull.innerHTML = ``; - } - return true; + document.addEventListener("keydown", e => { + if (e.target.tagName === "INPUT" || e.target.tagName === "TEXTAREA") + return; + const acttheme = Cookie.get('theme') ?? "w0bm"; + const themes = [...themecontainer.querySelectorAll("li > a")].map(t => t.innerText.toLowerCase()); + const k = e.key; + // if (k === "t") { + // e.preventDefault(); + // let i = themes.indexOf(acttheme); + // if (++i >= themes.length) + // i = 0; + // document.documentElement.setAttribute("theme", themes[i]); + // document.querySelector("#themes > a").setAttribute("content", themes[i]); + // Cookie.set("theme", themes[i], { path: "/", days: 360 }); + // } }); } + + // Fullscreen toggle - runs regardless of theme menu presence + document.addEventListener('click', e => { + const tbuttonfull = e.target.closest('svg#a_tfull'); + if (!tbuttonfull) return; + + let f = Cookie.get('fullscreen'); + if (f == 1) { + Cookie.set('fullscreen', 0); + document.documentElement.setAttribute('res', ''); + tbuttonfull.innerHTML = ``; + } + else { + Cookie.set('fullscreen', 1); + document.documentElement.setAttribute('res', 'fullscreen'); + tbuttonfull.innerHTML = ``; + } + return true; + }); })();