Skip to content

Commit d0ff58c

Browse files
committed
fix: warning into banner
1 parent 9ccfde3 commit d0ff58c

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

app/index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ <h1>LLM Visual Evaluator</h1>
1313
</header>
1414

1515
<main class="layout" role="main">
16-
<div id="corsWarning" style="display:none; margin:8px 8px 0 8px; padding:8px; border:1px solid #e9b34f; background:#fff8e6; color:#8a6100; border-radius:6px;">
17-
Running from file:// has origin "null" and many providers block it. To avoid CORS issues, open this app from a permitted origin (e.g., your GitHub Pages URL).
16+
<div id="corsWarning" role="alert" aria-live="polite">
17+
<span>
18+
Running from file:// has origin "null" and many providers block it. To avoid CORS issues, open this app from a permitted origin (e.g., your GitHub Pages URL).
19+
</span>
20+
<button id="corsClose" type="button" class="banner-close" aria-label="Dismiss CORS warning" title="Dismiss">×</button>
1821
</div>
1922
<!-- Inputs Panel (Left) -->
2023
<section class="panel inputs" aria-label="Inputs panel">

app/src/main.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ const historyTable = new HistoryTable(historyTableEl, historyStore);
6464
const historyDialog = new HistoryDialog(document.getElementById('historyDialog'), historyStore, overlay, resultsTable, imageLoader);
6565
const storageRoot = document.getElementById('sidebar-storage');
6666
const corsWarning = document.getElementById('corsWarning');
67+
const corsClose = document.getElementById('corsClose');
6768

6869
let activeBatch = null;
6970

@@ -78,10 +79,18 @@ renderPromptTemplateTab();
7879
// Show CORS warning if opened from file:// to avoid Origin null
7980
try {
8081
if (location.protocol === 'file:') {
81-
if (corsWarning) corsWarning.style.display = 'block';
82+
const hidden = typeof localStorage !== 'undefined' && localStorage.getItem('hideCorsWarning') === '1';
83+
if (corsWarning && !hidden) corsWarning.style.display = 'block';
8284
}
8385
} catch {}
8486

87+
if (corsClose && corsWarning) {
88+
corsClose.addEventListener('click', () => {
89+
corsWarning.style.display = 'none';
90+
try { localStorage.setItem('hideCorsWarning', '1'); } catch {}
91+
});
92+
}
93+
8594
function setBadge(text) {
8695
badge.textContent = text;
8796
}

app/styles.css

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,37 @@ body {
1919
background: var(--bg);
2020
}
2121

22+
/* Top overlay banner for CORS warning */
23+
#corsWarning {
24+
display: none;
25+
position: fixed;
26+
top: 0;
27+
left: 0;
28+
right: 0;
29+
z-index: 1000;
30+
padding: 10px 36px 10px 12px;
31+
border-bottom: 1px solid #e9b34f;
32+
background: #fff8e6;
33+
color: #8a6100;
34+
box-shadow: 0 2px 10px rgba(0,0,0,0.25);
35+
}
36+
#corsWarning .banner-close {
37+
position: absolute;
38+
right: 8px;
39+
top: 8px;
40+
background: transparent;
41+
border: none;
42+
color: #8a6100;
43+
cursor: pointer;
44+
font-size: 18px;
45+
line-height: 1;
46+
padding: 2px 6px;
47+
border-radius: 6px;
48+
}
49+
#corsWarning .banner-close:hover {
50+
background: rgba(0,0,0,0.06);
51+
}
52+
2253
.app-header, .app-footer {
2354
display:flex; align-items:center; justify-content:space-between;
2455
padding: 10px 14px; border-bottom: 1px solid var(--border);

0 commit comments

Comments
 (0)