Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update #1928

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

update #1928

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 51 additions & 16 deletions javascript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,87 @@ const milUniElement = document.getElementById('milUni');
const splitsElement = document.getElementById('splits');

function printTime() {
// ... your code goes here
// Here we're going to call printMinutes + printSeconds
setInterval(() => {
let seconds = printSeconds();
let minutes = printMinutes();

minDecElement.innerText = minutes[0];
minUniElement.innerText = minutes[1];
secUniElement.innerText = seconds[1];
secDecElement.innerText = seconds[0];
}, 1000);
}

function printMinutes() {
// ... your code goes here
return chronometer.computeTwoDigitNumber(chronometer.getMinutes());
}

function printSeconds() {
// ... your code goes here
}

// ==> BONUS
function printMilliseconds() {
// ... your code goes here
return chronometer.computeTwoDigitNumber(chronometer.getSeconds());
}

function printSplit() {
// ... your code goes here
// We receive the string from the split method inside the chronometer
let timestamp = chronometer.split();

// Create an element to insert into the DOM
let listItemElement = document.createElement('li');
// Assign the value of listItemElement to timestamp
listItemElement.innerText = timestamp;
// Point to the DOM selection variable containing the splits id and append a child :)
splitsElement.appendChild(listItemElement);
}

function clearSplits() {
// ... your code goes here
splitsElement.innerHTML = '';
}

function setStopBtn() {
// ... your code goes here
btnLeftElement.innerText = 'STOP';
btnLeftElement.className = 'btn stop';
}

function setSplitBtn() {
// ... your code goes here
btnRightElement.innerText = 'SPLIT';
btnRightElement.className = 'btn split';
}

function setStartBtn() {
// ... your code goes here
btnLeftElement.innerText = 'START';
btnLeftElement.className = 'btn start';
}

function setResetBtn() {
// ... your code goes here
btnRightElement.innerText = 'RESET';
btnRightElement.className = 'btn reset';
}

// Start/Stop Button
btnLeftElement.addEventListener('click', () => {
// ... your code goes here
if (btnLeftElement.innerText === 'START') {
setStopBtn();
chronometer.start();
printTime();
setSplitBtn();
} else {
setStartBtn();
setResetBtn();
chronometer.stop();
}
});

// Reset/Split Button
btnRightElement.addEventListener('click', () => {
// ... your code goes here
if (btnRightElement.innerText === 'RESET') {
chronometer.stop();
chronometer.reset();
minDecElement.innerText = '0';
minUniElement.innerText = '0';
secUniElement.innerText = '0';
secDecElement.innerText = '0';
clearSplits();
} else {
printSplit();
}
});