feat: mark service password input as required
This commit is contained in:
parent
d2ba86dfd2
commit
273451f8d4
2 changed files with 18 additions and 12 deletions
|
@ -1,7 +1,7 @@
|
|||
|
||||
<div id="password-input">
|
||||
<label for="password">
|
||||
passwort benötigt (>{auth_time} oder datei >{auth_large_size} und >{auth_large_time})
|
||||
service passwort benötigt (>{auth_time} oder datei >{auth_large_size} und >{auth_large_time})
|
||||
</label>
|
||||
<br />
|
||||
<input id="password" name="password" type="password" />
|
||||
|
|
|
@ -1,11 +1,12 @@
|
|||
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 fileUpload = document.getElementById("file-upload");
|
||||
const textUpload = document.getElementById("text-upload");
|
||||
const keepFor = document.getElementById("keep_for");
|
||||
const passwordField = document.getElementById("password-input");
|
||||
const passwordInput = document.getElementById("password");
|
||||
|
||||
const maxTime = Number('{no_auth_max_time}');
|
||||
const largeFileMaxTime = Number('{no_auth_large_file_max_time}');
|
||||
const largeFileSize = Number('{no_auth_large_file_size}');
|
||||
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]
|
||||
|
@ -15,24 +16,29 @@ let size = fileUpload.files[0]
|
|||
const updatePasswordInput = () => {
|
||||
const requirePassword =
|
||||
keep > maxTime || (size > largeFileSize && keep > largeFileMaxTime);
|
||||
passwordInput.className = requirePassword ? '' : 'hidden';
|
||||
passwordField.className = requirePassword ? "" : "hidden";
|
||||
if (requirePassword) {
|
||||
passwordInput.setAttribute("required", "required");
|
||||
} else {
|
||||
passwordInput.removeAttribute("required");
|
||||
}
|
||||
};
|
||||
|
||||
updatePasswordInput();
|
||||
|
||||
fileUpload.addEventListener('change', () => {
|
||||
fileUpload.addEventListener("change", () => {
|
||||
size = fileUpload.files[0]
|
||||
? fileUpload.files[0].size
|
||||
: textUpload.value.length;
|
||||
updatePasswordInput();
|
||||
});
|
||||
textUpload.addEventListener('input', () => {
|
||||
textUpload.addEventListener("input", () => {
|
||||
if (!fileUpload.files[0]) {
|
||||
size = textUpload.value.length;
|
||||
updatePasswordInput();
|
||||
}
|
||||
});
|
||||
keepFor.addEventListener('change', () => {
|
||||
keepFor.addEventListener("change", () => {
|
||||
keep = Number(keepFor.value);
|
||||
updatePasswordInput();
|
||||
});
|
||||
|
|
Loading…
Add table
Reference in a new issue