get random hex as title

This commit is contained in:
The Ghost of FOSS' Past 2024-10-28 13:04:26 -05:00
parent 2912d110c1
commit 04f656c2c0

View file

@ -7,6 +7,10 @@ document.getElementById('search-button').addEventListener('click', async () => {
alert('Please enter a search query.'); alert('Please enter a search query.');
return; return;
} }
function getRandomHex() {
const randomNumber = Math.floor(Math.random() * 0xFFFF); // Generates a number between 0 and 65535
return randomNumber.toString(16).padStart(4, '0'); // Converts to hex and pads to ensure it's 4 digits
}
try { try {
const response = await fetch(`https://ubertuberbe.nodemixaholic.com/search?q=${encodeURIComponent(query)}`); const response = await fetch(`https://ubertuberbe.nodemixaholic.com/search?q=${encodeURIComponent(query)}`);
@ -34,7 +38,7 @@ document.getElementById('search-button').addEventListener('click', async () => {
const a = document.createElement('a'); const a = document.createElement('a');
a.style.display = 'none'; a.style.display = 'none';
a.href = url; a.href = url;
a.download = `${e.target.dataset.title}.webm`; // You might want to set this dynamically a.download = `${getRandomHex}.webm`; // You might want to set this dynamically
document.body.appendChild(a); document.body.appendChild(a);
window.URL.revokeObjectURL(url); window.URL.revokeObjectURL(url);
}); });