Update web/index.html
Browse files- web/index.html +41 -18
web/index.html
CHANGED
|
@@ -2003,47 +2003,70 @@
|
|
| 2003 |
].join(';');
|
| 2004 |
document.body.appendChild(overlay);
|
| 2005 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2006 |
function switchTheme() {
|
| 2007 |
const lightTheme = document.getElementById('lightTheme');
|
| 2008 |
const darkTheme = document.getElementById('darkTheme');
|
| 2009 |
const goingDark = !darkTheme.disabled;
|
| 2010 |
-
|
| 2011 |
-
// El overlay es blanco al ir a dark, negro al ir a light
|
| 2012 |
overlay.style.background = goingDark ? '#fff' : '#1a1a2e';
|
| 2013 |
-
|
| 2014 |
-
// 1. Fade IN del overlay (tapa la página)
|
| 2015 |
overlay.style.opacity = '1';
|
| 2016 |
-
|
| 2017 |
setTimeout(function () {
|
| 2018 |
-
|
| 2019 |
-
// 2. Cambia el tema mientras está tapado
|
| 2020 |
lightTheme.disabled = !lightTheme.disabled;
|
| 2021 |
darkTheme.disabled = !darkTheme.disabled;
|
| 2022 |
-
|
| 2023 |
-
|
| 2024 |
-
setTimeout(function () {
|
| 2025 |
-
overlay.style.opacity = '0';
|
| 2026 |
-
}, 50);
|
| 2027 |
-
|
| 2028 |
}, 180);
|
| 2029 |
}
|
| 2030 |
|
| 2031 |
-
// Reemplaza el comportamiento del botón existente
|
| 2032 |
document.addEventListener('DOMContentLoaded', function () {
|
| 2033 |
const btn = document.getElementById('modeSwitcher');
|
| 2034 |
if (!btn) return;
|
| 2035 |
-
|
| 2036 |
-
// Clona el botón para eliminar listeners anteriores de apps.js
|
| 2037 |
const newBtn = btn.cloneNode(true);
|
| 2038 |
btn.parentNode.replaceChild(newBtn, btn);
|
| 2039 |
-
|
| 2040 |
newBtn.addEventListener('click', function (e) {
|
| 2041 |
e.preventDefault();
|
| 2042 |
e.stopPropagation();
|
| 2043 |
switchTheme();
|
| 2044 |
});
|
| 2045 |
});
|
| 2046 |
-
|
| 2047 |
})();
|
| 2048 |
</script>
|
| 2049 |
</body>
|
|
|
|
| 2003 |
].join(';');
|
| 2004 |
document.body.appendChild(overlay);
|
| 2005 |
|
| 2006 |
+
|
| 2007 |
+
|
| 2008 |
+
// Reemplaza el comportamiento del botón existente
|
| 2009 |
+
document.addEventListener('DOMContentLoaded', function () {
|
| 2010 |
+
const btn = document.getElementById('modeSwitcher');
|
| 2011 |
+
if (!btn) return;
|
| 2012 |
+
|
| 2013 |
+
// Clona el botón para eliminar listeners anteriores de apps.js
|
| 2014 |
+
const newBtn = btn.cloneNode(true);
|
| 2015 |
+
btn.parentNode.replaceChild(newBtn, btn);
|
| 2016 |
+
|
| 2017 |
+
newBtn.addEventListener('click', function (e) {
|
| 2018 |
+
e.preventDefault();
|
| 2019 |
+
e.stopPropagation();
|
| 2020 |
+
switchTheme();
|
| 2021 |
+
});
|
| 2022 |
+
});
|
| 2023 |
+
|
| 2024 |
+
})();
|
| 2025 |
+
</script>
|
| 2026 |
+
<script>
|
| 2027 |
+
(function () {
|
| 2028 |
+
// 1. Aplicar tema guardado inmediatamente
|
| 2029 |
+
const savedTheme = localStorage.getItem('theme');
|
| 2030 |
+
if (savedTheme === 'dark') {
|
| 2031 |
+
document.getElementById('lightTheme').disabled = true;
|
| 2032 |
+
document.getElementById('darkTheme').disabled = false;
|
| 2033 |
+
}
|
| 2034 |
+
|
| 2035 |
+
// 2. Overlay de transición
|
| 2036 |
+
const overlay = document.createElement('div');
|
| 2037 |
+
overlay.id = 'theme-overlay';
|
| 2038 |
+
overlay.style.cssText = [
|
| 2039 |
+
'position:fixed','inset:0','z-index:99999',
|
| 2040 |
+
'pointer-events:none','opacity:0',
|
| 2041 |
+
'transition:opacity 0.18s ease','background:#fff'
|
| 2042 |
+
].join(';');
|
| 2043 |
+
document.body.appendChild(overlay);
|
| 2044 |
+
|
| 2045 |
function switchTheme() {
|
| 2046 |
const lightTheme = document.getElementById('lightTheme');
|
| 2047 |
const darkTheme = document.getElementById('darkTheme');
|
| 2048 |
const goingDark = !darkTheme.disabled;
|
|
|
|
|
|
|
| 2049 |
overlay.style.background = goingDark ? '#fff' : '#1a1a2e';
|
|
|
|
|
|
|
| 2050 |
overlay.style.opacity = '1';
|
|
|
|
| 2051 |
setTimeout(function () {
|
|
|
|
|
|
|
| 2052 |
lightTheme.disabled = !lightTheme.disabled;
|
| 2053 |
darkTheme.disabled = !darkTheme.disabled;
|
| 2054 |
+
localStorage.setItem('theme', darkTheme.disabled ? 'light' : 'dark');
|
| 2055 |
+
setTimeout(function () { overlay.style.opacity = '0'; }, 50);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2056 |
}, 180);
|
| 2057 |
}
|
| 2058 |
|
|
|
|
| 2059 |
document.addEventListener('DOMContentLoaded', function () {
|
| 2060 |
const btn = document.getElementById('modeSwitcher');
|
| 2061 |
if (!btn) return;
|
|
|
|
|
|
|
| 2062 |
const newBtn = btn.cloneNode(true);
|
| 2063 |
btn.parentNode.replaceChild(newBtn, btn);
|
|
|
|
| 2064 |
newBtn.addEventListener('click', function (e) {
|
| 2065 |
e.preventDefault();
|
| 2066 |
e.stopPropagation();
|
| 2067 |
switchTheme();
|
| 2068 |
});
|
| 2069 |
});
|
|
|
|
| 2070 |
})();
|
| 2071 |
</script>
|
| 2072 |
</body>
|