function darkModeListener() {
    document.querySelector("html").classList.toggle("dark");
    if (localStorage.theme == 'light') {
        localStorage.theme = 'dark';
    } else {
        localStorage.theme = 'light';
    }
}

document.querySelector("input[type='checkbox']#toogleTheme").addEventListener("click", darkModeListener);

if(localStorage.theme) {
    if (localStorage.theme == 'light') {
        if (document.querySelector("html").classList.contains('dark')) {
            document.querySelector("html").classList.toggle("dark");
        }
        document.getElementById("toogleTheme").checked = true;
    }
} else {
    // Default Dark Theme
    localStorage.theme = 'dark';
}