Skip to content
This repository was archived by the owner on Feb 10, 2024. It is now read-only.

changes to script and css #46

Open
wants to merge 1 commit 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
56 changes: 18 additions & 38 deletions scripts/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,45 +54,10 @@ function keyboardInputHandler(e) {
//grabbing the liveScreen

//numbers
if (e.key === "0") {
res.value += "0";
} else if (e.key === "1") {
res.value += "1";
} else if (e.key === "2") {
res.value += "2";
} else if (e.key === "3") {
res.value += "3";
} else if (e.key === "4") {
res.value += "4";
} else if (e.key === "5") {
res.value += "5";
} else if (e.key === "6") {
res.value += "6";
} else if (e.key === "7") {
res.value += "7";
} else if (e.key === "7") {
res.value += "7";
} else if (e.key === "8") {
res.value += "8";
} else if (e.key === "9") {
res.value += "9";
}
checkNumbers(e.key)

//operators
if (e.key === "+") {
res.value += "+";
} else if (e.key === "-") {
res.value += "-";
} else if (e.key === "*") {
res.value += "*";
} else if (e.key === "/") {
res.value += "/";
}

//decimal key
if (e.key === ".") {
res.value += ".";
}
//checking operators & decimal key
checkOperator(e.key)

//press enter to see result
if (e.key === "Enter") {
Expand All @@ -106,3 +71,18 @@ function keyboardInputHandler(e) {
res.value = resultInput.substring(0, res.value.length - 1);
}
}

function checkNumbers(digit){
if (digit === "0" || digit === "1" || digit === "2" || digit === "3" || digit === "4"
|| digit === "5" || digit === "6" || digit === "7" || digit === "8" || digit === "9"){
res.value += digit
}
}

function checkOperator(operator){
if(operator === "+" || operator === "-" || operator === "*" || operator === "/"
|| operator === "."){
res.value += operator;
}

}
6 changes: 6 additions & 0 deletions styles/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ input[type="button"]:hover {
background-color: rgb(255, 42, 42);
}

#clear-button:hover {
color: #fff;
background-color: rgb(11, 96, 176);

}

a {
text-decoration: none;
color: #fff;
Expand Down
5 changes: 5 additions & 0 deletions styles/light.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ input[type="button"]:hover {
background-color: rgb(255, 25, 25);
}

#clear-button:hover{
color: #fff;
background-color: rgb(11, 96, 176);
}

a {
text-decoration: none;
color: #fff;
Expand Down