Skip to content

Commit

Permalink
remove button-specific handler from stopwatchAreaListener - now handl…
Browse files Browse the repository at this point in the history
…ed by drySelector > relates #5 #8
  • Loading branch information
VirtualDOMinic committed Sep 8, 2018
1 parent 7a0b035 commit 3a7ae0c
Showing 1 changed file with 8 additions and 28 deletions.
36 changes: 8 additions & 28 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,13 @@ function updateTimerDisplay() {
convertToMinsSecs(timerState[timerState.userSelected].timeTakenMS);
}

document.getElementById("main-time-display")
.innerText = convertToMinsSecs(timerState.timeLeftMS);

if(timerState.timeLeftMS < 0){
document.getElementById("main-time-display")
.innerText = "Time up!";
} else {
document.getElementById("main-time-display")
.innerText = convertToMinsSecs(timerState.timeLeftMS);
}
console.log("updateTimerDisplay called")
}

Expand Down Expand Up @@ -160,30 +164,8 @@ stopwatchAreaListener = function() {
.addEventListener("click", function(x) {
if (x.target.id.includes("presenter")) {
drySelector(x.target);
} else if (x.target.nodeName.toLowerCase() === "button") {
console.log("button clicked!");
if (x.target.innerText === "select") {
x.target.innerText = "deselect";
} else {
x.target.innerText = "select";
}

if (x.target.innerText === "deselect") {
console.log("deselect initiated");
}

x.target.parentElement.parentElement.childNodes.forEach(function(y) {
if (x.target.parentElement.id !== y.id) {
y.classList.remove("selected");
y.classList.add("normal");
} else if (x.target.parentElement.id === y.id) {
y.classList.remove("normal");
y.classList.add("selected");
selectUserForTimer(y.id);
}
});
} else if (x.target.parentElement.id.includes("presenter")){
// this else if statement is to handle any div children that aren't the button
// this else if statement is to handle any div children
drySelector(x.target.parentElement)
}

Expand Down Expand Up @@ -250,8 +232,6 @@ basicTimer = function() {
console.log(timerSched, "timersched ID");
};

var dateNow = Date.now();

timerCB = function() {
console.log("Run: timerCB");
var timeTest = 795000;
Expand Down

0 comments on commit 3a7ae0c

Please sign in to comment.