Fix CSP violations and ignoreAvailable reference error
- Add .hidden utility class to style.css for CSP compliance - Replace all inline style='display: none' with class='hidden' in HTML - Update all UI modules to use classList.add/remove instead of style.display - Fix ignoreAvailable reference error in history.js (use state.ignoreAvailable) - Rebuild client bundle with vite
This commit is contained in:
+15
-15
@@ -24,11 +24,11 @@ export function initHistoryControls() {
|
||||
refreshBtn.addEventListener('click', () => loadHistory(true));
|
||||
}
|
||||
if (ignoreToggle) {
|
||||
ignoreToggle.checked = ignoreAvailable;
|
||||
ignoreToggle.checked = state.ignoreAvailable;
|
||||
ignoreToggle.addEventListener('change', () => {
|
||||
ignoreAvailable = ignoreToggle.checked;
|
||||
saveIgnoreAvailable(ignoreAvailable);
|
||||
renderHistory(lastHistoryItems);
|
||||
state.ignoreAvailable = ignoreToggle.checked;
|
||||
saveIgnoreAvailable(state.ignoreAvailable);
|
||||
renderHistory(state.lastHistoryItems);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -53,8 +53,8 @@ export function stopHistoryRefresh() {
|
||||
export function clearHistory() {
|
||||
state.lastHistoryItems = [];
|
||||
document.getElementById('history-list').innerHTML = '';
|
||||
document.getElementById('no-history').style.display = 'none';
|
||||
document.getElementById('history-error').style.display = 'none';
|
||||
document.getElementById('no-history').classList.add('hidden');
|
||||
document.getElementById('history-error').classList.add('hidden');
|
||||
}
|
||||
|
||||
export async function loadHistory(forceRefresh = false) {
|
||||
@@ -63,24 +63,24 @@ export async function loadHistory(forceRefresh = false) {
|
||||
const errorEl = document.getElementById('history-error');
|
||||
const noHistoryEl = document.getElementById('no-history');
|
||||
|
||||
loadingEl.style.display = 'block';
|
||||
errorEl.style.display = 'none';
|
||||
noHistoryEl.style.display = 'none';
|
||||
loadingEl.classList.remove('hidden');
|
||||
errorEl.classList.add('hidden');
|
||||
noHistoryEl.classList.add('hidden');
|
||||
|
||||
try {
|
||||
const result = await apiLoadHistory(forceRefresh);
|
||||
loadingEl.style.display = 'none';
|
||||
loadingEl.classList.add('hidden');
|
||||
if (result.success) {
|
||||
state.lastHistoryItems = result.history;
|
||||
renderHistory(state.lastHistoryItems);
|
||||
} else {
|
||||
errorEl.textContent = result.error || 'Failed to load history.';
|
||||
errorEl.style.display = 'block';
|
||||
errorEl.classList.remove('hidden');
|
||||
}
|
||||
} catch (err) {
|
||||
loadingEl.style.display = 'none';
|
||||
loadingEl.classList.add('hidden');
|
||||
errorEl.textContent = 'Failed to load history.';
|
||||
errorEl.style.display = 'block';
|
||||
errorEl.classList.remove('hidden');
|
||||
console.error('[History] Load error:', err);
|
||||
}
|
||||
}
|
||||
@@ -93,10 +93,10 @@ export function renderHistory(items) {
|
||||
? items.filter(item => !(item.outcome === 'failed' && item.availableForUpgrade))
|
||||
: items;
|
||||
if (!visible.length) {
|
||||
noHistoryEl.style.display = 'block';
|
||||
noHistoryEl.classList.remove('hidden');
|
||||
return;
|
||||
}
|
||||
noHistoryEl.style.display = 'none';
|
||||
noHistoryEl.classList.add('hidden');
|
||||
visible.forEach(item => listEl.appendChild(createHistoryCard(item)));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user