-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
139 lines (135 loc) · 7.17 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
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
<!DOCTYPE html>
<html lang="pt_BR">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="style.css" />
</head>
<body class="no-margin is-border-box-sized is-flex is-fullscreen is-vcentered hidden-overflow">
<canvas id="canvas" width="500" height="500"></canvas>
<div class="is-flex is-bottom-middle-positioned is-vcentered is-spaced-1 is-padded-one-half is-layer-1">
<div class="is-bordered bg-white bg-gray-hover is-pointer-cursor-hover is-rounded-5 is-shadowed is-flex is-vcentered is-size-squared-3" data-popup="popup-protons">
<p class="no-margin"><span id="total-protons">0</span> p<sup>+</sup></p>
</div>
<div id="popup-protons" class="is-bottom-padded-one-half">
<div class="bg-white is-bordered is-shadowed is-rounded-one-half">
<div class="is-flex is-vcentered is-size-squared-2 bg-gray-hover is-pointer-cursor-hover is-rounded-one-half-top" id="proton-add">+</div>
<div class="is-flex is-vcentered is-size-squared-2 bg-gray-hover is-pointer-cursor-hover is-rounded-one-half-bottom" id="proton-remove">-</div>
</div>
</div>
<div class="is-bordered bg-white bg-gray-hover is-pointer-cursor-hover is-rounded-5 is-shadowed is-flex is-vcentered is-size-squared-3" data-popup="popup-neutrons">
<p class="no-margin"><span id="total-neutrons">0</span> n</p>
</div>
<div id="popup-neutrons" class="is-bottom-padded-one-half">
<div class="bg-white is-bordered is-shadowed is-rounded-one-half">
<div class="is-flex is-vcentered is-size-squared-2 bg-gray-hover is-pointer-cursor-hover is-rounded-one-half-top" id="neutron-add">+</div>
<div class="is-flex is-vcentered is-size-squared-2 bg-gray-hover is-pointer-cursor-hover is-rounded-one-half-bottom" id="neutron-remove">-</div>
</div>
</div>
<div class="is-bordered bg-white bg-gray-hover is-pointer-cursor-hover is-rounded-5 is-shadowed is-flex is-vcentered is-size-squared-3" data-popup="popup-eletrons">
<p class="no-margin"><span id="total-eletrons">0</span> e<sup>-</sup></p>
</div>
<div id="popup-eletrons" class="is-bottom-padded-one-half">
<div class="bg-white is-bordered is-flex is-shadowed is-rounded-one-half">
<div class="is-flex is-flex-column">
<div class="is-flex is-vcentered is-size-squared-2">K</div>
<div class="is-flex is-vcentered is-size-squared-2 bg-gray-hover is-pointer-cursor-hover" id="nivel-k-add">+</div>
<div class="is-flex is-vcentered is-size-squared-2" id="nivel-k-total">99</div>
<div class="is-flex is-vcentered is-size-squared-2 bg-gray-hover is-pointer-cursor-hover is-rounded-one-half-left-bottom" id="nivel-k-remove">-</div>
</div>
<div class="is-flex is-flex-column">
<div class="is-flex is-vcentered is-size-squared-2">L</div>
<div class="is-flex is-vcentered is-size-squared-2 bg-gray-hover is-pointer-cursor-hover" id="nivel-l-add">+</div>
<div class="is-flex is-vcentered is-size-squared-2" id="nivel-l-total">99</div>
<div class="is-flex is-vcentered is-size-squared-2 bg-gray-hover is-pointer-cursor-hover" id="nivel-l-remove">-</div>
</div>
<div class="is-flex is-flex-column">
<div class="is-flex is-vcentered is-size-squared-2">M</div>
<div class="is-flex is-vcentered is-size-squared-2 bg-gray-hover is-pointer-cursor-hover" id="nivel-m-add">+</div>
<div class="is-flex is-vcentered is-size-squared-2" id="nivel-m-total">99</div>
<div class="is-flex is-vcentered is-size-squared-2 bg-gray-hover is-pointer-cursor-hover" id="nivel-m-remove">-</div>
</div>
<div class="is-flex is-flex-column">
<div class="is-flex is-vcentered is-size-squared-2">N</div>
<div class="is-flex is-vcentered is-size-squared-2 bg-gray-hover is-pointer-cursor-hover" id="nivel-n-add">+</div>
<div class="is-flex is-vcentered is-size-squared-2" id="nivel-n-total">99</div>
<div class="is-flex is-vcentered is-size-squared-2 bg-gray-hover is-pointer-cursor-hover" id="nivel-n-remove">-</div>
</div>
<div class="is-flex is-flex-column">
<div class="is-flex is-vcentered is-size-squared-2">O</div>
<div class="is-flex is-vcentered is-size-squared-2 bg-gray-hover is-pointer-cursor-hover" id="nivel-o-add">+</div>
<div class="is-flex is-vcentered is-size-squared-2" id="nivel-o-total">99</div>
<div class="is-flex is-vcentered is-size-squared-2 bg-gray-hover is-pointer-cursor-hover" id="nivel-o-remove">-</div>
</div>
<div class="is-flex is-flex-column">
<div class="is-flex is-vcentered is-size-squared-2">P</div>
<div class="is-flex is-vcentered is-size-squared-2 bg-gray-hover is-pointer-cursor-hover" id="nivel-p-add">+</div>
<div class="is-flex is-vcentered is-size-squared-2" id="nivel-p-total">99</div>
<div class="is-flex is-vcentered is-size-squared-2 bg-gray-hover is-pointer-cursor-hover" id="nivel-p-remove">-</div>
</div>
<div class="is-flex is-flex-column">
<div class="is-flex is-vcentered is-size-squared-2">Q</div>
<div class="is-flex is-vcentered is-size-squared-2 bg-gray-hover is-pointer-cursor-hover" id="nivel-q-add">+</div>
<div class="is-flex is-vcentered is-size-squared-2" id="nivel-q-total">99</div>
<div class="is-flex is-vcentered is-size-squared-2 bg-gray-hover is-pointer-cursor-hover is-rounded-one-half-right-bottom" id="nivel-q-remove">-</div>
</div>
</div>
</div>
</div>
</body>
<script src="spring.js"></script>
<script src="script.js"></script>
<script src="popup.js"></script>
<script>
function updateUI() {
document.getElementById('total-protons').innerHTML = simulacao.getTotalProtons();
document.getElementById('total-neutrons').innerHTML = simulacao.getTotalNeutrons();
document.getElementById('total-eletrons').innerHTML = simulacao.getTotalEletrons();
simulacao.niveis.forEach(nivel => {
document.getElementById("nivel-" + nivel + "-total").innerHTML = simulacao.getTotalEletrons(nivel);
});
}
function registerUIEvents() {
document.getElementById("proton-add").addEventListener("click", e => {
simulacao.addProton();
updateUI();
});
document.getElementById("proton-remove").addEventListener("click", e => {
simulacao.removeProton();
updateUI();
});
document.getElementById("neutron-add").addEventListener("click", e => {
simulacao.addNeutron();
updateUI();
});
document.getElementById("neutron-remove").addEventListener("click", e => {
simulacao.removeNeutron();
updateUI();
});
simulacao.niveis.forEach(nivel => {
let id = "nivel-" + nivel;
document.getElementById(id + "-add").addEventListener("click", e => {
simulacao.addEletron(nivel);
updateUI();
});
document.getElementById(id + "-remove").addEventListener("click", e => {
simulacao.removeEletron(nivel);
updateUI();
});
});
}
let simulacao = new Simulacao();
document.addEventListener("DOMContentLoaded", () => {
simulacao.addProton();
simulacao.addProton();
simulacao.addNeutron();
simulacao.addNeutron();
simulacao.addEletron('k');
simulacao.addEletron('k');
initPopups();
registerUIEvents();
updateUI();
simulacao.start();
});
</script>
</html>