add iframe theme reload on theme toggle
modified: index.html
This commit is contained in:
parent
c9bd3ff7d2
commit
1a210d48e9
1 changed files with 31 additions and 6 deletions
37
index.html
37
index.html
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue