-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdisplays.js
58 lines (49 loc) · 1.25 KB
/
displays.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
class CalcDisplay {
P1
P2
PH
DIV
constructor(gap) {
this.P1 = document.createElement('p')
this.P2 = document.createElement('p')
this.P1.style.marginBottom = '0px'
this.P2.style.marginTop = '0px'
if (gap == null) {
gap = '8px'
}
this.BuildDiv(gap)
}
BuildDiv(gap) {
this.DIV = document.createElement('div')
this.DIV.style.display = 'flex'
this.DIV.style.flexDirection = 'column'
this.DIV.style.gap = gap
this.DIV.append(this.P1, this.P2)
}
Get() {
return this.DIV
}
Rub(){
let ac_val = this.P1.innerHTML
this.P1.innerHTML = ac_val.substring(0, ac_val.length - 1 )
this.SetP2()
if(this.P1.innerHTML == ''){
this.P2.innerHTML = ''
}
}
Set(newval) {
this.P1.innerHTML = this.P1.innerHTML + String(newval)
this.SetP2()
}
SetP2() {
let val
try {
val = eval(this.P1.innerHTML)
}catch(error){
console.log(error)
}
if (typeof val != 'undefined') {
this.P2.innerHTML = val
}
}
}