-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
44 lines (39 loc) · 1.32 KB
/
script.js
File metadata and controls
44 lines (39 loc) · 1.32 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
document.addEventListener('DOMContentLoaded', () => {
fetch('data.json')
.then(response => response.json())
.then(data => populateCPUSelect(data.CPUs));
});
function populateCPUSelect(cpus) {
const cpuSelect = document.getElementById('cpu-select');
cpus.forEach(cpu => {
const option = document.createElement('option');
option.value = cpu;
option.textContent = cpu;
cpuSelect.appendChild(option);
});
}
function fetchCompatibleGPUs() {
const cpuSelect = document.getElementById('cpu-select');
const selectedCPU = cpuSelect.value;
if (!selectedCPU) {
document.getElementById('gpu-list').innerHTML = '';
return;
}
fetch('data.json')
.then(response => response.json())
.then(data => {
const compatibleGPUs = data.Compatibility[selectedCPU];
displayGPUs(compatibleGPUs);
});
}
function displayGPUs(gpus) {
const gpuList = document.getElementById('gpu-list');
gpuList.innerHTML = '';
gpus.forEach((gpu, index) => {
const gpuItem = document.createElement('div');
gpuItem.className = 'gpu-item';
gpuItem.style.animationDelay = `${index * 0.1}s`;
gpuItem.textContent = gpu;
gpuList.appendChild(gpuItem);
});
}