Guest User

Untitled

a guest
Sep 28th, 2016
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.           <div id="banner" onclick="rotateTheme()">
  2.             <script>
  3.               var themeIndex = 3; // determines starting theme, tracks current theme
  4.               var themeColor = ["rgba(255,227,206,1.0)","rgba(24,56,94,1.0)","rgba(153,153,153,1.0)","rgba(171,166,254,1.0)"];
  5.               var themeColorTint = ["rgba(255,227,206,0.5)","rgba(24,56,94,0.5)","rgba(153,153,153,0.5)","rgba(171,166,254,0.5)"];
  6.               if (themeColor.length != themeColorTint.length) console.log("Color and tint array lengths mismatch.");
  7.               else console.log("Loaded " + themeColor.length + " themes.");
  8.  
  9.               function setTheme(index) { // allows fo
  10.                 console.log("Initial theme: " + index + ".");
  11.                 document.getElementById("banner").style.backgroundImage = "url('res/banner" + index + ".png')";
  12.                 console.log("Initial theme color: " + themeColor[index-1] + ".");
  13.                 document.documentElement.style.setProperty("--main-color",themeColor[index-1],null);
  14.                 document.documentElement.style.setProperty("--main-color-tint",themeColorTint[index-1],null);              }
  15.  
  16.               function rotateTheme() {
  17.                 themeIndex++;
  18.                 if (themeIndex > themeColor.length) themeIndex=1;
  19.                 console.log("Switching to theme: " + themeIndex + ".");
  20.                 document.getElementById("banner").style.backgroundImage = "url('res/banner" + themeIndex + ".png')";
  21.                 console.log("Switching to theme color: " + themeColor[themeIndex-1] + ".");
  22.                 document.documentElement.style.setProperty("--main-color",themeColor[themeIndex-1],null);
  23.                 document.documentElement.style.setProperty("--main-color-tint",themeColorTint[themeIndex-1],null);
  24.               }
  25.  
  26.               setTheme(themeIndex); // set initial theme
  27.             </script>
  28.           </div>
Advertisement
Add Comment
Please, Sign In to add comment