ViannyCruz commited on
Commit
e19601c
·
verified ·
1 Parent(s): 3a0fdbe

Update web/users.html

Browse files
Files changed (1) hide show
  1. web/users.html +60 -0
web/users.html CHANGED
@@ -608,5 +608,65 @@
608
  });
609
  })();
610
  </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
611
  </body>
612
  </html>
 
608
  });
609
  })();
610
  </script>
611
+ <script>
612
+ (function () {
613
+ // 1. Aplicar tema guardado al cargar
614
+ function applyTheme(theme) {
615
+ const lightTheme = document.getElementById('lightTheme');
616
+ const darkTheme = document.getElementById('darkTheme');
617
+ if (theme === 'dark') {
618
+ lightTheme.disabled = true;
619
+ darkTheme.disabled = false;
620
+ } else {
621
+ lightTheme.disabled = false;
622
+ darkTheme.disabled = true;
623
+ }
624
+ }
625
+
626
+ applyTheme(localStorage.getItem('theme') || 'light');
627
+
628
+ // 2. Escuchar cambios desde OTRAS pestañas
629
+ window.addEventListener('storage', function(e) {
630
+ if (e.key === 'theme') {
631
+ applyTheme(e.newValue);
632
+ }
633
+ });
634
+
635
+ // 3. Overlay de transición
636
+ const overlay = document.createElement('div');
637
+ overlay.id = 'theme-overlay';
638
+ overlay.style.cssText = [
639
+ 'position:fixed','inset:0','z-index:99999',
640
+ 'pointer-events:none','opacity:0',
641
+ 'transition:opacity 0.18s ease','background:#fff'
642
+ ].join(';');
643
+ document.body.appendChild(overlay);
644
+
645
+ function switchTheme() {
646
+ const darkTheme = document.getElementById('darkTheme');
647
+ const goingDark = darkTheme.disabled; // si está disabled, vamos a dark
648
+ overlay.style.background = goingDark ? '#fff' : '#1a1a2e';
649
+ overlay.style.opacity = '1';
650
+ setTimeout(function () {
651
+ const newTheme = goingDark ? 'dark' : 'light';
652
+ applyTheme(newTheme);
653
+ localStorage.setItem('theme', newTheme); // 👈 esto dispara el evento en otras pestañas
654
+ setTimeout(function () { overlay.style.opacity = '0'; }, 50);
655
+ }, 180);
656
+ }
657
+
658
+ document.addEventListener('DOMContentLoaded', function () {
659
+ const btn = document.getElementById('modeSwitcher');
660
+ if (!btn) return;
661
+ const newBtn = btn.cloneNode(true);
662
+ btn.parentNode.replaceChild(newBtn, btn);
663
+ newBtn.addEventListener('click', function (e) {
664
+ e.preventDefault();
665
+ e.stopPropagation();
666
+ switchTheme();
667
+ });
668
+ });
669
+ })();
670
+ </script>
671
  </body>
672
  </html>