Compare commits

..

27 Commits

Author SHA1 Message Date
f57da84b34 Implement solution. 2020-06-11 10:45:08 +09:00
Ryan Sobol
9f424e9ebb Flex 2016-11-11 08:06:39 -08:00
Ryan Sobol
670a7de318 Improve the README 2016-11-11 07:42:24 -08:00
Ryan Sobol
3a2f06183f Improve the CSS 2016-11-11 07:42:07 -08:00
Ryan Sobol
2b226f0912 Improve the README 2016-11-11 07:07:44 -08:00
Ryan Sobol
6a99ac8ed0 Improve the README 2016-11-11 07:04:35 -08:00
Ryan Sobol
61ba5846f8 Improve the gif 2016-11-11 07:01:15 -08:00
Ryan Sobol
f2fa5eaa08 Remove screenshot 2016-11-11 06:47:29 -08:00
Ryan Sobol
2daab178da Improve the README 2016-11-11 06:46:41 -08:00
Ryan Sobol
7b724cc4dc Improve the README 2016-11-11 06:43:35 -08:00
Ryan Sobol
bbb7582d3e Improve the README 2016-11-11 06:40:56 -08:00
Ryan Sobol
01d5e8efc9 Improve the README 2016-11-11 06:39:50 -08:00
Ryan Sobol
f7b6b56f97 Improve the README 2016-11-11 06:33:45 -08:00
Ryan Sobol
4db1c28362 Improve the README 2016-11-11 06:33:10 -08:00
Ryan Sobol
104ac52aa7 Improve the screenshot 2016-11-11 06:30:40 -08:00
Ryan Sobol
289c0fd033 Improve the README 2016-11-11 06:29:57 -08:00
Ryan Sobol
6ba4d24e86 Rename 2016-11-11 05:51:41 -08:00
Ryan Sobol
ffc92b74d4 Tweak HTML and CSS 2016-11-11 05:49:28 -08:00
Ryan Sobol
bfec34aa0b Tweak HTML 2016-11-10 15:13:00 -08:00
mrjadaml
431312f75f order of tasks seemed backward. Also made the bouns a bit harder 2016-08-18 10:31:45 -07:00
Craig Quincy
495eff9794 Revert "working model with bonuses"
This reverts commit 8d168d8a3555dc4b872760bf0739f91c8dbf428d.
2016-08-11 18:05:58 -06:00
THACHER
8d168d8a35 working model with bonuses 2016-08-10 14:48:58 -07:00
Ken McGrady
203fd81c6a Rename spotlight to stoplight 2016-05-12 14:51:59 -07:00
Ken McGrady
10f46daf57 Move Screenshot back below 2016-05-12 10:53:37 -07:00
Ken McGrady
c0a7b0b853 Update README 2016-05-12 10:47:40 -07:00
Ken McGrady
8ab3a0c231 Update README 2016-05-12 10:26:56 -07:00
Ian Smith
6728934c84 updated readme 2016-05-12 09:08:39 -07:00

View File

@ -1,80 +1,23 @@
(function() {
'use strict';
const stopButton = document.querySelector('#stopButton');
const slowButton = document.querySelector('#slowButton');
const goButton = document.querySelector('#goButton');
const stopLight = document.querySelector('#stopLight');
const slowLight = document.querySelector('#slowLight');
const goLight = document.querySelector('#goLight');
// part 1
stopButton.addEventListener('click', () => {
stopLight.classList.toggle('stop');
// or...
// if (stopLight.classList.contains('stop')) {
// stopLight.classList.remove('stop');
// }
// else {
// stopLight.classList.add('stop');
// }
});
slowButton.addEventListener('click', () => {
slowLight.classList.toggle('slow');
});
goButton.addEventListener('click', () => {
goLight.classList.toggle('go');
});
// part 2
const handleMouseEnter = (event) => {
console.log(`Entered ${event.target.textContent} button`);
};
const handleMouseLeave = (event) => {
console.log(`Left ${event.target.textContent} button`);
};
stopButton.addEventListener('mouseenter', handleMouseEnter);
slowButton.addEventListener('mouseenter', handleMouseEnter);
goButton.addEventListener('mouseenter', handleMouseEnter);
stopButton.addEventListener('mouseleave', handleMouseLeave);
slowButton.addEventListener('mouseleave', handleMouseLeave);
goButton.addEventListener('mouseleave', handleMouseLeave);
// bonus
const controls = document.querySelector('#controls');
controls.addEventListener('click', (event) => {
if (event.target === controls) {
return;
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.")
}
})
let status;
if (event.target === stopButton) {
status = stopLight.classList.contains('stop') ? 'on' : 'off';
// or...
// if (stopLight.classList.contains('stop')) {
// status = 'on';
// }
// else {
// status = '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.")
})
}
else if (event.target === slowButton) {
status = slowLight.classList.contains('slow') ? 'on' : 'off';
}
else {
status = goLight.classList.contains('go') ? 'on' : 'off';
}
console.log(`${event.target.textContent} bulb ${status}`);
});
})();
})