* Summary: function that adds or removes the attribute 'data-theme' depending if * the switch is 'on' or 'off'. * * Description: initTheme is a function that uses localStorage from JavaScript DOM, * to store the value of the HTML switch. If the switch was already switched to * 'on' it will set
()
| 20 | * @return {void} |
| 21 | */ |
| 22 | function initTheme() { |
| 23 | var currentTheme = localStorage.getItem("currentTheme"); |
| 24 | |
| 25 | if (currentTheme == null) { |
| 26 | document.body.removeAttribute("data-theme") |
| 27 | } else { |
| 28 | document.body.setAttribute("data-theme", currentTheme) |
| 29 | $("#theme-selector").val(currentTheme).change(); |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Summary: resetTheme checks if the switch is 'on' or 'off' and if it is toggled |