cleanup: lokale escapeHtml/esc Duplikate entfernt, globale esc() aus ui.js verwenden
This commit is contained in:
1 parent
e45498ac50
commit
eeecd3da62
3 files changed
+11
-27
No files matched your search
@@ -170,7 +170,7 @@ function openSessionPickerModal(sessions, agentMap, currentId, onSelect, options
|
||||
// Header
|
||||
const header = document.createElement('div');
|
||||
header.className = 'agent-picker-header';
|
||||
header.innerHTML = `<span>${escapeHtml(title)}</span><button class="icon-btn agent-picker-close"><i class="fa fa-times"></i></button>`;
|
||||
header.innerHTML = `<span>${esc(title)}</span><button class="icon-btn agent-picker-close"><i class="fa fa-times"></i></button>`;
|
||||
modal.appendChild(header);
|
||||
|
||||
// Body
|
||||
@@ -181,10 +181,10 @@ function openSessionPickerModal(sessions, agentMap, currentId, onSelect, options
|
||||
const noneCard = document.createElement('div');
|
||||
noneCard.className = 'card agent-picker-item' + (!currentId ? ' selected' : '');
|
||||
noneCard.innerHTML = `
|
||||
<div class="card-image" style="display:flex;align-items:center;justify-content:center"><i class="fa ${escapeHtml(noneIcon)}" style="font-size:2em;opacity:var(--semi-transparent)"></i></div>
|
||||
<div class="card-image" style="display:flex;align-items:center;justify-content:center"><i class="fa ${esc(noneIcon)}" style="font-size:2em;opacity:var(--semi-transparent)"></i></div>
|
||||
<div class="card-body">
|
||||
<div class="card-title-row">
|
||||
<span class="card-title">${escapeHtml(noneLabel)}</span>
|
||||
<span class="card-title">${esc(noneLabel)}</span>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
@@ -315,23 +315,19 @@ function showCronjobStatus(box, job) {
|
||||
const statusIcon = job.lastRunStatus === 'success' ? '✅' : '❌';
|
||||
parts.push(`<span>${statusIcon} Letzte Ausführung: ${last.toLocaleString('de-AT')}</span>`);
|
||||
if (job.lastRunStatus === 'error' && job.lastRunError) {
|
||||
parts.push(`<span class="status-error"><i class="fa fa-exclamation-triangle"></i> ${escapeHtml(job.lastRunError)}</span>`);
|
||||
parts.push(`<span class="status-error"><i class="fa fa-exclamation-triangle"></i> ${esc(job.lastRunError)}</span>`);
|
||||
}
|
||||
}
|
||||
|
||||
if (job.sessionName) {
|
||||
parts.push(`<span><i class="fa fa-comment"></i> Session: ${escapeHtml(job.sessionName)}</span>`);
|
||||
parts.push(`<span><i class="fa fa-comment"></i> Session: ${esc(job.sessionName)}</span>`);
|
||||
}
|
||||
|
||||
if (job.notifySessionName) {
|
||||
parts.push(`<span><i class="fa fa-bell"></i> Benachrichtigung → ${escapeHtml(job.notifySessionName)}</span>`);
|
||||
parts.push(`<span><i class="fa fa-bell"></i> Benachrichtigung → ${esc(job.notifySessionName)}</span>`);
|
||||
}
|
||||
|
||||
box.innerHTML = parts.join('');
|
||||
}
|
||||
|
||||
function escapeHtml(s) {
|
||||
const d = document.createElement('div');
|
||||
d.textContent = s || '';
|
||||
return d.innerHTML;
|
||||
}
|
||||
|
||||
@@ -386,12 +386,6 @@ function closeAllCardMenus() {
|
||||
document.querySelectorAll('.card-menu-dropdown').forEach(d => d.hidden = true);
|
||||
}
|
||||
|
||||
function esc(s) {
|
||||
const d = document.createElement('div');
|
||||
d.textContent = s;
|
||||
return d.innerHTML;
|
||||
}
|
||||
|
||||
function formatDate(iso) {
|
||||
if (!iso) return '';
|
||||
return new Date(iso).toLocaleString('de-AT', {
|
||||
|
||||
@@ -362,9 +362,9 @@ async function refreshTelegramStatus(sessionId, statusBox, registerBtn, deleteBt
|
||||
var html = '';
|
||||
if (active) {
|
||||
html += '<p>✅ <strong>Webhook aktiv</strong></p>';
|
||||
html += '<p><strong>URL:</strong> ' + escapeHtml(url) + '</p>';
|
||||
html += '<p><strong>URL:</strong> ' + esc(url) + '</p>';
|
||||
html += '<p><strong>Ausstehend:</strong> ' + pending + '</p>';
|
||||
if (lastError) html += '<p class="tg-error"><strong>Letzter Fehler:</strong> ' + escapeHtml(lastError) + '</p>';
|
||||
if (lastError) html += '<p class="tg-error"><strong>Letzter Fehler:</strong> ' + esc(lastError) + '</p>';
|
||||
} else {
|
||||
html += '<p>⚠️ <strong>Webhook nicht registriert</strong></p>';
|
||||
}
|
||||
@@ -375,7 +375,7 @@ async function refreshTelegramStatus(sessionId, statusBox, registerBtn, deleteBt
|
||||
registerBtn.hidden = active;
|
||||
deleteBtn.hidden = !active;
|
||||
} catch(e) {
|
||||
statusBox.innerHTML = '<p class="tg-error">Status konnte nicht abgerufen werden: ' + escapeHtml(e.message) + '</p>';
|
||||
statusBox.innerHTML = '<p class="tg-error">Status konnte nicht abgerufen werden: ' + esc(e.message) + '</p>';
|
||||
statusBox.hidden = false;
|
||||
registerBtn.hidden = false;
|
||||
deleteBtn.hidden = true;
|
||||
@@ -390,10 +390,4 @@ async function saveTelegramConfig(sessionId, tokenInput, secretInput) {
|
||||
await apiSessionTelegramSave(sessionId, token, secret, allowed);
|
||||
}
|
||||
|
||||
function escapeHtml(str) {
|
||||
return String(str)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"');
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user