Sha256: 5906b3784aba982515f5bf7cf6073c157959b0bd087139f2d52ded35adf54e6b
Contents?: true
Size: 1020 Bytes
Versions: 2
Compression:
Stored size: 1020 Bytes
Contents
function onLoad() { var themeSelector = document.getElementById('themeSelector'); for (var themeName in themeMap) { var opt = document.createElement('option'); opt.value = themeName; opt.innerHTML = capitalizeFirstLetter(themeName); themeSelector.appendChild(opt); } if (localStorage.getItem('theme') != null) { themeSelector.value = localStorage.getItem('theme'); toggleTheme(); } } function toggleTheme() { var themeName = themeSelector.value; localStorage.setItem('theme', themeName); var element = document.getElementsByTagName('html')[0]; changeTheme(element, themeMap[themeName]); } function changeTheme(element, theme) { element.style.setProperty("--primary-background-color", theme['background-color']); element.style.setProperty("--primary-text-color", theme['text-color']); element.style.setProperty("--primary-highlight-color", theme['highlight-color']); } function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); }
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dev-portfolio-blog-0.1.9 | assets/js/script.js |
dev-portfolio-blog-0.1.8 | assets/js/script.js |