allow downloading individual files from bundle
This commit is contained in:
parent
43d03869ab
commit
007289ffe5
15 changed files with 499 additions and 69 deletions
26
static/js/download-landing.js
Normal file
26
static/js/download-landing.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const downloadCodeInput = document.getElementById('download_code_input');
|
||||
const downloadButton = document.getElementById('download_button');
|
||||
const downloadForm = document.getElementById('download_form');
|
||||
downloadCodeInput.addEventListener('beforeinput', (e) => {
|
||||
if (/^[a-zA-Z0-9-]+$/.test(e.data)) { return; }
|
||||
e.preventDefault();
|
||||
if (e.data === ' ') {
|
||||
downloadCodeInput.value += '-';
|
||||
}
|
||||
});
|
||||
const disableEnableDownload = () => { downloadButton.disabled = (downloadCodeInput.value === ''); };
|
||||
disableEnableDownload();
|
||||
downloadCodeInput.addEventListener('input', disableEnableDownload);
|
||||
downloadForm.addEventListener('submit', (e) => {
|
||||
if (downloadCodeInput.value === '') {
|
||||
e.preventDefault();
|
||||
} else {
|
||||
setTimeout(() => {
|
||||
downloadCodeInput.value = '';
|
||||
downloadButton.disabled = true;
|
||||
}, 0);
|
||||
}
|
||||
});
|
||||
downloadCodeInput.focus();
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue