From 38dba32312a01bfcfcca05f5bcda67178f9234c6 Mon Sep 17 00:00:00 2001 From: Prince Luah Marwiah Date: Wed, 10 May 2023 19:56:17 +0000 Subject: [PATCH] Make some changes with the functionality of the app --- index.css | 31 ++++++++++++++++++++++--------- index.html | 15 ++++++++------- index.js | 51 ++++++++++++++++++++++++++++++++++----------------- 3 files changed, 64 insertions(+), 33 deletions(-) diff --git a/index.css b/index.css index b20f15e..c6183c9 100644 --- a/index.css +++ b/index.css @@ -4,8 +4,8 @@ padding: 0px; border: 2px solid blue; border-radius: 5px; - width: 550px; - height: 600px; + width: 600px; + height: 670px; background: rgb(241, 183, 245); text-align: center; } @@ -13,19 +13,19 @@ #teamOne{ /* border: 2px solid rgb(1, 0, 18); */ border-bottom: 1px solid black; - width: 550px; - height: 270px; + width: 600px; + height: 320px; } #header{ color: blue; - font-size: 40px; + font-size: 35px; font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; } .scores{ color: black; - font-size: 90px; + font-size: 80px; font-weight: bolder; } @@ -34,9 +34,9 @@ button{ border: 1px solid rgb(101, 7, 208); border-radius: 3px; margin-top: -8px; - width: 50px; - height: 40px; - font-size: 25px; + width: 40px; + height: 30px; + font-size: 20px; font-weight: bolder; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; } @@ -72,4 +72,17 @@ button:hover{ } .losing{ color: darkred; +} + +#home-delete-btn, #away-delete-btn { + color: red; + width: 60px; + height: 25px; + font-size: 15px; + text-transform: uppercase; +} + +#home-delete-btn:hover, #away-delete-btn:hover { + background: black; + color: white; } \ No newline at end of file diff --git a/index.html b/index.html index 7432d67..30d7b6b 100644 --- a/index.html +++ b/index.html @@ -14,24 +14,25 @@

HOME TEAM

0

- +

+ + - -

AWAY TEAM

0

- -
-
+

+ + +
+
- \ No newline at end of file diff --git a/index.js b/index.js index b8a7086..82ff472 100644 --- a/index.js +++ b/index.js @@ -1,22 +1,20 @@ -// function status(){ -// if(currentHomeScore > currentAwayScore){ -// currentHomeScore.classList.add(winning); -// currentAwayScore.classList.add(loser); -// }else if (currentAwayScore > currentHomeScore) { -// currentAwayScore.classList.add(winning) -// currentHomeScore.classList.add(loser) -// } else { - -// } -// } +function scoreStatus(){ + if(currentHomeScore > currentAwayScore){ + homeScore.classList.add("winning"); + }else if (currentAwayScore > currentHomeScore) { + awayScore.classList.add("winning"); + } else { + homeScore.classList.remove("winning"); + awayScore.classList.remove("winning"); + } +} let currentHomeScore = 0; const addHomeBtnOne = document.getElementById("homeBtnOne"); const addHomeBtnTwo = document.getElementById("homeBtnTwo"); const addHomeBtnThree = document.getElementById("homeBtnThree"); - // home score let homeScore = document.getElementById("home-score"); @@ -34,27 +32,25 @@ function addThree() { currentHomeScore += 3; } - addHomeBtnOne.addEventListener("click", function() { addOne() homeScore.innerText = currentHomeScore; + scoreStatus() }) addHomeBtnTwo.addEventListener("click", function() { addTwo() homeScore.innerText = currentHomeScore; + scoreStatus() }) addHomeBtnThree.addEventListener("click", function() { addThree() homeScore.innerText = currentHomeScore; + scoreStatus() }); -// function to minus 1 form the score -// function deleteBtn(){ -// currentHomeScore -= 1; -// } let currentAwayScore = 0; @@ -82,16 +78,19 @@ function addAwayThree() { addAwayBtnOne.addEventListener("click", function() { addAwayOne() awayScore.innerText = currentAwayScore; + scoreStatus() }) addAwayBtnTwo.addEventListener("click", function() { addAwayTwo() awayScore.innerText = currentAwayScore; + scoreStatus() }) addAwayBtnThree.addEventListener("click", function() { addAwayThree() awayScore.innerText = currentAwayScore; + scoreStatus() }); function resert() { @@ -100,3 +99,21 @@ function resert() { homeScore.innerHTML = currentHomeScore; awayScore.innerHTML = currentAwayScore; } + +let homeDeleteBtn = document.getElementById("home-delete-btn"); +let awayDeleteBtn = document.getElementById("away-delete-btn"); + +function deleteOne() { + currentHomeScore -= 1; + currentAwayScore -= 1; +} +homeDeleteBtn.addEventListener("click", function() { + deleteOne() + homeScore.innerText = currentHomeScore; +}) + +awayDeleteBtn.addEventListener("click", function() { + deleteOne() + awayScore.innerText = currentAwayScore; +}) +