-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
61 lines (56 loc) · 1.5 KB
/
script.js
File metadata and controls
61 lines (56 loc) · 1.5 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
let txt = document.getElementById('txt')
let txt2 = document.getElementById('txt2')
var element = document.body;
let numbers = txt.value;
let savenum = '';
let loadnum = false
let mode = localStorage.getItem("mode");
let mobilemode = (typeof window.orientation !== "undefined")
|| (navigator.userAgent.indexOf('IEMobile') !== -1
);
function numberup() {
numbers = eval(txt.value) }
function savenumb() {
if (loadnum == false) {
savenum = numbers
loadnum = true
}else if(loadnum == true) {
txt.value = txt.value + savenum
}
}
function darkmode() {
element.style = 'color: white; background-color: black;'
txt.style = 'color: white; background-color: black;'
txt2.style = 'color: white; background-color: black;'
localStorage.setItem("mode", "dark");
}
function lightmode() {
element.style = 'color: black; background-color: white;'
txt.style = 'color: black; background-color: white;'
txt2.style = 'color: black; background-color: white;'
localStorage.setItem("mode", "");
}
if (mode == "dark") {
darkmode()
}
function removech() {
if (txt.value.charAt(txt.value.length - 1) == ' ') {
txt.value = txt.value.substr(0, txt.value.length - 2)
}
else {
txt.value = txt.value.substr(0, txt.value.length - 1)
}
}
if(mobilemode == false){
txt.readOnly = false
txt.addEventListener("keydown", (e) => {
if(e.key ==="Enter"){
numberup()
txt2.value = txt.value + ' =';
txt.value = numbers; loadnum = false
}
if(isFinite(e.key)){
numberup()
}
})
}