2021-04-07 22:03:02 +00:00
|
|
|
const fileUpload = document.getElementById("file-upload");
|
|
|
|
const textUpload = document.getElementById("text-upload");
|
|
|
|
const keepFor = document.getElementById("keep_for");
|
|
|
|
const passwordInput = document.getElementById("password-input");
|
|
|
|
|
|
|
|
const maxTime = Number("{no_auth_max_time}");
|
|
|
|
const largeFileMaxTime = Number("{no_auth_large_file_max_time}");
|
|
|
|
const largeFileSize = Number("{no_auth_large_file_size}");
|
|
|
|
|
|
|
|
let keep = Number(keepFor.value);
|
|
|
|
let size = fileUpload.files[0]
|
|
|
|
? fileUpload.files[0].size
|
|
|
|
: textUpload.value.length;
|
2021-08-18 21:22:50 +00:00
|
|
|
|
|
|
|
const updatePasswordInput = () => {
|
|
|
|
const requirePassword = keep > maxTime || (size > largeFileSize && keep > largeFileMaxTime);
|
|
|
|
passwordInput.className = requirePassword ? "" : "hidden";
|
|
|
|
};
|
|
|
|
|
2021-04-07 22:03:02 +00:00
|
|
|
updatePasswordInput();
|
|
|
|
|
2021-08-18 21:22:50 +00:00
|
|
|
fileUpload.addEventListener("change", () => {
|
2021-04-07 22:03:02 +00:00
|
|
|
size = fileUpload.files[0]
|
|
|
|
? fileUpload.files[0].size
|
|
|
|
: textUpload.value.length;
|
|
|
|
updatePasswordInput();
|
|
|
|
});
|
2021-08-18 21:22:50 +00:00
|
|
|
textUpload.addEventListener("input", () => {
|
2021-04-07 22:03:02 +00:00
|
|
|
if (!fileUpload.files[0]) {
|
|
|
|
size = textUpload.value.length;
|
|
|
|
updatePasswordInput();
|
|
|
|
}
|
|
|
|
});
|
2021-08-18 21:22:50 +00:00
|
|
|
keepFor.addEventListener("change", () => {
|
2021-04-07 22:03:02 +00:00
|
|
|
keep = Number(keepFor.value);
|
|
|
|
updatePasswordInput();
|
|
|
|
});
|
|
|
|
|