Compare commits
27 Commits
Author | SHA1 | Date |
---|---|---|
Joshua Sigona | f57da84b34 | 5 years ago |
Ryan Sobol | 9f424e9ebb | 8 years ago |
Ryan Sobol | 670a7de318 | 8 years ago |
Ryan Sobol | 3a2f06183f | 8 years ago |
Ryan Sobol | 2b226f0912 | 8 years ago |
Ryan Sobol | 6a99ac8ed0 | 8 years ago |
Ryan Sobol | 61ba5846f8 | 8 years ago |
Ryan Sobol | f2fa5eaa08 | 8 years ago |
Ryan Sobol | 2daab178da | 8 years ago |
Ryan Sobol | 7b724cc4dc | 8 years ago |
Ryan Sobol | bbb7582d3e | 8 years ago |
Ryan Sobol | 01d5e8efc9 | 8 years ago |
Ryan Sobol | f7b6b56f97 | 8 years ago |
Ryan Sobol | 4db1c28362 | 8 years ago |
Ryan Sobol | 104ac52aa7 | 8 years ago |
Ryan Sobol | 289c0fd033 | 8 years ago |
Ryan Sobol | 6ba4d24e86 | 8 years ago |
Ryan Sobol | ffc92b74d4 | 8 years ago |
Ryan Sobol | bfec34aa0b | 8 years ago |
mrjadaml | 431312f75f | 8 years ago |
Craig Quincy | 495eff9794 | 8 years ago |
THACHER | 8d168d8a35 | 8 years ago |
Ken McGrady | 203fd81c6a | 9 years ago |
Ken McGrady | 10f46daf57 | 9 years ago |
Ken McGrady | c0a7b0b853 | 9 years ago |
Ken McGrady | 8ab3a0c231 | 9 years ago |
Ian Smith | 6728934c84 | 9 years ago |
@ -1,33 +1,49 @@ |
||||
body { |
||||
display: flex; |
||||
} |
||||
|
||||
#controls { |
||||
float: left; |
||||
padding-top: 30px; |
||||
margin-top: 30px; |
||||
} |
||||
|
||||
.button { |
||||
background-color: gray; |
||||
color: white; |
||||
border-radius: 15px; |
||||
color: white; |
||||
cursor: pointer; |
||||
font-size: 2em; |
||||
font-weight: bold; |
||||
margin: 90px 40px; |
||||
padding: 20px; |
||||
text-align: center; |
||||
margin: 90px 40px; |
||||
cursor: pointer; |
||||
} |
||||
|
||||
#traffic-light { |
||||
height: 550px; |
||||
width: 200px; |
||||
float: left; |
||||
background-color: #ababab; |
||||
border-radius: 40px; |
||||
margin: 30px 0; |
||||
height: 550px; |
||||
padding: 20px; |
||||
width: 200px; |
||||
} |
||||
|
||||
.bulb { |
||||
height: 150px; |
||||
width: 150px; |
||||
background-color: #111; |
||||
border-radius: 50%; |
||||
margin: 25px auto; |
||||
transition: background 500ms; |
||||
height: 150px; |
||||
transition: background 300ms; |
||||
width: 150px; |
||||
} |
||||
|
||||
.stop { |
||||
background-color: red; |
||||
} |
||||
|
||||
.slow { |
||||
background-color: orange; |
||||
} |
||||
|
||||
.go { |
||||
background-color: green; |
||||
} |
@ -0,0 +1,23 @@ |
||||
document.addEventListener("DOMContentLoaded",()=>{ |
||||
document.getElementById("controls").addEventListener("click",(clicked)=>{ |
||||
var lightPrefix = clicked.target.id.replace("Button",""); |
||||
var targetLight = document.getElementById(lightPrefix+"Light"); |
||||
if (!targetLight.classList.contains(lightPrefix)) { |
||||
targetLight.classList.add(lightPrefix); |
||||
console.log(lightPrefix+" bulb on.") |
||||
} else { |
||||
targetLight.classList.remove(lightPrefix); |
||||
console.log(lightPrefix+" bulb off.") |
||||
} |
||||
}) |
||||
|
||||
var buttons = document.getElementsByClassName("button"); |
||||
for (var i=0;i<buttons.length;i++) { |
||||
buttons[i].addEventListener("mouseenter",(e)=>{ |
||||
console.log("Entered "+e.target.innerHTML+" button.") |
||||
}) |
||||
buttons[i].addEventListener("mouseleave",(e)=>{ |
||||
console.log("Left "+e.target.innerHTML+" button.") |
||||
}) |
||||
} |
||||
}) |
Binary file not shown.
@ -1,10 +0,0 @@ |
||||
/* |
||||
Write JS to make this stoplight work. |
||||
|
||||
When I click on the 'stop' button, |
||||
the top light should turn red. |
||||
When I click on the 'slow' button |
||||
the middle light should turn orange. |
||||
When I click on the 'go' button |
||||
the bottom light should turn green. |
||||
*/ |
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 2.0 MiB |
Loading…
Reference in new issue