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
|
|
@ -368,7 +368,7 @@ window.Page_wetter = (() => {
|
|||
box-shadow:${shadow};transform:${transform};
|
||||
transition:all .15s;user-select:none">
|
||||
<span style="font-size:var(--text-xs);font-weight:600;
|
||||
margin-bottom:var(--space-1)">${_esc(dayName)}</span>
|
||||
margin-bottom:var(--space-1)">${UI.escape(dayName)}</span>
|
||||
<div style="margin-bottom:var(--space-1)">${_wmoIcon(d.weathercode, '1.5rem', active ? 'filter:brightness(0) invert(1)' : '')}</div>
|
||||
<span class="wttr-temp"
|
||||
style="font-size:var(--text-xs);color:${textSec};white-space:nowrap">
|
||||
|
|
@ -414,13 +414,13 @@ window.Page_wetter = (() => {
|
|||
: 0;
|
||||
}
|
||||
|
||||
const locName = _data.location_name ? `<div style="font-size:var(--text-xs);color:var(--c-text-muted);margin-bottom:2px">${_esc(_data.location_name)}</div>` : '';
|
||||
const locName = _data.location_name ? `<div style="font-size:var(--text-xs);color:var(--c-text-muted);margin-bottom:2px">${UI.escape(_data.location_name)}</div>` : '';
|
||||
el.innerHTML = `
|
||||
${locName}
|
||||
<div style="display:flex;align-items:center;gap:var(--space-3);margin-bottom:var(--space-4)">
|
||||
${_wmoIcon(d.weathercode, '3.5rem')}
|
||||
<div>
|
||||
<div style="font-weight:700;font-size:var(--text-lg)">${_esc(desc)}</div>
|
||||
<div style="font-weight:700;font-size:var(--text-lg)">${UI.escape(desc)}</div>
|
||||
<div style="font-size:var(--text-2xl);font-weight:800;color:var(--c-primary);line-height:1.1">
|
||||
${Math.round(d.temp_max)}°
|
||||
<span style="font-size:var(--text-base);font-weight:400;color:var(--c-text-secondary)">
|
||||
|
|
@ -445,10 +445,10 @@ window.Page_wetter = (() => {
|
|||
margin-bottom:var(--space-1)">
|
||||
<span style="display:flex;align-items:center;gap:4px">
|
||||
<svg class="ph-icon" style="width:14px;height:14px;color:#F97316"><use href="/icons/phosphor.svg#sun-horizon"></use></svg>
|
||||
${_esc(sunriseStr)}
|
||||
${UI.escape(sunriseStr)}
|
||||
</span>
|
||||
<span style="display:flex;align-items:center;gap:4px">
|
||||
${_esc(sunsetStr)}
|
||||
${UI.escape(sunsetStr)}
|
||||
<svg class="ph-icon" style="width:14px;height:14px;color:#7C3AED"><use href="/icons/phosphor.svg#moon-stars"></use></svg>
|
||||
</span>
|
||||
</div>
|
||||
|
|
@ -469,9 +469,9 @@ window.Page_wetter = (() => {
|
|||
</span>
|
||||
<div class="flex-1">
|
||||
<div style="font-size:var(--text-sm);font-weight:600">
|
||||
${_esc(compass)} · ${Math.round(d.wind_kmh ?? 0)} km/h
|
||||
${UI.escape(compass)} · ${Math.round(d.wind_kmh ?? 0)} km/h
|
||||
</div>
|
||||
<div class="text-xs-secondary">${_esc(bft)}</div>
|
||||
<div class="text-xs-secondary">${UI.escape(bft)}</div>
|
||||
</div>
|
||||
${d.precip_sum != null ? `
|
||||
<div class="text-right">
|
||||
|
|
@ -488,7 +488,7 @@ window.Page_wetter = (() => {
|
|||
font-size:var(--text-xs);margin-bottom:4px">
|
||||
<span class="text-secondary">UV-Index</span>
|
||||
<span style="font-weight:600;color:${uvColor}">
|
||||
${d.uv_index ?? 0} — ${_esc(uvLabel)}
|
||||
${d.uv_index ?? 0} — ${UI.escape(uvLabel)}
|
||||
</span>
|
||||
</div>
|
||||
<div style="height:6px;border-radius:999px;background:var(--c-border);overflow:hidden">
|
||||
|
|
@ -596,7 +596,7 @@ window.Page_wetter = (() => {
|
|||
Niederschlagswahrscheinlichkeit
|
||||
</span>
|
||||
<span style="font-size:var(--text-xs);color:var(--c-text-secondary);margin-left:auto">
|
||||
${_selDay === 0 ? 'heute' : _esc(d.date ? new Date(d.date + 'T12:00').toLocaleDateString('de', {weekday:'short', day:'numeric', month:'short'}) : '')}
|
||||
${_selDay === 0 ? 'heute' : UI.escape(d.date ? new Date(d.date + 'T12:00').toLocaleDateString('de', {weekday:'short', day:'numeric', month:'short'}) : '')}
|
||||
</span>
|
||||
</div>
|
||||
<!-- Baseline -->
|
||||
|
|
@ -648,10 +648,10 @@ window.Page_wetter = (() => {
|
|||
margin-bottom:var(--space-4);text-align:center">
|
||||
<div style="font-size:2rem;line-height:1;margin-bottom:4px">${_wl.emoji}</div>
|
||||
<div style="font-weight:800;font-size:var(--text-lg);color:${_wl.color};line-height:1.2">
|
||||
${_esc(_wl.label)}
|
||||
${UI.escape(_wl.label)}
|
||||
</div>
|
||||
<div style="font-size:var(--text-xs);color:var(--c-text-secondary);margin-top:4px">
|
||||
${_esc(_wl.sub)}
|
||||
${UI.escape(_wl.sub)}
|
||||
</div>
|
||||
</div>
|
||||
<h3 style="font-size:var(--text-base);font-weight:700;margin-bottom:var(--space-4)">
|
||||
|
|
@ -670,10 +670,10 @@ window.Page_wetter = (() => {
|
|||
<svg class="ph-icon" style="width:1.3rem;height:1.3rem;flex-shrink:0;color:var(--c-primary)"><use href="/icons/phosphor.svg#paw-print"></use></svg>
|
||||
<div class="flex-1">
|
||||
<div style="font-weight:600;font-size:var(--text-sm);color:${aspColor}">
|
||||
Asphalt ~${Math.round(d.asphalt_temp)}°C — ${_esc(aspText)}
|
||||
Asphalt ~${Math.round(d.asphalt_temp)}°C — ${UI.escape(aspText)}
|
||||
</div>
|
||||
${aspAdvice ? `<div style="font-size:var(--text-xs);color:var(--c-text-secondary);margin-top:2px">
|
||||
${_esc(aspAdvice)}
|
||||
${UI.escape(aspAdvice)}
|
||||
</div>` : ''}
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -735,7 +735,7 @@ window.Page_wetter = (() => {
|
|||
padding:3px 10px;background:${col}22;
|
||||
border:1px solid ${col}55;color:${col};font-weight:600">
|
||||
<span style="width:6px;height:6px;border-radius:50%;background:${col};display:inline-block"></span>
|
||||
${_esc(name)}: ${_esc(lbl)}
|
||||
${UI.escape(name)}: ${UI.escape(lbl)}
|
||||
</span>`;
|
||||
}).join('')}
|
||||
</div>
|
||||
|
|
@ -756,7 +756,7 @@ window.Page_wetter = (() => {
|
|||
<div class="flex-1">
|
||||
<span style="font-size:var(--text-sm);font-weight:600">Zecken-Risiko: </span>
|
||||
<span style="font-size:var(--text-sm);color:${tickColor};font-weight:700">
|
||||
${_esc(tickLabel)}
|
||||
${UI.escape(tickLabel)}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -786,7 +786,7 @@ window.Page_wetter = (() => {
|
|||
<svg class="ph-icon" style="width:1.3rem;height:1.3rem;flex-shrink:0;color:${fellHint.color}">
|
||||
<use href="/icons/phosphor.svg#${fellHint.icon}"></use>
|
||||
</svg>
|
||||
<div class="text-sm">${_esc(fellHint.text)}</div>
|
||||
<div class="text-sm">${UI.escape(fellHint.text)}</div>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
|
@ -876,7 +876,7 @@ window.Page_wetter = (() => {
|
|||
</span>
|
||||
<span class="text-xs-secondary">/ 10</span>
|
||||
<span style="font-size:var(--text-xs);font-weight:600;color:${color};
|
||||
white-space:nowrap">— ${_esc(text)}</span>
|
||||
white-space:nowrap">— ${UI.escape(text)}</span>
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
|
|
@ -912,7 +912,7 @@ window.Page_wetter = (() => {
|
|||
padding:3px 10px;background:${s.color}22;
|
||||
border:1px solid ${s.color}55;color:${s.color};font-weight:600">
|
||||
<svg class="ph-icon" style="width:12px;height:12px"><use href="/icons/phosphor.svg#nose"></use></svg>
|
||||
Schnüffel: ${_esc(s.label)}
|
||||
Schnüffel: ${UI.escape(s.label)}
|
||||
</span>
|
||||
`;
|
||||
}
|
||||
|
|
@ -1072,15 +1072,6 @@ window.Page_wetter = (() => {
|
|||
return ['hoch', '#F44336'];
|
||||
}
|
||||
|
||||
function _esc(s) {
|
||||
if (s == null) return '';
|
||||
return String(s)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"');
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------
|
||||
// MEINE WETTERREKORDE
|
||||
// ----------------------------------------------------------
|
||||
|
|
@ -1116,15 +1107,15 @@ window.Page_wetter = (() => {
|
|||
display:flex;align-items:center;gap:3px;font-weight:700;
|
||||
text-transform:uppercase;letter-spacing:.04em">
|
||||
<span>${emoji}</span>
|
||||
<span>${_esc(title)}</span>
|
||||
<span>${UI.escape(title)}</span>
|
||||
</div>
|
||||
<div style="font-size:var(--text-lg);font-weight:800;color:${color};line-height:1.1">
|
||||
${_esc(value)}
|
||||
${UI.escape(value)}
|
||||
</div>
|
||||
<div style="font-size:10px;color:var(--c-text-secondary);
|
||||
overflow:hidden;display:-webkit-box;
|
||||
-webkit-line-clamp:2;-webkit-box-orient:vertical;line-height:1.3">
|
||||
${_esc(subtitle)}
|
||||
${UI.escape(subtitle)}
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue