-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
46 lines (38 loc) · 1.42 KB
/
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import Caclculator from "./app.js";
const numberButtons = document.querySelectorAll("[number-button]");
const operationButtons = document.querySelectorAll("[operation-button]");
const allClearButton = document.querySelector("#all-clear-button");
const deleteButton = document.querySelector("[delete-button]");
const computeButton = document.querySelector("[compute-button]");
const singChangeButton = document.querySelector("[sign-change-button]");
const previousInputText = document.querySelector(".previous-input");
const currentInputText = document.querySelector(".current-input");
const caclculator = new Caclculator(previousInputText, currentInputText);
numberButtons.forEach((button) => {
button.addEventListener("click", () => {
caclculator.appendNumber(button.innerText);
caclculator.updateDisplay();
});
});
operationButtons.forEach((button) => {
button.addEventListener("click", () => {
caclculator.selectOperation(button.innerText);
caclculator.updateDisplay();
});
});
computeButton.addEventListener("click", () => {
caclculator.compute();
caclculator.updateDisplay();
});
allClearButton.addEventListener("click", () => {
caclculator.clear();
caclculator.updateDisplay();
});
deleteButton.addEventListener("click", () => {
caclculator.delete();
caclculator.updateDisplay();
});
singChangeButton.addEventListener("click", () => {
caclculator.numberSingChange();
caclculator.updateDisplay();
});