-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
110 lines (97 loc) · 4.07 KB
/
index.html
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Calculator</title>
<meta name="description" content="MR.js example">
<script src="https://cdn.jsdelivr.net/gh/volumetrics-io/mrjs@latest/dist/build.js"></script>
<style>
* {
padding: 0;
margin: 0;
border: 0;
}
mr-app * {
display: none;
}
</style>
</head>
<body>
<mr-app camera="camera: orthographic">
<mr-surface>
<mr-container>
<mr-column>
<mr-row padding="0.01">
<mr-panel padding="0.01"><mr-texteditor id="result" color="lightgrey" text-style="size: 0.03; vertical: center"></mr-text></mr-panel>
</mr-row>
<mr-row padding="0.01">
<mr-panel value="7" padding="0.01"><mr-text color="lightgrey" text-style="size: 0.03; vertical: center">7</mr-text></mr-panel>
<mr-panel value="8" padding="0.01"><mr-text color="lightgrey" text-style="size: 0.03; vertical: center">8</mr-text></mr-panel>
<mr-panel value="9" padding="0.01"><mr-text color="lightgrey" text-style="size: 0.03; vertical: center">9</mr-text></mr-panel>
<mr-panel value="*" padding="0.01"><mr-text color="lightgrey" text-style="size: 0.03; vertical: center">×</mr-text></mr-panel>
</mr-row>
<mr-row padding="0.01">
<mr-panel value="4" padding="0.01"><mr-text color="lightgrey" text-style="size: 0.03; vertical: center">4</mr-text></mr-panel>
<mr-panel value="5" padding="0.01"><mr-text color="lightgrey" text-style="size: 0.03; vertical: center">5</mr-text></mr-panel>
<mr-panel value="6" padding="0.01"><mr-text color="lightgrey" text-style="size: 0.03; vertical: center">6</mr-text></mr-panel>
<mr-panel value="-" padding="0.01"><mr-text color="lightgrey" text-style="size: 0.03; vertical: center">-</mr-text></mr-panel>
</mr-row>
<mr-row padding="0.01">
<mr-panel value="1" padding="0.01"><mr-text color="lightgrey" text-style="size: 0.03; vertical: center">1</mr-text></mr-panel>
<mr-panel value="2" padding="0.01"><mr-text color="lightgrey" text-style="size: 0.03; vertical: center">2</mr-text></mr-panel>
<mr-panel value="3" padding="0.01"><mr-text color="lightgrey" text-style="size: 0.03; vertical: center">3</mr-text></mr-panel>
<mr-panel value="+" padding="0.01"><mr-text color="lightgrey" text-style="size: 0.03; vertical: center">+</mr-text></mr-panel>
</mr-row>
<mr-row padding="0.01">
<mr-panel value="0" padding="0.01"><mr-text color="lightgrey" text-style="size: 0.03; vertical: center">0</mr-text></mr-panel>
<mr-panel value="." padding="0.01"><mr-text color="lightgrey" text-style="size: 0.03; vertical: center">.</mr-text></mr-panel>
<mr-panel value="C" padding="0.01"><mr-text color="lightgrey" text-style="size: 0.03; vertical: center">C</mr-text></mr-panel>
<mr-panel value="=" padding="0.01"><mr-text color="lightgrey" text-style="size: 0.03; vertical: center">=</mr-text></mr-panel>
</mr-row>
</mr-column>
</mr-container>
</mr-surface>
</mr-app>
</body>
<script>
const insert = (value) => {
// console.log(number);
let result = document.querySelector("#result");
switch (value) {
case '=':
result.innerText = eval(result.innerText);
break;
case 'C':
result.innerText = '';
break;
default:
result.innerText += value;
break;
}
}
let panels = document.querySelectorAll('mr-panel')
for (const panel of panels) {
panel.addEventListener('click', (event) => {
insert(event.target.value);
});
panel.onMouseDown = (event) => {
panel.color = "red";
}
panel.onMouseUp = (event) => {
panel.color = "blue";
}
panel.onHover = (event) => {
switch (event.type) {
case 'hover-start':
panel.color = "yellow";
break;
case 'hover-end':
panel.color = "lightgrey";
break;
default:
break;
}
}
}
</script>
</html>