mirror of
https://github.com/RoastSlav/quickdrop.git
synced 2025-12-30 19:20:14 -06:00
added a warning if keep indefinitely is checked and a password is not input
This commit is contained in:
@@ -69,6 +69,21 @@ function isPasswordProtected() {
|
||||
return passwordField && passwordField.value.trim() !== "";
|
||||
}
|
||||
|
||||
function validateKeepIndefinitely() {
|
||||
const keepIndefinitely = document.getElementById("keepIndefinitely").checked;
|
||||
const password = document.getElementById("password").value;
|
||||
|
||||
if (keepIndefinitely && !password) {
|
||||
return confirm(
|
||||
"You have selected 'Keep indefinitely' but haven't set a password. " +
|
||||
"This means the file will only be deletable by an admin. " +
|
||||
"Do you want to proceed?"
|
||||
);
|
||||
}
|
||||
|
||||
return true; // Allow form submission if conditions are not met
|
||||
}
|
||||
|
||||
function validateFileSize() {
|
||||
const maxFileSize = document.getElementsByClassName('maxFileSize')[0].innerText;
|
||||
const file = document.getElementById('file').files[0];
|
||||
|
||||
@@ -85,23 +85,17 @@
|
||||
id="uploadForm"
|
||||
method="post"
|
||||
th:action="@{/file/upload}"
|
||||
onsubmit="return validateKeepIndefinitely()"
|
||||
>
|
||||
<!-- CSRF Token -->
|
||||
<input th:name="${_csrf.parameterName}"
|
||||
th:value="${_csrf.token}"
|
||||
type="hidden"/>
|
||||
<input th:name="${_csrf.parameterName}" th:value="${_csrf.token}" type="hidden"/>
|
||||
|
||||
<!-- UUID -->
|
||||
<input name="uuid"
|
||||
th:value="${uuid}"
|
||||
type="hidden"/>
|
||||
<input name="uuid" th:value="${uuid}" type="hidden"/>
|
||||
|
||||
<!-- File Input -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label"
|
||||
for="file">Select
|
||||
a
|
||||
file:</label>
|
||||
<label class="form-label" for="file">Select a file:</label>
|
||||
<input
|
||||
class="form-control"
|
||||
id="file"
|
||||
@@ -113,61 +107,30 @@
|
||||
</div>
|
||||
|
||||
<!-- File Size Alert -->
|
||||
<div class="alert alert-danger"
|
||||
id="fileSizeAlert"
|
||||
role="alert"
|
||||
style="display: none;">
|
||||
File
|
||||
size
|
||||
exceeds
|
||||
the
|
||||
<span th:text="${maxFileSize}">1GB</span>
|
||||
limit.
|
||||
<div class="alert alert-danger" id="fileSizeAlert" role="alert" style="display: none;">
|
||||
File size exceeds the <span th:text="${maxFileSize}">1GB</span> limit.
|
||||
</div>
|
||||
|
||||
<!-- Description Input -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label"
|
||||
for="description">Description:</label>
|
||||
<input
|
||||
class="form-control"
|
||||
id="description"
|
||||
name="description"
|
||||
type="text"
|
||||
/>
|
||||
<label class="form-label" for="description">Description:</label>
|
||||
<input class="form-control" id="description" name="description" type="text"/>
|
||||
</div>
|
||||
|
||||
<!-- Keep Indefinitely Checkbox -->
|
||||
<div class="form-check mb-3">
|
||||
<input
|
||||
class="form-check-input"
|
||||
id="keepIndefinitely"
|
||||
name="keepIndefinitely"
|
||||
type="checkbox"
|
||||
/>
|
||||
<label class="form-check-label"
|
||||
for="keepIndefinitely">
|
||||
Keep
|
||||
indefinitely
|
||||
</label>
|
||||
<input class="form-check-input" id="keepIndefinitely" name="keepIndefinitely" type="checkbox"/>
|
||||
<label class="form-check-label" for="keepIndefinitely">Keep indefinitely</label>
|
||||
</div>
|
||||
|
||||
<!-- Password Input -->
|
||||
<div class="mb-3">
|
||||
<label class="form-label"
|
||||
for="password">Password
|
||||
(Optional):</label>
|
||||
<input
|
||||
class="form-control"
|
||||
id="password"
|
||||
name="password"
|
||||
type="password"
|
||||
/>
|
||||
<label class="form-label" for="password">Password (Optional):</label>
|
||||
<input class="form-control" id="password" name="password" type="password"/>
|
||||
</div>
|
||||
|
||||
<!-- Submit Button -->
|
||||
<button class="btn btn-primary w-100"
|
||||
type="submit">
|
||||
<button class="btn btn-primary w-100" type="submit">
|
||||
Upload
|
||||
</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user