ViannyCruz commited on
Commit
cb3a130
·
verified ·
1 Parent(s): 0d29c20

Update web/patients.html

Browse files
Files changed (1) hide show
  1. web/patients.html +53 -4
web/patients.html CHANGED
@@ -1261,15 +1261,64 @@
1261
  ].join(';');
1262
  document.body.appendChild(overlay);
1263
 
1264
- function switchTheme() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1265
  const lightTheme = document.getElementById('lightTheme');
1266
  const darkTheme = document.getElementById('darkTheme');
1267
- const goingDark = !darkTheme.disabled;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1268
  overlay.style.background = goingDark ? '#fff' : '#1a1a2e';
1269
  overlay.style.opacity = '1';
1270
  setTimeout(function () {
1271
- lightTheme.disabled = !lightTheme.disabled;
1272
- darkTheme.disabled = !darkTheme.disabled;
 
1273
  setTimeout(function () { overlay.style.opacity = '0'; }, 50);
1274
  }, 180);
1275
  }
 
1261
  ].join(';');
1262
  document.body.appendChild(overlay);
1263
 
1264
+
1265
+
1266
+ document.addEventListener('DOMContentLoaded', function () {
1267
+ const btn = document.getElementById('modeSwitcher');
1268
+ if (!btn) return;
1269
+ const newBtn = btn.cloneNode(true);
1270
+ btn.parentNode.replaceChild(newBtn, btn);
1271
+ newBtn.addEventListener('click', function (e) {
1272
+ e.preventDefault();
1273
+ e.stopPropagation();
1274
+ switchTheme();
1275
+ });
1276
+ });
1277
+ })();
1278
+ </script>
1279
+ <script>
1280
+ (function () {
1281
+ // 1. Aplicar tema guardado al cargar
1282
+ function applyTheme(theme) {
1283
  const lightTheme = document.getElementById('lightTheme');
1284
  const darkTheme = document.getElementById('darkTheme');
1285
+ if (theme === 'dark') {
1286
+ lightTheme.disabled = true;
1287
+ darkTheme.disabled = false;
1288
+ } else {
1289
+ lightTheme.disabled = false;
1290
+ darkTheme.disabled = true;
1291
+ }
1292
+ }
1293
+
1294
+ applyTheme(localStorage.getItem('theme') || 'light');
1295
+
1296
+ // 2. Escuchar cambios desde OTRAS pestañas
1297
+ window.addEventListener('storage', function(e) {
1298
+ if (e.key === 'theme') {
1299
+ applyTheme(e.newValue);
1300
+ }
1301
+ });
1302
+
1303
+ // 3. Overlay de transición
1304
+ const overlay = document.createElement('div');
1305
+ overlay.id = 'theme-overlay';
1306
+ overlay.style.cssText = [
1307
+ 'position:fixed','inset:0','z-index:99999',
1308
+ 'pointer-events:none','opacity:0',
1309
+ 'transition:opacity 0.18s ease','background:#fff'
1310
+ ].join(';');
1311
+ document.body.appendChild(overlay);
1312
+
1313
+ function switchTheme() {
1314
+ const darkTheme = document.getElementById('darkTheme');
1315
+ const goingDark = darkTheme.disabled; // si está disabled, vamos a dark
1316
  overlay.style.background = goingDark ? '#fff' : '#1a1a2e';
1317
  overlay.style.opacity = '1';
1318
  setTimeout(function () {
1319
+ const newTheme = goingDark ? 'dark' : 'light';
1320
+ applyTheme(newTheme);
1321
+ localStorage.setItem('theme', newTheme); // 👈 esto dispara el evento en otras pestañas
1322
  setTimeout(function () { overlay.style.opacity = '0'; }, 50);
1323
  }, 180);
1324
  }