Created
December 9, 2014 05:40
-
-
Save scottwall0/4d7932d0d209baf89ec5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var lock = false; | |
var lock1 = document.getElementById('lock1'); | |
var lock2 = document.getElementById('lock2'); | |
var lock3 = document.getElementById('lock2'); | |
var lock4 = document.getElementById('lock3'); | |
var lock4 = document.getElementById('lock4'); | |
//This Function Generates the Colors | |
function chooseColor() { | |
var R = Math.floor(Math.random() * 255); | |
var G = Math.floor(Math.random() * 255); | |
var B = Math.floor(Math.random() * 255); | |
return "rgb" + "(" + R + "," + G + "," + B + ")"; | |
} | |
//This Function Toggles the Lock Switches | |
function isLocked() { | |
lock = !lock | |
return lock; | |
} | |
//This Generates the color for square one, determining if it's locked or not | |
function color1Generate() { | |
lock1.onclick = function() {isLocked()}; | |
if (lock == false) { | |
return chooseColor(); | |
} | |
} | |
//This is the function powering the Go! button | |
function Go() { | |
document.getElementById("color1").style.background = color1Generate(); | |
document.getElementById("color2").style.background = chooseColor(); | |
document.getElementById("color3").style.background = chooseColor(); | |
document.getElementById("color4").style.background = chooseColor(); | |
document.getElementById("color5").style.background = chooseColor(); | |
} | |
//This calls the function on the God button | |
document.getElementById('generateColors').onclick = function() {Go()}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment