ViannyCruz commited on
Commit
68df3e6
·
verified ·
1 Parent(s): 81238e7

Update web/diagnosis.html

Browse files
Files changed (1) hide show
  1. web/diagnosis.html +53 -4
web/diagnosis.html CHANGED
@@ -1436,15 +1436,64 @@ if (false) { /* removed */ }
1436
  ].join(';');
1437
  document.body.appendChild(overlay);
1438
 
1439
- function switchTheme() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1440
  const lightTheme = document.getElementById('lightTheme');
1441
  const darkTheme = document.getElementById('darkTheme');
1442
- const goingDark = !darkTheme.disabled;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1443
  overlay.style.background = goingDark ? '#fff' : '#1a1a2e';
1444
  overlay.style.opacity = '1';
1445
  setTimeout(function () {
1446
- lightTheme.disabled = !lightTheme.disabled;
1447
- darkTheme.disabled = !darkTheme.disabled;
 
1448
  setTimeout(function () { overlay.style.opacity = '0'; }, 50);
1449
  }, 180);
1450
  }
 
1436
  ].join(';');
1437
  document.body.appendChild(overlay);
1438
 
1439
+
1440
+
1441
+ document.addEventListener('DOMContentLoaded', function () {
1442
+ const btn = document.getElementById('modeSwitcher');
1443
+ if (!btn) return;
1444
+ const newBtn = btn.cloneNode(true);
1445
+ btn.parentNode.replaceChild(newBtn, btn);
1446
+ newBtn.addEventListener('click', function (e) {
1447
+ e.preventDefault();
1448
+ e.stopPropagation();
1449
+ switchTheme();
1450
+ });
1451
+ });
1452
+ })();
1453
+ </script>
1454
+ <script>
1455
+ (function () {
1456
+ // 1. Aplicar tema guardado al cargar
1457
+ function applyTheme(theme) {
1458
  const lightTheme = document.getElementById('lightTheme');
1459
  const darkTheme = document.getElementById('darkTheme');
1460
+ if (theme === 'dark') {
1461
+ lightTheme.disabled = true;
1462
+ darkTheme.disabled = false;
1463
+ } else {
1464
+ lightTheme.disabled = false;
1465
+ darkTheme.disabled = true;
1466
+ }
1467
+ }
1468
+
1469
+ applyTheme(localStorage.getItem('theme') || 'light');
1470
+
1471
+ // 2. Escuchar cambios desde OTRAS pestañas
1472
+ window.addEventListener('storage', function(e) {
1473
+ if (e.key === 'theme') {
1474
+ applyTheme(e.newValue);
1475
+ }
1476
+ });
1477
+
1478
+ // 3. Overlay de transición
1479
+ const overlay = document.createElement('div');
1480
+ overlay.id = 'theme-overlay';
1481
+ overlay.style.cssText = [
1482
+ 'position:fixed','inset:0','z-index:99999',
1483
+ 'pointer-events:none','opacity:0',
1484
+ 'transition:opacity 0.18s ease','background:#fff'
1485
+ ].join(';');
1486
+ document.body.appendChild(overlay);
1487
+
1488
+ function switchTheme() {
1489
+ const darkTheme = document.getElementById('darkTheme');
1490
+ const goingDark = darkTheme.disabled; // si está disabled, vamos a dark
1491
  overlay.style.background = goingDark ? '#fff' : '#1a1a2e';
1492
  overlay.style.opacity = '1';
1493
  setTimeout(function () {
1494
+ const newTheme = goingDark ? 'dark' : 'light';
1495
+ applyTheme(newTheme);
1496
+ localStorage.setItem('theme', newTheme); // 👈 esto dispara el evento en otras pestañas
1497
  setTimeout(function () { overlay.style.opacity = '0'; }, 50);
1498
  }, 180);
1499
  }