Add functionality to clear top screen
This commit is contained in:
parent
61a3c3b929
commit
5cb8f57879
1 changed files with 4 additions and 4 deletions
|
|
@ -16,6 +16,7 @@ function displayToScreen() {
|
||||||
mainScreen.textContent = calc.calculate(topScreen.textContent);
|
mainScreen.textContent = calc.calculate(topScreen.textContent);
|
||||||
} else if (this.classList.contains("all")) {
|
} else if (this.classList.contains("all")) {
|
||||||
mainScreen.textContent = "0";
|
mainScreen.textContent = "0";
|
||||||
|
topScreen.textContent = "";
|
||||||
} else if (this.classList.contains("error") && mainScreen.textContent !== "0") {
|
} else if (this.classList.contains("error") && mainScreen.textContent !== "0") {
|
||||||
mainScreen.textContent = mainScreen.textContent.trimEnd()
|
mainScreen.textContent = mainScreen.textContent.trimEnd()
|
||||||
mainScreen.textContent = mainScreen.textContent.slice(0, -1);
|
mainScreen.textContent = mainScreen.textContent.slice(0, -1);
|
||||||
|
|
@ -30,6 +31,7 @@ function displayToScreen() {
|
||||||
} else {
|
} else {
|
||||||
if (this.className == "operator") {
|
if (this.className == "operator") {
|
||||||
let screenContent = topScreen.textContent;
|
let screenContent = topScreen.textContent;
|
||||||
|
topScreen.textContent += mainScreen.textContent + " " + this.textContent + " ";
|
||||||
|
|
||||||
// Add some logic for handling negatives with -
|
// Add some logic for handling negatives with -
|
||||||
// Add key support
|
// Add key support
|
||||||
|
|
@ -45,10 +47,8 @@ function displayToScreen() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
topScreen.textContent += mainScreen.textContent + " " + this.textContent + " ";
|
|
||||||
mainScreen.textContent = "0";
|
|
||||||
|
|
||||||
} else if (mainScreen.textContent === "0" && this.className == "num") {
|
} else if ((mainScreen.textContent === "0") && this.className == "num") {
|
||||||
mainScreen.textContent = this.textContent;
|
mainScreen.textContent = this.textContent;
|
||||||
} else if (this.className == "num") {
|
} else if (this.className == "num") {
|
||||||
mainScreen.textContent += this.textContent;
|
mainScreen.textContent += this.textContent;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue