mirror of
				https://github.com/Theodor-Springmann-Stiftung/hamann-ausgabe-core.git
				synced 2025-10-31 02:05:33 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			35 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			35 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| // Functions for switching theme
 | |
| const startup_theme = function () {
 | |
| 
 | |
|     const go_to_dark = function () {
 | |
|         localStorage.setItem("theme", "ha-toggledark");
 | |
|         document.documentElement.classList.add("dark");
 | |
|     };
 | |
| 
 | |
|     const go_to_bright = function () {
 | |
|         document.documentElement.classList.remove("dark");
 | |
|         localStorage.setItem("theme", "ha-togglebright");
 | |
|     };
 | |
| 
 | |
|     // Functions for reading theme settings
 | |
|     const get_theme_settings = function (standard) {
 | |
|         var theme = localStorage.getItem("theme");
 | |
|         if (theme === null) theme = standard;
 | |
|         let toggleSwitch = document.getElementById(theme).click();
 | |
|     };
 | |
| 
 | |
|     if (
 | |
|         document.getElementById("ha-togglebright") !== null &&
 | |
|         document.getElementById("ha-toggledark") !== null
 | |
|     ) {
 | |
|         document
 | |
|             .getElementById("ha-togglebright")
 | |
|             .addEventListener("click", go_to_bright);
 | |
|         document
 | |
|             .getElementById("ha-toggledark")
 | |
|             .addEventListener("click", go_to_dark);
 | |
|     }
 | |
|     get_theme_settings("ha-togglebright");
 | |
| };
 | |
| 
 | |
| export { startup_theme }; | 
