This commit is contained in:
2026-08-09 02:22:22 +02:00
parent 3179d15b42
commit b10ddac6f3
28 changed files with 689 additions and 66 deletions

View File

@@ -1491,6 +1491,7 @@ window.initUploadForm = (selector) => {
let ratingSwitch = '';
let visibilitySwitch = '';
let expirySwitch = '';
let tagsUI = '';
let ocUI = '';
let commentUI = '';
@@ -1543,6 +1544,31 @@ window.initUploadForm = (selector) => {
visibilitySwitch = '';
}
const globalExpiryEl = form.querySelector('select[name="expiry"], input[name="expiry"]');
const hasExpirySection = !!globalExpiryEl || window.f0ckEnableExpiringUploads !== false;
if (hasExpirySection && globalExpiryEl) {
const globalExpiry = globalExpiryEl.value || 'permanent';
const expiryValue = (item.expiry !== undefined && item.expiry !== '') ? item.expiry : globalExpiry;
item.expiry = expiryValue;
expirySwitch = `
<div class="item-expiry-container" style="margin-top: 4px;">
<select class="item-expiry-select" style="width: 100%; padding: 4px 8px; background: rgba(0,0,0,0.3); color: #fff; border: 1px solid var(--nav-border-color, rgba(255,255,255,0.1)); border-radius: 4px; font-size: 0.85em; cursor: pointer;">
<option value="permanent" ${expiryValue === 'permanent' ? 'selected' : ''}>Permanent (Never expires)</option>
<option value="30minutes" ${expiryValue === '30minutes' ? 'selected' : ''}>30 Minutes</option>
<option value="1hour" ${expiryValue === '1hour' ? 'selected' : ''}>1 Hour</option>
<option value="24hours" ${expiryValue === '24hours' ? 'selected' : ''}>24 Hours</option>
<option value="1week" ${expiryValue === '1week' ? 'selected' : ''}>1 Week</option>
<option value="1month" ${expiryValue === '1month' ? 'selected' : ''}>1 Month</option>
</select>
</div>
`;
} else {
expirySwitch = '';
}
const tagsPlaceholder = window.f0ckI18n?.upload_tags_placeholder || 'Tags...';
const minTagsHint = shitpostMinTags > 0 ? ` (min ${shitpostMinTags})` : '';
tagsUI = `
@@ -1587,6 +1613,7 @@ window.initUploadForm = (selector) => {
${titleUI}
${ratingSwitch}
${visibilitySwitch}
${expirySwitch}
${tagsUI}
${commentUI}
`;
@@ -1607,6 +1634,15 @@ window.initUploadForm = (selector) => {
};
});
// Handle Expiry
const expirySelect = infoRow.querySelector('.item-expiry-select');
if (expirySelect) {
expirySelect.onchange = () => {
item.expiry = expirySelect.value;
};
}
// Handle Comment
const commentInput = infoRow.querySelector('.item-comment-input');
const emojiTrigger = infoRow.querySelector('.item-emoji-trigger');
@@ -2472,6 +2508,9 @@ window.initUploadForm = (selector) => {
try {
const globalVisEl = form.querySelector('input[name="visibility"]:checked');
const visibilityVal = globalVisEl ? globalVisEl.value : '0';
const globalExpiryEl = form.querySelector('select[name="expiry"], input[name="expiry"]');
const expiryVal = globalExpiryEl ? globalExpiryEl.value : 'permanent';
const resp = await fetch('/api/v2/upload-url', {
method: 'POST',
headers: {
@@ -2483,6 +2522,7 @@ window.initUploadForm = (selector) => {
url,
rating: globalRatingEl ? globalRatingEl.value : 'sfw',
visibility: visibilityVal,
expiry: expiryVal,
tags: tags.join(','),
comment: comment,
is_oc: isOc,
@@ -2590,10 +2630,12 @@ window.initUploadForm = (selector) => {
for (let i = 0; i < selectedFiles.length; i++) {
const item = selectedFiles[i];
const globalVisEl = form.querySelector('input[name="visibility"]:checked');
const globalExpiryEl = form.querySelector('select[name="expiry"], input[name="expiry"]');
const isUrlItem = isShitpost && item.type === 'url';
const file = !isUrlItem ? (isShitpost ? item.file : item) : null;
const fileRating = isShitpost ? item.rating : (globalRatingEl ? globalRatingEl.value : 'sfw');
const fileVisibility = isShitpost ? (item.visibility || globalVisEl?.value || '0') : (globalVisEl?.value || '0');
const fileExpiry = isShitpost ? (item.expiry || globalExpiryEl?.value || 'permanent') : (globalExpiryEl?.value || 'permanent');
const fileTags = isShitpost ? item.tags : tags;
const fileComment = isShitpost ? item.comment : comment;
const fileTitle = isShitpost ? (item.title || '') : titleVal;
@@ -2611,6 +2653,7 @@ window.initUploadForm = (selector) => {
}
formData.append('rating', fileRating);
formData.append('visibility', fileVisibility);
formData.append('expiry', fileExpiry);
formData.append('tags', fileTags.join(','));
formData.append('is_oc', (isShitpost ? item.is_oc : isOc) ? 'true' : 'false');
if (isShitpost) formData.append('is_shitpost', 'true');
@@ -2663,6 +2706,7 @@ window.initUploadForm = (selector) => {
url: item.url,
rating: fileRating,
visibility: fileVisibility,
expiry: fileExpiry,
tags: fileTags.join(','),
is_oc: (isShitpost ? item.is_oc : isOc),
comment: fileComment,