-
Notifications
You must be signed in to change notification settings - Fork 0
/
grid3.htm
209 lines (184 loc) · 6.2 KB
/
grid3.htm
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>grid calculator</title>
<script src="https://kit.fontawesome.com/5b728db556.js" crossorigin="anonymous"></script>
<!-- <link rel="font-family" href="DIGITAL-7.TTF"> -->
<style>
@font-face {
font-family: 'DIGITAL-7';
src: url('DIGITAL-7.TTF');
}
*{
box-sizing: border-box;
}
body{
margin: 0;
padding: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
background-color: rgb(255, 255, 255);
}
.calculator{
display: grid;
grid-template-columns: repeat(4,1fr);
grid-template-rows: repeat(6,1fr);
background-color: rgba(246, 212, 165, 0.366);
height: 500px;
width: 300px;
border: 1px solid rgb(185, 183, 183);
box-shadow: 2px 10px 30px 15px rgb(227, 225, 225);
border-radius: 10px;
padding:2px
}
.screen{
display:grid;
grid-column: 1/5;
border-radius: 10px 10px 0 0;
grid-template-rows: 1fr 2fr;
margin:1px;
border: 1.5px lightgray solid;
/* <inset?> x y blur spread */
box-shadow: inset 2px 2px 0px 0px rgb(227, 225, 225);
background-color: rgba(255, 255, 255, 0.863);
}
.screen-row{
background-color: transparent;
}
#upper-row{
border-radius: 10px 10px 0 0;
border:none;
width: 100%;
/* height: 50px; */
font-size: 20px;
text-align: right;
/* border: 3px solid black; */
/* border-radius: 10px 10px 0 0; */
padding-top: 8px;
padding-right: 10px;
font-family: 'DIGITAL-7', sans-serif;
}
#lower-row{
/* border-radius: 10px 10px 0 0; */
border:none;
width: 100%;
/* height: 70px; */
font-size: 2.5em;
text-align: right;
padding-right: 10px;
font-family: 'DIGITAL-7', sans-serif;
}
.btn{
background-color: rgba(255, 255, 255, 0.86);
margin: 3px;
font-size: 1.6em;
font-weight: bold;
box-shadow: 2px 2px 0 0px lightgray;
border-radius: 5px;
border:none;
cursor: pointer;
}
.btn:hover{
background-color: rgb(243, 243, 243);
}
.btn:active{
background-color: rgb(199, 199, 199);
box-shadow: 2px 2px 0 0px rgb(105, 105, 105);
}
</style>
</head>
<body>
<div class="calculator">
<div class="screen">
<input type="text" disabled class='screen-row' name="" id="upper-row">
<input type="text" disabled class='screen-row' name="" id="lower-row">
</div>
<button class="btn num5"><i class="fa-solid fa-delete-left"></i></button>
<button class="btn num6">CE</button>
<button class="btn num8">C</button>
<button class="btn num7">÷</button>
<button class="btn num1">1</button>
<button class="btn num2">2</button>
<button class="btn num3">3</button>
<button class="btn divide">x</button>
<button class="btn num4">4</button>
<button class="btn num5">5</button>
<button class="btn num6">6</button>
<button class="btn num8">-</button>
<button class="btn num7">7</button>
<button class="btn num8">8</button>
<button class="btn num9">9</button>
<button class="btn minus">+</button>
<button class="btn clear">%</button>
<button class="btn num0">0</button>
<button class="btn plus">.</button>
<button class="btn plus">=</button>
</div>
<script>
class Animal{
static count = 0;
constructor(name,species){
this.name = name;
this.species = species;
Animal.count++; //coiunt += 1, count = count +
}
speak(){
console.log(`My name is ${this.name} and I am a ${this.species}`);
}
static getCount(){
return Animal.count;
}
}
let cat = new Animal('Tom','Cat');
let dog = new Animal('Spike','Dog');
class List{
// constructor(){
// this.list = [];
// }
// addToList(value){
// this.list.push(value);
// }
// removeFromList(){
// this.list.pop();
// }
// clearList(){
// this.list = [];
// }
// getList(){
// return this.list;
// }
}
console.log("hj");
let buttons = document.querySelectorAll('.btn');
buttons.forEach((btn)=>{
btn.addEventListener('click',()=>{
let upperRow = document.getElementById('upper-row');
let lowerRow = document.getElementById('lower-row');
let value = btn.textContent;
if(value === 'C'){
upperRow.value = '';
lowerRow.value = '';
}else if(value === 'CE'){
lowerRow.value = '';
}else if(value === 'x'){
lowerRow.value += '*'; // lowerRow.value = lowerRow.value + '*'
}else if(value === '='){
upperRow.value = lowerRow.value;
let finalString = lowerRow.value.replace('÷','/');
lowerRow.value = eval(finalString);
}else if(value === '÷'){
lowerRow.value += '÷'
}else if(!value){
lowerRow.value = lowerRow.value.slice(0,-1);
}else{
lowerRow.value += value;
}
});
});
</script>
</body>
</html>