Fix order of Functions
This commit is contained in:
		@@ -5,11 +5,11 @@ document.querySelectorAll(".onclick-select").forEach((element) => {
 | 
				
			|||||||
// Navbar dropdowns
 | 
					// Navbar dropdowns
 | 
				
			||||||
const navSections = document.querySelectorAll(".nav-details");
 | 
					const navSections = document.querySelectorAll(".nav-details");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const navSectionsToggle = () => {
 | 
					const navSectionsToggle = (event) => {
 | 
				
			||||||
  // When opening next dropdown, hide previous
 | 
					  // When opening next dropdown, hide previous
 | 
				
			||||||
  if (this.open) {
 | 
					  if (event.target.open) {
 | 
				
			||||||
    navSections.forEach((navSection) => {
 | 
					    navSections.forEach((navSection) => {
 | 
				
			||||||
      if (navSection != this && navSection.open) {
 | 
					      if (navSection != event.target && navSection.open) {
 | 
				
			||||||
        navSection.open = !open;
 | 
					        navSection.open = !open;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
@@ -28,15 +28,14 @@ const navSectionsClose = (event) => {
 | 
				
			|||||||
  });
 | 
					  });
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Fix images in dark theme
 | 
				
			||||||
navSections.forEach(navSection => {
 | 
					function fixThemeImages() {
 | 
				
			||||||
  navSection.addEventListener("toggle", navSectionsToggle);
 | 
					  document.querySelectorAll('[data-theme-src]').forEach((image) => {
 | 
				
			||||||
});
 | 
					    const tempSrc = image.src;
 | 
				
			||||||
document.addEventListener("click", navSectionsClose);
 | 
					    image.src = image.getAttribute("data-theme-src");
 | 
				
			||||||
 | 
					    image.setAttribute("data-theme-src", tempSrc);
 | 
				
			||||||
// Dark/Light color scheme switch button
 | 
					  });
 | 
				
			||||||
document.querySelector("#nav-switch-theme").style.display = "inline";
 | 
					}
 | 
				
			||||||
document.querySelector("#nav-switch-theme").addEventListener("click", changeColorScheme);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
const changeColorScheme = () => {
 | 
					const changeColorScheme = () => {
 | 
				
			||||||
  // Use whatever users want
 | 
					  // Use whatever users want
 | 
				
			||||||
@@ -76,15 +75,15 @@ const changeColorScheme = () => {
 | 
				
			|||||||
  fixThemeImages();
 | 
					  fixThemeImages();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					navSections.forEach(navSection => {
 | 
				
			||||||
 | 
					  navSection.addEventListener("toggle", navSectionsToggle);
 | 
				
			||||||
 | 
					});
 | 
				
			||||||
 | 
					document.addEventListener("click", navSectionsClose);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					// Dark/Light color scheme switch button
 | 
				
			||||||
 | 
					document.querySelector("#nav-switch-theme").style.display = "inline";
 | 
				
			||||||
 | 
					document.querySelector("#nav-switch-theme").addEventListener("click", changeColorScheme);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Fix images in dark theme
 | 
					 | 
				
			||||||
function fixThemeImages() {
 | 
					 | 
				
			||||||
  document.querySelectorAll('[data-theme-src]').forEach((image) => {
 | 
					 | 
				
			||||||
    const tempSrc = image.src;
 | 
					 | 
				
			||||||
    image.src = image.getAttribute("data-theme-src");
 | 
					 | 
				
			||||||
    image.setAttribute("data-theme-src", tempSrc);
 | 
					 | 
				
			||||||
  });
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
if (localStorage.getItem("colorScheme") === "dark" ||
 | 
					if (localStorage.getItem("colorScheme") === "dark" ||
 | 
				
			||||||
    window.matchMedia("(prefers-color-scheme: dark)").matches ^
 | 
					    window.matchMedia("(prefers-color-scheme: dark)").matches ^
 | 
				
			||||||
    localStorage.getItem("colorScheme") === "light"
 | 
					    localStorage.getItem("colorScheme") === "light"
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user