add iframe theme reload on theme toggle

modified:   index.html
This commit is contained in:
Russell Ballestrini 2025-10-12 08:31:50 -04:00
parent c9bd3ff7d2
commit 1a210d48e9

View file

@ -27,8 +27,14 @@
} else {
document.documentElement.setAttribute('data-theme', theme);
}
// Reload Remarkbox iframe with new theme if it exists
var iframe = document.getElementById('remarkbox-iframe');
if (iframe && window.buildRbSrc) {
iframe.src = buildRbSrc();
}
}
// Disable custom styling for uncloseai.js - use PicoCSS instead
window.UNCLOSEAI_CUSTOM_STYLING = false;
</script>
@ -531,11 +537,30 @@ speech.ai.unturf.com {
var thread_title = window.document.title;
var thread_fragment = window.location.hash;
var rb_src = "https://my.remarkbox.com/embed" +
"?rb_owner_key=" + rb_owner_key +
"&thread_title=" + encodeURI(thread_title) +
"&thread_uri=" + encodeURIComponent(thread_uri) +
thread_fragment;
function getCurrentTheme() {
// Check if data-theme is set on documentElement
var theme = document.documentElement.getAttribute('data-theme');
if (theme) {
return theme; // 'light' or 'dark'
}
// If auto, detect system preference
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
return 'dark';
}
return 'light';
}
function buildRbSrc() {
var mode = getCurrentTheme();
return "https://my.remarkbox.com/embed" +
"?rb_owner_key=" + rb_owner_key +
"&thread_title=" + encodeURI(thread_title) +
"&thread_uri=" + encodeURIComponent(thread_uri) +
"&mode=" + mode +
thread_fragment;
}
var rb_src = buildRbSrc();
function create_remarkbox_iframe() {
var ifrm = document.createElement("iframe");