logo fix attempt 1
This commit is contained in:
1 parent
36df765000
commit
3674f07716
2 files changed
+35
-7
No files matched your search
@@ -111,6 +111,27 @@
|
||||
pushDownTopBars(offset);
|
||||
}
|
||||
|
||||
// Hide the default server-name text next to the top-bar logo icon, leaving
|
||||
// just the (now custom) logo image in place. "icon-transparent" matches the
|
||||
// filename inject-banner.sh replaces for the top-bar logo; keep these two
|
||||
// in sync if that ever changes again.
|
||||
const LOGO_IMG_MATCH = 'icon-transparent';
|
||||
|
||||
function hideLogoText() {
|
||||
const logoImg = document.querySelector('img[src*="' + LOGO_IMG_MATCH + '"]');
|
||||
if (!logoImg) return;
|
||||
const container = logoImg.parentElement;
|
||||
if (!container) return;
|
||||
Array.prototype.forEach.call(container.childNodes, function (node) {
|
||||
if (node === logoImg) return;
|
||||
if (node.nodeType === Node.TEXT_NODE) {
|
||||
if (node.textContent.trim()) node.textContent = '';
|
||||
} else if (node.nodeType === Node.ELEMENT_NODE && node.style.display !== 'none') {
|
||||
node.style.display = 'none';
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function isHomePage() {
|
||||
const h = window.location.hash;
|
||||
return h === '' || h === '#' || h === '#/home' || h === '#!'
|
||||
@@ -160,22 +181,24 @@
|
||||
debounceTimer = setTimeout(function () {
|
||||
update();
|
||||
applyOffset();
|
||||
hideLogoText();
|
||||
}, delay || 150);
|
||||
}
|
||||
|
||||
// React to SPA navigation
|
||||
window.addEventListener('hashchange', update);
|
||||
window.addEventListener('hashchange', function () { update(); hideLogoText(); });
|
||||
window.addEventListener('resize', function () { scheduleUpdate(); });
|
||||
|
||||
// Watch for Jellyfin's deferred body rendering (SPA bootstraps after
|
||||
// DOMContentLoaded) and re-run on DOM churn, since the nav bar can be
|
||||
// unmounted/remounted by the SPA router.
|
||||
// DOMContentLoaded) and re-run on DOM churn, since the nav bar (and the
|
||||
// logo it contains) can be unmounted/remounted by the SPA router.
|
||||
const observer = new MutationObserver(function () { scheduleUpdate(); });
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
observer.observe(document.body, { childList: true, subtree: true });
|
||||
update();
|
||||
hideLogoText();
|
||||
});
|
||||
|
||||
// Fallback: run immediately if DOMContentLoaded already fired
|
||||
if (document.readyState !== 'loading') update();
|
||||
if (document.readyState !== 'loading') { update(); hideLogoText(); }
|
||||
})();
|
||||
+8
-3
@@ -36,16 +36,21 @@ with open(index_path, 'w') as f:
|
||||
print("jellyfin-inject-banner: inlined banner script into " + index_path)
|
||||
EOF
|
||||
|
||||
# Replace the logo image (filename contains a content hash that changes on updates)
|
||||
# Replace the logo image(s) (filenames contain a content hash that changes on
|
||||
# updates). "icon-transparent" is the top-bar logo as of the 12.x header
|
||||
# redesign; "banner-light" is kept too since it's still used for the splash
|
||||
# screen / PWA icons.
|
||||
LOGO_SRC="${CUSTOM_DIR}/banner-light.png"
|
||||
if [[ -f "${LOGO_SRC}" ]]; then
|
||||
LOGO_DEST=$(ls "${WEB_DIR}"/banner-light.*.png 2>/dev/null | head -1)
|
||||
for LOGO_BASENAME in banner-light icon-transparent; do
|
||||
LOGO_DEST=$(ls "${WEB_DIR}/${LOGO_BASENAME}".*.png 2>/dev/null | head -1)
|
||||
if [[ -n "${LOGO_DEST}" ]]; then
|
||||
cp "${LOGO_SRC}" "${LOGO_DEST}"
|
||||
echo "jellyfin-inject-banner: replaced logo at ${LOGO_DEST}"
|
||||
else
|
||||
echo "jellyfin-inject-banner: no banner-light.*.png found in ${WEB_DIR}, skipping logo." >&2
|
||||
echo "jellyfin-inject-banner: no ${LOGO_BASENAME}.*.png found in ${WEB_DIR}, skipping." >&2
|
||||
fi
|
||||
done
|
||||
else
|
||||
echo "jellyfin-inject-banner: ${LOGO_SRC} not found, skipping logo." >&2
|
||||
fi
|
||||
Reference in new issue
Block a user