Skip to content
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
42 changes: 36 additions & 6 deletions static/calculator.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,33 +11,63 @@ body {
width: 400px;
background-color: black;
color: white;
border: 8px double blue;
border-radius: 10px;
margin: 25px auto;
}

.screen {
color: white;
font-size: 40px;
height: 80px;
font-family: "Courier New", Courier, monospace;
text-align: right;
padding: 20px 5px;
border-bottom: 8px double blue;
}

.calc-button {
background-color: #d8d9db;
background-color: #dadfe9;
color: black;
font-weight: 500;
height: 100px;
width: 24.5%;
border: none;
border-radius: 0;
border-radius: 10px;
font-size: 40px;
cursor: pointer;
}

#c{
background-color: rgb(72, 240, 72);
}

#c:hover{
background-color: rgb(6, 248, 6);
}

#percentage{
background-color:rgb(231, 49, 49);
}

#percentage:hover{
background-color:red;
}

#back{
background-color: rgb(214, 214, 60);
}

#back:hover{
background-color: yellow;
}

.calc-button:hover {
background-color: #ebebeb;
}

.calc-button:active {
background-color: #bbbcbe;
background-color: #d6d8db;
}

.double {
Expand All @@ -49,16 +79,16 @@ body {
}

.calc-button:last-child {
background-color: #df974c;
background-color: #4cd5df;
color: white;
}

.calc-button:last-child:hover {
background-color: #dfb07e;
background-color: #04e8f8;
}

.calc-button:last-child:active {
background-color: #dd8d37;
background-color: #04e8f8;
}

.calc-button-row {
Expand Down
8 changes: 5 additions & 3 deletions static/calculator.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@

<section class="calc-buttons">
<div class="calc-button-row">
<button class="calc-button double ">C</button>
<button class="calc-button">←</button>
<button class="calc-button" id="c">C</button>
<button class="calc-button" id="percentage">%</button>
<button class="calc-button" id="back">←</button>
<button class="calc-button">÷</button>
</div>
<div class="calc-button-row">
Expand All @@ -40,7 +41,8 @@
<button class="calc-button">+</button>
</div>
<div class="calc-button-row">
<button class="calc-button triple">0</button>
<button class="calc-button double">00</button>
<button class="calc-button">0</button>
<button class="calc-button">=</button>
</div>
</section>
Expand Down
6 changes: 5 additions & 1 deletion static/calculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,12 @@ function flushOperation(intBuffer) {
runningTotal -= intBuffer;
} else if (previousOperator === "×") {
runningTotal *= intBuffer;
} else {
} else if(previousOperator === "÷") {
runningTotal /= intBuffer;
}
else{
runningTotal /= 100;
}
}

function handleSymbol(value) {
Expand Down Expand Up @@ -77,6 +80,7 @@ function handleSymbol(value) {
case "-":
case "×":
case "÷":
case "%":
handleMath(value);
break;
}
Expand Down