Skip to content

Commit

Permalink
delete unused functions > relates #8
Browse files Browse the repository at this point in the history
  • Loading branch information
VirtualDOMinic committed Sep 8, 2018
1 parent e7d9476 commit 0653120
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ <h1>Group stopwatch trial (WIP)</h1>
<section id="timer-stopwatch-area">
<div id="timer" class="hidden">
<div>
<span id="main-time-display">0:00</span>
<span id="main-timer-display">0:00</span>
</div>
<button id="main-timer-start">Start main timer</button>
<button id="main-timer-start-btn">Start main timer</button>
</div>
<div id="stopwatch-area"></div>
</section>
Expand Down
17 changes: 8 additions & 9 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ var stopwatchArea = document.getElementById("stopwatch-area");
var noticeArea = document.getElementById("notice-area");
var timerArea = document.getElementById("timer");

var mainStartBtn = document.getElementById("main-timer-start");
var mainStartBtn = document.getElementById("main-timer-start-btn");
var mainTimerDisplay = document.getElementById("main-timer-display")

if (!window) {
console.log("no window object! This scripts gonna fail");
Expand Down Expand Up @@ -87,11 +88,9 @@ function updateTimerDisplay() {
}

if(timerState.timeLeftMS < 0){
document.getElementById("main-time-display")
.innerText = "Time up!";
mainTimerDisplay.innerText = "Time up!";
} else {
document.getElementById("main-time-display")
.innerText = convertToMinsSecs(timerState.timeLeftMS);
mainTimerDisplay.innerText = convertToMinsSecs(timerState.timeLeftMS);
}
console.log("updateTimerDisplay called")
}
Expand Down Expand Up @@ -160,10 +159,10 @@ stopwatchAreaListener = function() {
.getElementById("stopwatch-area")
.addEventListener("click", function(x) {
if (x.target.id.includes("presenter")) {
drySelector(x.target);
divSelectionHandler(x.target);
} else if (x.target.parentElement.id.includes("presenter")){
// this else if statement is to handle any div children
drySelector(x.target.parentElement)
divSelectionHandler(x.target.parentElement)
}

});
Expand Down Expand Up @@ -256,8 +255,8 @@ formatTime = function(ms) {

// CODE IS (WAS?) WAY TOO WET! Below, I'm making a function to update the div style, button text and userSelected, with input being the presenter div that has been clicked:

function drySelector(divClicked) {
console.log("drySelector called");
function divSelectionHandler(divClicked) {
console.log("divSelectionHandler called");
divClicked.parentElement.childNodes.forEach(function(div) {
if (div.id === divClicked.id) {
if (div.id === timerState.userSelected) {
Expand Down

0 comments on commit 0653120

Please sign in to comment.