forked from iris-web-lab/calc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
45 lines (39 loc) · 1.13 KB
/
script.js
File metadata and controls
45 lines (39 loc) · 1.13 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
navigator.serviceWorker && navigator.serviceWorker.register('./sw.js').then(function (registration) {
console.log('Excellent, registered with scope: ', registration.scope);
});
let display = document.getElementById("display");
Window.onload = function size() {
window.resizeTo(700, window.screen.availHeight / 2);
}
function appendDisplay(char) {
if (display.textContent === "0") {
display.textContent = char;
} else {
if (char == "Del") {
display.textContent = display.textContent.slice(0, -1);
} else {
display.textContent += char;
}
}
}
/* Window.onload = function service() {
if ("serviceWorker" in navigator) {
window.addEventListener("load", function () {
navigator.serviceWorker
.register("/sw.js")
.then(res => console.log("service worker registered"))
.catch(err => console.log("service worker not registered", err))
})
}
} */
function clearDisplay() {
display.textContent = "0";
}
function evaluateDisplay() {
try {
let result = eval(display.textContent);
display.textContent = result;
} catch (error) {
display.textContent = "Error";
}
}