Files
xamxam/app/public/assets/js/app/admin-acces.js
Pontoporeia 6ecd3d4540 Fix biome lint errors: remove duplicate CSS properties, apply safe auto-fixes
CSS:
- Remove duplicate 'background' fallbacks in base.css, header.css, search.css
  (solid color declared before gradient — gradient always wins)
- Remove duplicate 'padding' in admin.css .admin-import-log

JS (biome --write safe fixes applied):
- function() → arrow functions in all IIFEs and callbacks
- forEach/callback → arrow functions
- evaluePtrn → parseInt(x, 10) in admin-contacts-form.js
- Cleaned label text in build.mjs lint step

Remaining warnings are intentional: !important overrides, descending
specificity (admin.css cascade), noUnusedVariables (functions exported
to window/onclick), useTemplate style preference.
2026-06-24 13:57:00 +02:00

106 lines
3.6 KiB
JavaScript

/**
* admin-acces.js — Share link + file access management for acces.php.
*
* Reads PHP-injected data from <meta> tags:
* <meta name="acces-base-url" content="...">
* <meta name="acces-new-link-password" content="...">
* <meta name="acces-new-link-slug" content="...">
*/
(() => {
var baseUrlMeta = document.querySelector('meta[name="acces-base-url"]');
var passwordMeta = document.querySelector('meta[name="acces-new-link-password"]');
var slugMeta = document.querySelector('meta[name="acces-new-link-slug"]');
// Show result dialog after redirect (new link created)
if (passwordMeta && slugMeta && passwordMeta.content && slugMeta.content) {
document.getElementById('create-result-password').value = passwordMeta.content;
document.getElementById('create-result-url').value =
(baseUrlMeta ? baseUrlMeta.content : '') + '/partage/' + slugMeta.content;
document.getElementById('create-result-dialog').showModal();
}
// Create dialog opener
var createBtn = document.getElementById('open-create-dialog');
if (createBtn) {
createBtn.addEventListener('click', () => {
document.getElementById('create-dialog').showModal();
});
}
})();
function copyUrl(id) {
var input = document.getElementById('url-' + id);
navigator.clipboard.writeText(input.value).then(() => {
var btn = event.target.closest('button');
if (btn) {
var orig = btn.getAttribute('title') || '';
btn.setAttribute('title', '✓ Copié');
setTimeout(() => {
btn.setAttribute('title', orig);
}, 1200);
}
});
}
function copyUrlFrom(el) {
navigator.clipboard.writeText(el.value).then(() => {
var btn = el.nextElementSibling;
if (btn) {
var orig = btn.textContent;
btn.textContent = '✓ Copié';
setTimeout(() => {
btn.textContent = orig;
}, 1200);
}
});
}
function copyTextToClipboard(text) {
navigator.clipboard.writeText(text)
.then(() => {
var btn = event && event.target ? event.target.closest('button') : null;
if (btn) {
var orig = btn.getAttribute('title') || '';
btn.setAttribute('title', '✓ Copié');
setTimeout(() => {
btn.setAttribute('title', orig);
}, 1200);
}
})
.catch(() => {});
}
function openEditDialog(id, name, hasPassword, expiresVal) {
document.getElementById('edit-link-id').value = id;
document.getElementById('edit-name').value = name || '';
document.getElementById('edit-expires').value = expiresVal || '';
document.getElementById('edit-dialog').showModal();
}
function openApproveDialog(requestId) {
document.getElementById('approve-request-id').value = requestId;
document.getElementById('approve-dialog').showModal();
}
function openRejectDialog(requestId) {
document.getElementById('reject-request-id').value = requestId;
document.getElementById('reject-dialog').showModal();
}
var _pendingArchiveLinkId = null;
function openArchiveLinkDialog(id) {
_pendingArchiveLinkId = id;
document.getElementById('archive-link-dialog').showModal();
}
function _executeArchiveLink() {
var form = document.getElementById('archive-link-form-' + _pendingArchiveLinkId);
if (form) form.submit();
}
function openDeleteArchivedLinkDialog(id) {
document.getElementById('delete-archived-link-id').value = id;
document.getElementById('delete-archived-link-dialog').showModal();
}