Refactor: 1167 _esc() → UI.escape() in 36 Dateien, SW by-v1113
Bündel 1 aus dem Duplikat-Audit: existierende zentrale Helper nutzen
statt lokale Duplikate.
Pure Migration ohne neuen Code:
- 1167 _esc()-Aufrufe in 36 Page-Modulen migriert auf UI.escape()
- 24 lokale _esc/_escape-Definitionen entfernt
- lost.js hatte _escape() (Variante) — 17 Aufrufe ebenfalls migriert
- jobs.js + breeder.js: tote Alias-Wrapper entfernt
UI.escape() existierte schon — wurde nur überall lokal nochmal
implementiert. Funktional identisch (gleiche 4-replace-chain für
& < > ").
Tests 19/19 grün. Frontend-LOC um ~120 Zeilen reduziert.
Hinweis: _emptyState (7 Stellen) und _icon (8 Stellen) wurden NICHT
migriert — sie haben abweichende Signaturen von UI.emptyState({...})
bzw. UI.icon(name). Eigener Sprint nötig.
This commit is contained in:
parent
e7939ce98e
commit
c517c9281d
42 changed files with 1115 additions and 1341 deletions
|
|
@ -71,7 +71,7 @@ window.Page_expenses = (() => {
|
|||
if (dogs.length < 2) return '';
|
||||
const pills = [{ id: null, name: 'Alle' }, ...dogs].map(d => `
|
||||
<button class="exp-dog-pill${_selectedDogId === d.id ? ' active' : ''}" data-dog="${d.id ?? ''}">
|
||||
${d.id ? UI.icon('paw-print') : ''} ${_esc(d.name)}
|
||||
${d.id ? UI.icon('paw-print') : ''} ${UI.escape(d.name)}
|
||||
</button>`).join('');
|
||||
return `<div class="exp-dog-selector" id="exp-dog-selector">${pills}</div>`;
|
||||
}
|
||||
|
|
@ -283,10 +283,10 @@ window.Page_expenses = (() => {
|
|||
const datum = new Date(e.datum + 'T00:00:00')
|
||||
.toLocaleDateString('de-DE', { day: '2-digit', month: '2-digit' });
|
||||
const dogBadge = e.dog_name
|
||||
? `<span>${UI.icon('paw-print')} ${_esc(e.dog_name)}</span>`
|
||||
? `<span>${UI.icon('paw-print')} ${UI.escape(e.dog_name)}</span>`
|
||||
: '';
|
||||
const notiz = e.notiz
|
||||
? `<div class="list-item-text">${_esc(e.notiz)}</div>`
|
||||
? `<div class="list-item-text">${UI.escape(e.notiz)}</div>`
|
||||
: '';
|
||||
return `
|
||||
<div class="list-item-card list-item-card--clickable exp-entry" data-id="${e.id}">
|
||||
|
|
@ -376,11 +376,11 @@ window.Page_expenses = (() => {
|
|||
<div class="list-item-meta-badge" style="--meta-color:${k.color}">${UI.icon(k.icon)}</div>
|
||||
<div class="list-item-body">
|
||||
<div class="list-item-title">${k.label}</div>
|
||||
${r.notiz ? `<div class="list-item-text">${_esc(r.notiz)}</div>` : ''}
|
||||
${r.notiz ? `<div class="list-item-text">${UI.escape(r.notiz)}</div>` : ''}
|
||||
<div class="list-item-meta-row">
|
||||
<span>${HAEUFIGKEIT_LABEL[r.haeufigkeit] || r.haeufigkeit}</span>
|
||||
· <span>${UI.icon('calendar')} ${naechste}</span>
|
||||
${r.dog_name ? `· <span>${UI.icon('paw-print')} ${_esc(r.dog_name)}</span>` : ''}
|
||||
${r.dog_name ? `· <span>${UI.icon('paw-print')} ${UI.escape(r.dog_name)}</span>` : ''}
|
||||
${!r.aktiv ? '· <span>Pausiert</span>' : ''}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -444,7 +444,7 @@ window.Page_expenses = (() => {
|
|||
].map(k => `<option value="${k.id}" ${r?.kategorie === k.id ? 'selected' : ''}>${k.label}</option>`).join('');
|
||||
|
||||
const dogOptions = (_appState.dogs || []).map(d =>
|
||||
`<option value="${d.id}" ${r?.dog_id === d.id ? 'selected' : ''}>${_esc(d.name)}</option>`
|
||||
`<option value="${d.id}" ${r?.dog_id === d.id ? 'selected' : ''}>${UI.escape(d.name)}</option>`
|
||||
).join('');
|
||||
|
||||
const body = `
|
||||
|
|
@ -480,7 +480,7 @@ window.Page_expenses = (() => {
|
|||
<div class="form-group">
|
||||
<label class="form-label">Bezeichnung <span class="text-muted">(optional)</span></label>
|
||||
<input class="form-control" type="text" name="notiz"
|
||||
value="${_esc(r?.notiz || '')}" placeholder="z.B. Haftpflicht Allianz">
|
||||
value="${UI.escape(r?.notiz || '')}" placeholder="z.B. Haftpflicht Allianz">
|
||||
</div>
|
||||
</form>`;
|
||||
|
||||
|
|
@ -683,7 +683,7 @@ window.Page_expenses = (() => {
|
|||
|
||||
const defaultDogId = entry?.dog_id ?? _selectedDogId;
|
||||
const dogOptions = (_appState.dogs || []).map(d =>
|
||||
`<option value="${d.id}"${defaultDogId === d.id ? ' selected' : ''}>${_esc(d.name)}</option>`
|
||||
`<option value="${d.id}"${defaultDogId === d.id ? ' selected' : ''}>${UI.escape(d.name)}</option>`
|
||||
).join('');
|
||||
|
||||
// Kategorie-Kacheln statt Dropdown
|
||||
|
|
@ -725,7 +725,7 @@ window.Page_expenses = (() => {
|
|||
<div class="form-group">
|
||||
<label class="form-label">Notiz <span class="form-label-hint">(optional)</span></label>
|
||||
<input type="text" name="notiz" class="form-control"
|
||||
value="${_esc(entry?.notiz || '')}"
|
||||
value="${UI.escape(entry?.notiz || '')}"
|
||||
placeholder="z.B. Hundesteuer 2026, Allianz Haftpflicht …">
|
||||
</div>
|
||||
|
||||
|
|
@ -852,14 +852,5 @@ window.Page_expenses = (() => {
|
|||
return Math.round(val) + ' €';
|
||||
}
|
||||
|
||||
function _esc(s) {
|
||||
if (!s) return '';
|
||||
return String(s)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"');
|
||||
}
|
||||
|
||||
return { init, refresh };
|
||||
})();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue