function getCookie(name) { var v = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)'); return v ? v[2] : null; } function setCookie(name, value, days) { var d = new Date; d.setTime(d.getTime() + 24 * 60 * 60 * 1000 * days); document.cookie = name + "=" + value + ";path=/;expires=" + d.toGMTString(); } function deleteCookie(name) { setCookie(name, '', -1); } // end cookie.js start jscrall var setTheme = function (theme) { if (theme === 'dark') { // dark $( "body" ).removeClass("standard"); $( "body" ).addClass( "dark" ); $(".inner-switch").text("ON"); setCookie('Theme', 'dark', 30); } else { $("body").removeClass("dark"); $("body").addClass("standard"); $(".inner-switch").text("OFF"); setCookie('Theme', 'standard', 30); } }; currentTheme = getCookie('Theme'); setTheme(currentTheme); $( ".inner-switch" ).on("click", function() { if ($("body").hasClass("dark")) { // standard setTheme('standard'); } else { // dark mode setTheme('dark'); } });