Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function swapStyleSheet(sheet) {
- document.getElementById("pagestyle").setAttribute("href", sheet);
- }
- function initate() {
- baguetteBox.run('.galleryBaguetteBox');
- var styleSwag = document.getElementById("enableSwag");
- var swagEnable = false; //working with a boolean instead of a strin makes life easier
- let storedSwagEnable = localStorage.getItem('swagEnable'); //load strored swag
- if (storedSwagEnable != null) swagEnable = storedSwagEnable; //if there is a perviously stored value, write it to the swagEnable variable
- swapStyleSheet(swagEnable ? "styleSwag.css" : "style.css"); //set style
- styleSwag.onclick = function () {
- swagEnable = !swagEnable; //swagEnable is set tot the opposite of swagEnbable. true -> false or false -> true
- swapStyleSheet(swagEnable ? "styleSwag.css" : "style.css"); //ternery operator works like this: condition ? value-if-true : value-if-false
- localStorage.setItem('swagEnable', swagEnable); //store swag mode
- };
- }
- window.onload = initate;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement