-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.JS
147 lines (139 loc) · 3.33 KB
/
app.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
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
function btnclick(_this, num){
_this.className = "btn-custom"
var res = document.getElementById("calc");
res.value += num;
}
function btnafterclick(_this){
_this.className = "afterclick"
}
function getResult(_this, val){
_this.className = "btn-custom"
var res = document.getElementById("calc");
res.value = eval(res.value)
if(val == "%"){
getResult(_this)
}
else if(val=="sin"){
Math.sin(res.value)
}
else if(val=="cos"){
Math.cos(res.value)
}
else if(val=="tan"){
Math.tan(res.value)
}
else if(val=="ln"){
Math.log(res.value)
}
else if(val=="√"){
Math.sqrt(res.value)
}
else if(val=="^"){
Math.exp(res.value)
}
else if(val == "x2"){
eval(res.value*res.value)
}
}
function clearValue(_this){
var res = document.getElementById("calc");
res.value = "";
_this.className = "btn-custom"
}
function del(_this) {
_this.className = "btn-custom"
var res = document.getElementById("calc");
res.value = res.value.slice(0,-1)
}
function lightTheme(class1, class2, color){
var btn = document.getElementsByTagName("button")
var body=document.getElementById("mainbody")
var watch = document.getElementById("stpwtch")
var calc = document.getElementById("main")
watch.className += class2
body.className += class1
calc.className += class2
for(var i =0; i<btn.length; i++){
btn[i].style.borderColor= color
}
}
function scientific(_this,val){
_this.className = "btn-custom"
var res = document.getElementById("calc");
if(val=="π"){
res.value = Math.PI }
else if(val == "%"){
getResult(_this)
}
else if(val=="sin"){
res.value = Math.sin(res.value)
}
else if(val=="cos"){
res.value = Math.cos(res.value)
}
else if(val=="tan"){
res.value = Math.tan(res.value)
}
else if(val=="ln"){
res.value = Math.log(res.value)
}
else if(val=="√"){
res.value = Math.sqrt(res.value)
}
else if(val=="!"){
}
else if(val == "x2"){
res.value = eval(res.value*res.value)
}
else if(val == "e"){
res.value = Math.exp(res.value)
}
}
function factorial(_this){
var i
_this.className = "btn-custom"
var res = document.getElementById("calc");
v = res.value
console.log(res.value)
for(i=(v-1); i>=1; i--){
v=v*i
}
res.value= v
}
var mh = document.getElementById("min")
var sh = document.getElementById("sec")
var msh = document.getElementById("msec")
var count = 0
var pause = document.getElementById('pause')
var interval
var strt = document.getElementById("start")
function timer(){
pause.className += "innitial"
msh.innerHTML++
if(msh.innerHTML == 100){
sh.innerHTML++
msh.innerHTML = 0
}
else if(sh.innerHTML == 60){
mh.innerHTML++
sh.innerHTML = 0
}
}
function start(){
interval = setInterval(timer,10)
}
function stop(){
clearInterval(interval)
var pause = document.getElementById('pause')
pause.value = "resume"
if(pause.value == "resume"){
pause.onclick = function() {start()}
}
}
function reset(){
mh.innerHTML = 0
sh.innerHTML = 0
msh.innerHTML = 0
stop()
strt.disabled = false
}