docs: вложения статей (doc_files), подписи и библиотека картинок, быстрое ред. отзыва
This commit is contained in:
@@ -403,18 +403,23 @@ function closeReportCard() {
|
||||
setReportFieldsOpen(false);
|
||||
}
|
||||
|
||||
function fileExtLabel(name) {
|
||||
const m = String(name || '').match(/\.[^.\/]+$/);
|
||||
return m ? m[0].toLowerCase() : esc(name || '');
|
||||
}
|
||||
|
||||
function filesHTML(files) {
|
||||
if (!files || !files.length) return '';
|
||||
return `<div class="entry-files">${files.map(f => {
|
||||
const url = `${API}/api/files/${f.token}`;
|
||||
const label = fileExtLabel(f.name);
|
||||
let link;
|
||||
if (isImageFile(f.name)) {
|
||||
link = `<a class="f-link" href="#" data-img="${url}" title="Открыть">${esc(f.name)}</a>`;
|
||||
link = `<a class="f-link" href="#" data-img="${url}" title="${esc(f.name)}">${label}</a>`;
|
||||
} else if (isPlayableVideoFile(f.name)) {
|
||||
link = `<a class="f-link" href="${url}?play=1" data-video="${url}?play=1" data-video-name="${esc(f.name)}" data-video-token="${f.token}" title="Смотреть">${esc(f.name)}</a>`;
|
||||
link = `<a class="f-link" href="${url}?play=1" data-video="${url}?play=1" data-video-name="${esc(f.name)}" data-video-token="${f.token}" title="${esc(f.name)}">${label}</a>`;
|
||||
} else {
|
||||
const note = isVideoFile(f.name) ? 'Скачать (браузер не умеет играть этот формат)' : 'Скачать';
|
||||
link = `<a class="f-link" href="${url}" download title="${note}">${esc(f.name)}</a>`;
|
||||
link = `<a class="f-link" href="${url}" download title="${esc(f.name)}">${label}</a>`;
|
||||
}
|
||||
return `<span class="f-item">${link}<button class="f-detach" data-detach="${f.id}" title="Открепить файл">✕</button></span>`;
|
||||
}).join('')}</div>`;
|
||||
|
||||
Reference in New Issue
Block a user