1.0 version

This commit is contained in:
vxclutch
2026-05-27 19:00:09 -04:00
parent 7ee19a2883
commit 1234288e03
6 changed files with 70 additions and 24 deletions

View File

@@ -22,26 +22,57 @@
<p id="status"></p>
<script>
const tokenInput = document.getElementById('tokenInput');
const submitBtn = document.getElementById('submitBtn');
const status = document.getElementById('status');
const tokenInput = document.getElementById('tokenInput');
const submitBtn = document.getElementById('submitBtn');
const status = document.getElementById('status');
submitBtn.addEventListener('click', async () => {
const token = tokenInput.value.trim();
submitBtn.addEventListener('click', async () => {
const token = tokenInput.value.trim();
if (!token) {
status.textContent = 'Please enter a token.';
return;
}
if (!token) {
status.textContent = 'Please enter a token.';
return;
}
const response = await fetch('/api/receive-token', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ token })
});
try {
const response = await fetch('/api/receive-token', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ token })
});
</script>
if (!response.ok) {
status.textContent = 'Download failed.';
return;
}
const blob = await response.blob();
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
const disposition = response.headers.get('Content-Disposition');
let filename = 'download.bin';
if (disposition && disposition.includes('filename=')) {
filename = disposition
.split('filename=')[1]
.replace(/"/g, '');
}
a.download = filename;
document.body.appendChild(a);
a.click();
a.remove();
window.URL.revokeObjectURL(url);
status.textContent = 'Download started.';
} catch (err) {
console.error(err);
status.textContent = 'An error occurred.';
}
});
</script>
</body>
</html>