-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
30 lines (28 loc) · 1.18 KB
/
script.js
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
window.addEventListener('DOMContentLoaded', () => {
const partNumberInput = document.getElementById('partNumber');
const resultsContainer = document.getElementById('results');
const searchButton = document.getElementById('searchButton');
searchButton.addEventListener('click', async () => {
const partNumber = partNumberInput.value;
fetch(`https://ofv-searchup.onrender.com/api/versions?partNumber=${partNumber}`)
.then(response => response.json())
.then(versions => {
resultsContainer.innerHTML = '';
if (versions.length > 0) {
versions.forEach(version => {
const resultItem = document.createElement('div');
resultItem.innerHTML = `
<h3>Version ${version.version_number}</h3>
<a href="${version.download_link}" target="_blank">Download</a>
`;
resultsContainer.appendChild(resultItem);
});
} else {
resultsContainer.innerHTML = '<p>No matching firmwares found.</p>';
}
})
.catch(error => {
console.error('Error while requesting:', error);
resultsContainer.innerHTML = '<p>Failed to load firmwares.</p>';
});
})})