-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
40 lines (38 loc) · 1.22 KB
/
Copy pathscript.js
File metadata and controls
40 lines (38 loc) · 1.22 KB
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
let buttons = document.querySelectorAll(".buttons");
let ceButton = document.querySelector('#ce');
let screen = document.querySelector(".screen-text");
//------------stylizing buttons
for (let i = 0; i < buttons.length; i++) {
buttons[i].onmouseover = function (){
//---debugging console.log("mouse_over");
this.style.border = "solid black 2px";
if (this == buttons[3]){
this.style.background = "#831a1a";
}else{
this.style.background = "#6d7279";
}
this.onmouseout = function (){
//---debugging console.log("mouse_out");
this.style.border = "solid #172837 2px";
if (this == buttons[3]){
this.style.background = "#a32222";
}else{
this.style.background = "#7a8289";
}
}
}
//----calculating
if (buttons[i].textContent == "="){
buttons[i].onclick = function (){
screen.value = eval(screen.value);
}
} else if (buttons[i].textContent == "CE"){
buttons[i].onclick = function (){
screen.value = "";
}
} else {
buttons[i].onclick = function (){
screen.value += this.textContent;
}
}
}