diff --git a/index.html b/index.html
index a3f45e8..c0c3c66 100644
--- a/index.html
+++ b/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;
@@ -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");