Repository navigation
Expand file tree
/
Copy pathelectron-config.html
More file actions
277 lines (252 loc) · 15.8 KB
/
Copy pathelectron-config.html
File metadata and controls
277 lines (252 loc) · 15.8 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
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Electron Configuration</title>
<script src="https://cdn.tailwindcss.com"></script>
<link rel="stylesheet" href="style.css">
</head>
<body class="bg-gray-800 text-gray-300 font-sans">
<div class="container mx-auto p-4">
<div class="text-center mb-4">
<a href="index.html" class="text-blue-400 hover:text-blue-300">← Back to home</a>
</div>
<h1 class="text-3xl font-bold text-center mb-6 text-white">Electron Configuration of Atoms</h1>
<!-- Search Bar -->
<div class="max-w-xl mx-auto mb-8">
<div class="flex">
<input type="text" id="element-input" placeholder="Enter a name, symbol, or atomic number (e.g., Sodium, Na, 11)..." class="w-full p-3 rounded-l-lg bg-gray-700 text-white border border-gray-600 focus:outline-none focus:border-blue-400">
<button id="find-button" class="px-6 py-3 bg-blue-600 text-white rounded-r-lg hover:bg-blue-700">Find</button>
</div>
</div>
<!-- Result Area -->
<div id="result-area" class="hidden max-w-xl mx-auto bg-gray-700 rounded-lg p-6">
<div id="error-message" class="hidden text-center text-red-400 p-4"></div>
<div id="success-content">
<div class="flex justify-between items-center mb-4">
<h2 class="text-3xl font-bold text-white" id="element-name"></h2>
<div class="text-right">
<div id="element-symbol" class="text-4xl font-mono text-blue-300"></div>
<div id="atomic-number" class="text-sm"></div>
</div>
</div>
<div class="bg-gray-800 rounded p-4 mb-4">
<h3 class="text-lg font-semibold mb-2">Electron Configuration:</h3>
<p id="electron-config" class="text-xl font-mono"></p>
</div>
<div class="bg-gray-800 rounded p-4">
<h3 class="text-lg font-semibold mb-2">Demonstration (Aufbau Principle):</h3>
<div id="aufbau-principle" class="font-mono text-sm space-y-1"></div>
</div>
<div class="bg-gray-800 rounded p-4 mt-4">
<h3 class="text-lg font-semibold mb-2">Orbital Diagram (Quantum Boxes):</h3>
<div id="orbital-diagram" class="font-mono text-lg space-y-2"></div>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
const elementsData = {
1: { name: 'Hydrogen', symbol: 'H', config: '1s1' },
2: { name: 'Helium', symbol: 'He', config: '1s2' },
3: { name: 'Lithium', symbol: 'Li', config: '[He] 2s1' },
4: { name: 'Beryllium', symbol: 'Be', config: '[He] 2s2' },
5: { name: 'Boron', symbol: 'B', config: '[He] 2s2 2p1' },
6: { name: 'Carbon', symbol: 'C', config: '[He] 2s2 2p2' },
7: { name: 'Nitrogen', symbol: 'N', config: '[He] 2s2 2p3' },
8: { name: 'Oxygen', symbol: 'O', config: '[He] 2s2 2p4' },
9: { name: 'Fluorine', symbol: 'F', config: '[He] 2s2 2p5' },
10: { name: 'Neon', symbol: 'Ne', config: '[He] 2s2 2p6' },
11: { name: 'Sodium', symbol: 'Na', config: '[Ne] 3s1' },
12: { name: 'Magnesium', symbol: 'Mg', config: '[Ne] 3s2' },
13: { name: 'Aluminum', symbol: 'Al', config: '[Ne] 3s2 3p1' },
14: { name: 'Silicon', symbol: 'Si', config: '[Ne] 3s2 3p2' },
15: { name: 'Phosphorus', symbol: 'P', config: '[Ne] 3s2 3p3' },
16: { name: 'Sulfur', symbol: 'S', config: '[Ne] 3s2 3p4' },
17: { name: 'Chlorine', symbol: 'Cl', config: '[Ne] 3s2 3p5' },
18: { name: 'Argon', symbol: 'Ar', config: '[Ne] 3s2 3p6' },
19: { name: 'Potassium', symbol: 'K', config: '[Ar] 4s1' },
20: { name: 'Calcium', symbol: 'Ca', config: '[Ar] 4s2' },
21: { name: 'Scandium', symbol: 'Sc', config: '[Ar] 3d1 4s2' },
22: { name: 'Titanium', symbol: 'Ti', config: '[Ar] 3d2 4s2' },
23: { name: 'Vanadium', symbol: 'V', config: '[Ar] 3d3 4s2' },
24: { name: 'Chromium', symbol: 'Cr', config: '[Ar] 3d5 4s1' },
25: { name: 'Manganese', symbol: 'Mn', config: '[Ar] 3d5 4s2' },
26: { name: 'Iron', symbol: 'Fe', config: '[Ar] 3d6 4s2' },
27: { name: 'Cobalt', symbol: 'Co', config: '[Ar] 3d7 4s2' },
28: { name: 'Nickel', symbol: 'Ni', config: '[Ar] 3d8 4s2' },
29: { name: 'Copper', symbol: 'Cu', config: '[Ar] 3d10 4s1' },
30: { name: 'Zinc', symbol: 'Zn', config: '[Ar] 3d10 4s2' },
31: { name: 'Gallium', symbol: 'Ga', config: '[Ar] 3d10 4s2 4p1' },
32: { name: 'Germanium', symbol: 'Ge', config: '[Ar] 3d10 4s2 4p2' },
33: { name: 'Arsenic', symbol: 'As', config: '[Ar] 3d10 4s2 4p3' },
34: { name: 'Selenium', symbol: 'Se', config: '[Ar] 3d10 4s2 4p4' },
35: { name: 'Bromine', symbol: 'Br', config: '[Ar] 3d10 4s2 4p5' },
36: { name: 'Krypton', symbol: 'Kr', config: '[Ar] 3d10 4s2 4p6' },
37: { name: 'Rubidium', symbol: 'Rb', config: '[Kr] 5s1' },
38: { name: 'Strontium', symbol: 'Sr', config: '[Kr] 5s2' },
39: { name: 'Yttrium', symbol: 'Y', config: '[Kr] 4d1 5s2' },
40: { name: 'Zirconium', symbol: 'Zr', config: '[Kr] 4d2 5s2' },
41: { name: 'Niobium', symbol: 'Nb', config: '[Kr] 4d4 5s1' },
42: { name: 'Molybdenum', symbol: 'Mo', config: '[Kr] 4d5 5s1' },
43: { name: 'Technetium', symbol: 'Tc', config: '[Kr] 4d5 5s2' },
44: { name: 'Ruthenium', symbol: 'Ru', config: '[Kr] 4d7 5s1' },
45: { name: 'Rhodium', symbol: 'Rh', config: '[Kr] 4d8 5s1' },
46: { name: 'Palladium', symbol: 'Pd', config: '[Kr] 4d10' },
47: { name: 'Silver', symbol: 'Ag', config: '[Kr] 4d10 5s1' },
48: { name: 'Cadmium', symbol: 'Cd', config: '[Kr] 4d10 5s2' },
49: { name: 'Indium', symbol: 'In', config: '[Kr] 4d10 5s2 5p1' },
50: { name: 'Tin', symbol: 'Sn', config: '[Kr] 4d10 5s2 5p2' },
51: { name: 'Antimony', symbol: 'Sb', config: '[Kr] 4d10 5s2 5p3' },
52: { name: 'Tellurium', symbol: 'Te', config: '[Kr] 4d10 5s2 5p4' },
53: { name: 'Iodine', symbol: 'I', config: '[Kr] 4d10 5s2 5p5' },
54: { name: 'Xenon', symbol: 'Xe', config: '[Kr] 4d10 5s2 5p6' },
55: { name: 'Caesium', symbol: 'Cs', config: '[Xe] 6s1' },
56: { name: 'Barium', symbol: 'Ba', config: '[Xe] 6s2' },
57: { name: 'Lanthanum', symbol: 'La', config: '[Xe] 5d1 6s2' },
58: { name: 'Cerium', symbol: 'Ce', config: '[Xe] 4f1 5d1 6s2' },
59: { name: 'Praseodymium', symbol: 'Pr', config: '[Xe] 4f3 6s2' },
60: { name: 'Neodymium', symbol: 'Nd', config: '[Xe] 4f4 6s2' },
61: { name: 'Promethium', symbol: 'Pm', config: '[Xe] 4f5 6s2' },
62: { name: 'Samarium', symbol: 'Sm', config: '[Xe] 4f6 6s2' },
63: { name: 'Europium', symbol: 'Eu', config: '[Xe] 4f7 6s2' },
64: { name: 'Gadolinium', symbol: 'Gd', config: '[Xe] 4f7 5d1 6s2' },
65: { name: 'Terbium', symbol: 'Tb', config: '[Xe] 4f9 6s2' },
66: { name: 'Dysprosium', symbol: 'Dy', config: '[Xe] 4f10 6s2' },
67: { name: 'Holmium', symbol: 'Ho', config: '[Xe] 4f11 6s2' },
68: { name: 'Erbium', symbol: 'Er', config: '[Xe] 4f12 6s2' },
69: { name: 'Thulium', symbol: 'Tm', config: '[Xe] 4f13 6s2' },
70: { name: 'Ytterbium', symbol: 'Yb', config: '[Xe] 4f14 6s2' },
71: { name: 'Lutetium', symbol: 'Lu', config: '[Xe] 4f14 5d1 6s2' },
72: { name: 'Hafnium', symbol: 'Hf', config: '[Xe] 4f14 5d2 6s2' },
73: { name: 'Tantalum', symbol: 'Ta', config: '[Xe] 4f14 5d3 6s2' },
74: { name: 'Tungsten', symbol: 'W', config: '[Xe] 4f14 5d4 6s2' },
75: { name: 'Rhenium', symbol: 'Re', config: '[Xe] 4f14 5d5 6s2' },
76: { name: 'Osmium', symbol: 'Os', config: '[Xe] 4f14 5d6 6s2' },
77: { name: 'Iridium', symbol: 'Ir', config: '[Xe] 4f14 5d7 6s2' },
78: { name: 'Platinum', symbol: 'Pt', config: '[Xe] 4f14 5d9 6s1' },
79: { name: 'Gold', symbol: 'Au', config: '[Xe] 4f14 5d10 6s1' },
80: { name: 'Mercury', symbol: 'Hg', config: '[Xe] 4f14 5d10 6s2' },
81: { name: 'Thallium', symbol: 'Tl', config: '[Xe] 4f14 5d10 6s2 6p1' },
82: { name: 'Lead', symbol: 'Pb', config: '[Xe] 4f14 5d10 6s2 6p2' },
83: { name: 'Bismuth', symbol: 'Bi', config: '[Xe] 4f14 5d10 6s2 6p3' },
84: { name: 'Polonium', symbol: 'Po', config: '[Xe] 4f14 5d10 6s2 6p4' },
85: { name: 'Astatine', symbol: 'At', config: '[Xe] 4f14 5d10 6s2 6p5' },
86: { name: 'Radon', symbol: 'Rn', config: '[Xe] 4f14 5d10 6s2 6p6' },
87: { name: 'Francium', symbol: 'Fr', config: '[Rn] 7s1' },
88: { name: 'Radium', symbol: 'Ra', config: '[Rn] 7s2' },
89: { name: 'Actinium', symbol: 'Ac', config: '[Rn] 6d1 7s2' },
90: { name: 'Thorium', symbol: 'Th', config: '[Rn] 6d2 7s2' },
91: { name: 'Protactinium', symbol: 'Pa', config: '[Rn] 5f2 6d1 7s2' },
92: { name: 'Uranium', symbol: 'U', config: '[Rn] 5f3 6d1 7s2' },
93: { name: 'Neptunium', symbol: 'Np', config: '[Rn] 5f4 6d1 7s2' },
94: { name: 'Plutonium', symbol: 'Pu', config: '[Rn] 5f6 7s2' },
95: { name: 'Americium', symbol: 'Am', config: '[Rn] 5f7 7s2' },
96: { name: 'Curium', symbol: 'Cm', config: '[Rn] 5f7 6d1 7s2' },
97: { name: 'Berkelium', symbol: 'Bk', config: '[Rn] 5f9 7s2' },
98: { name: 'Californium', symbol: 'Cf', config: '[Rn] 5f10 7s2' },
99: { name: 'Einsteinium', symbol: 'Es', config: '[Rn] 5f11 7s2' },
100: { name: 'Fermium', symbol: 'Fm', config: '[Rn] 5f12 7s2' },
101: { name: 'Mendelevium', symbol: 'Md', config: '[Rn] 5f13 7s2' },
102: { name: 'Nobelium', symbol: 'No', config: '[Rn] 5f14 7s2' },
103: { name.
..
..
..
const findButton = document.getElementById('find-button');
const elementInput = document.getElementById('element-input');
const resultArea = document.getElementById('result-area');
const errorMessage = document.getElementById('error-message');
const successContent = document.getElementById('success-content');
const elementNameEl = document.getElementById('element-name');
const elementSymbolEl = document.getElementById('element-symbol');
const atomicNumberEl = document.getElementById('atomic-number');
const electronConfigEl = document.getElementById('electron-config');
const aufbauPrincipleEl = document.getElementById('aufbau-principle');
const orbitalDiagramEl = document.getElementById('orbital-diagram');
function formatConfig(config) {
return config.replace(/([spdf])(\d+)/g, "$1<sup>$2</sup>");
}
function findElement(query) {
const lowerCaseQuery = query.toLowerCase().trim();
if (elementsData[lowerCaseQuery]) {
return { ...elementsData[lowerCaseQuery], z: lowerCaseQuery };
}
for (const z in elementsData) {
const element = elementsData[z];
if (element.symbol.toLowerCase() === lowerCaseQuery || element.name.toLowerCase() === lowerCaseQuery) {
return { ...element, z: z };
}
}
return null;
}
function showAufbauDemonstration(configStr) {
let aufbauHTML = '';
const orbitals = configStr.replace(/\[.*?\]\s*/, '').split(' ');
orbitals.forEach(orbital => {
const parts = orbital.match(/(\d+[spdf])(\d+)/);
if (parts && parts.length === 3) {
const level = parts[1];
const electrons = parts[2];
aufbauHTML += `<div><span class="text-blue-300">${level}</span>: ${formatConfig(electrons)} electrons</div>`;
}
});
return aufbauHTML;
}
function drawOrbitalDiagrams(configStr) {
const orbitalBoxCount = { s: 1, p: 3, d: 5, f: 7 };
const upArrow = '↑';
const downArrow = '↓';
let diagramHTML = '';
const orbitals = configStr.replace(/\[.*?\]\s*/, '').split(' ');
orbitals.forEach(orbital => {
const parts = orbital.match(/(\d+)([spdf])(\d+)/);
if (!parts) return;
const levelAndType = parts[1];
const type = parts[2];
const electrons = parseInt(parts[3], 10);
const boxCount = orbitalBoxCount[type];
let boxes = Array(boxCount).fill('');
// Hund's rule: fill with up arrows first
for (let i = 0; i < electrons; i++) {
boxes[i % boxCount] += (i < boxCount) ? upArrow : downArrow;
}
diagramHTML += `<div class="flex items-center space-x-2">`;
diagramHTML += `<div class="w-8 text-right text-blue-300">${levelAndType}</div>`;
boxes.forEach(boxContent => {
diagramHTML += `<div class="orbital-box">${boxContent}</div>`;
});
diagramHTML += `</div>`;
});
return diagramHTML;
}
function displayElement(query) {
const element = findElement(query);
resultArea.classList.remove('hidden');
if (!element) {
successContent.style.display = 'none';
errorMessage.textContent = 'Element not found.';
errorMessage.classList.remove('hidden');
return;
}
successContent.style.display = 'block';
errorMessage.classList.add('hidden');
elementNameEl.textContent = element.name;
elementSymbolEl.textContent = element.symbol;
atomicNumberEl.textContent = `Z = ${element.z}`;
electronConfigEl.innerHTML = formatConfig(element.config);
aufbauPrincipleEl.innerHTML = showAufbauDemonstration(element.config);
orbitalDiagramEl.innerHTML = drawOrbitalDiagrams(element.config);
}
findButton.addEventListener('click', () => displayElement(elementInput.value));
elementInput.addEventListener('keyup', (event) => {
if (event.key === 'Enter') {
displayElement(elementInput.value);
}
});
});
</script>
</body>
</html>