-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
124 lines (99 loc) · 2.98 KB
/
index.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
let mainbg = document.querySelector(".main");
let thems = document.querySelector(".thems");
let chkbtn = document.querySelector(".chkbtn");
let screen = document.querySelector(".screen");
let btns = document.querySelector(".btns");
let buttons = document.querySelectorAll("button");
const blubtns = document.querySelectorAll(".blubtn");
let redbtn = document.querySelector(".redbtn");
const btn1 = () => {
mainbg.classList.remove("secbg", "thibg");
thems.classList.remove("secthm", "thithm");
chkbtn.classList.remove("secchk", "thichk");
screen.classList.remove("secscrn", "thiscrn");
btns.classList.remove("secbtns", "thibtns");
for (const button of buttons) {
button.classList.remove("secbtnsbg", "thibtnsbg");
}
for (const blubtn of blubtns) {
blubtn.classList.remove("secblubtn", "thiblubtn");
}
redbtn.classList.remove("secredbtn", "thiredbtn");
};
const btn2 = () => {
mainbg.classList.remove("thibg");
thems.classList.remove("thithm");
chkbtn.classList.remove("thichk");
screen.classList.remove("thiscrn");
btns.classList.remove("thibtns");
for (const button of buttons) {
button.classList.remove("thibtnsbg");
}
for (const blubtn of blubtns) {
blubtn.classList.remove("thiblubtn");
}
redbtn.classList.remove("thiredbtn");
mainbg.classList.add("secbg");
thems.classList.add("secthm");
chkbtn.classList.add("secchk");
screen.classList.add("secscrn");
btns.classList.add("secbtns");
for (const button of buttons) {
button.classList.add("secbtnsbg");
}
for (const blubtn of blubtns) {
blubtn.classList.add("secblubtn");
}
redbtn.classList.add("secredbtn");
};
const btn3 = () => {
mainbg.classList.add("thibg");
thems.classList.add("thithm");
chkbtn.classList.add("thichk");
screen.classList.add("thiscrn");
btns.classList.add("thibtns");
for (const button of buttons) {
button.classList.add("thibtnsbg");
}
for (const blubtn of blubtns) {
blubtn.classList.add("thiblubtn");
}
redbtn.classList.add("thiredbtn");
};
// all cal code
// for reset button
let scr = document.getElementById('scrnum');
const allbtns=document.querySelectorAll('button')
let bt;
let scrrenvalue = "";
for (item of allbtns) {
item.addEventListener('click', (e) => {
bt = e.target.innerText;
if (bt == 'x') {
bt = '*';
scrrenvalue += bt;
scr.innerText = scrrenvalue;
}
else if (bt == '=') {
if(!scr.innerText)
{
return
}
scrrenvalue = eval (scrrenvalue);
scr.innerText= scrrenvalue;
}
else if (bt == 'RESET') {
scrrenvalue = "";
scr.innerText = scrrenvalue;
}
else if (bt == 'DEL') {
scrrenvalue=scr.innerText;
scrrenvalue=scrrenvalue.slice(0,-1);
scr.innerText = scrrenvalue
}
else{
scrrenvalue +=bt;
scr.innerText=scrrenvalue;
}
})
}