Skip to content

Lab Assignment - 8 #76

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
51 changes: 39 additions & 12 deletions javascript/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,79 @@ const milUniElement = document.getElementById('milUni');
const splitsElement = document.getElementById('splits');

function printTime() {
// ... your code goes here
printMinutes();
printSeconds();
printMilliseconds();
}

function printMinutes() {
// ... your code goes here
minUni.innerHTML = chronometer.computeTwoDigitNumber(chronometer.getMinutes())[1];
minDec.innerHTML = chronometer.computeTwoDigitNumber(chronometer.getMinutes())[0];
}

function printSeconds() {
// ... your code goes here
secUni.innerHTML = chronometer.computeTwoDigitNumber(chronometer.getSeconds())[1];
secDec.innerHTML = chronometer.computeTwoDigitNumber(chronometer.getSeconds())[0];
}

// ==> BONUS
function printMilliseconds() {
// ... your code goes here
milUni.innerHTML = chronometer.computeTwoDigitNumber(chronometer.getMilliSeconds())[1];
milDec.innerHTML = chronometer.computeTwoDigitNumber(chronometer.getMilliSeconds())[0];
}

function printSplit() {
// ... your code goes here
let li = document.createElement('li');
li.innerHTML = chronometer.split();
splits.appendChild(li);
}

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

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

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

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

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

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

// Reset/Split Button
btnRightElement.addEventListener('click', () => {
// ... your code goes here
if (btnRight.classList.contains('reset')){
chronometer.reset();
clearSplits();
printTime();
}
else{
printSplit();
}
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"test:watch": "jest --watchAll --verbose=false"
},
"devDependencies": {
"jest": "^26.6.3",
"jest": "^29.7.0",
"jest-html-reporter": "^3.3.0",
"jest-junit": "^12.0.0"
},
Expand Down