|
Метки: очистка ручная отмена |
(не показано 78 промежуточных версий этого же участника) |
Строка 1: |
Строка 1: |
| $(document).ready(function() {
| |
| var button = document.createElement("button");
| |
| button.innerHTML = "Сменить тему";
| |
| button.className = "theme-button";
| |
| button.onclick = toggleTheme;
| |
|
| |
|
| var container = document.getElementById("p-personal");
| |
| if (container) {
| |
| container.parentNode.insertBefore(button, container);
| |
| }
| |
|
| |
| var isLightTheme = localStorage.getItem("isLightTheme");
| |
| if (isLightTheme === "true") {
| |
| setLightTheme();
| |
| } else {
| |
| setDarkTheme();
| |
| }
| |
| });
| |
|
| |
| function toggleTheme() {
| |
| var isLightTheme = localStorage.getItem("isLightTheme");
| |
| if (isLightTheme === "true") {
| |
| setDarkTheme();
| |
| localStorage.setItem("isLightTheme", "false");
| |
| } else {
| |
| setLightTheme();
| |
| localStorage.setItem("isLightTheme", "true");
| |
| }
| |
| }
| |
|
| |
| function setLightTheme() {
| |
| var root = document.documentElement;
| |
| root.style.setProperty('--color-fg', '#252525');
| |
| root.style.setProperty('--color-bg', '#ffffff');
| |
| }
| |
|
| |
| function setDarkTheme() {
| |
| var root = document.documentElement;
| |
| root.style.setProperty('--color-fg', '#ffffff');
| |
| root.style.setProperty('--color-bg', '#252525');
| |
| }
| |