Skip to content

Commit 2869ccb

Browse files
simonwclaude
andauthored
gemini-prompt: add Change API key button and fix mobile submit layout (#231)
- Show a "Change API key" button when a key is already stored in localStorage, so users can update it without clearing storage - Add responsive CSS: on screens ≤600px the controls row wraps and the Submit button stretches full-width https://claude.ai/code/session_01XXTsotCW64yZXECFgWokoj Co-authored-by: Claude <noreply@anthropic.com>
1 parent 546979a commit 2869ccb

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

gemini-prompt.html

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,18 +234,51 @@
234234
font-size: 0.9rem;
235235
}
236236

237+
/* API key row */
238+
#api-key-row {
239+
display: none;
240+
margin-bottom: 16px;
241+
}
242+
243+
#change-api-key-btn {
244+
background: none;
245+
border: 1px solid #d1d5db;
246+
color: #6b7280;
247+
font-size: 0.8rem;
248+
padding: 4px 10px;
249+
border-radius: 5px;
250+
}
251+
#change-api-key-btn:hover {
252+
border-color: #4f7df3;
253+
color: #4f7df3;
254+
background: #eff6ff;
255+
}
256+
237257
/* Status */
238258
#status {
239259
font-size: 0.8rem;
240260
color: #6b7280;
241261
margin-top: 8px;
242262
height: 1.2em;
243263
}
264+
265+
@media (max-width: 600px) {
266+
.controls-row {
267+
flex-wrap: wrap;
268+
}
269+
#submit-btn {
270+
width: 100%;
271+
}
272+
}
244273
</style>
245274
</head>
246275
<body>
247276
<h1>Gemini Prompt</h1>
248277

278+
<div id="api-key-row">
279+
<button id="change-api-key-btn">Change API key</button>
280+
</div>
281+
249282
<label for="system-prompt">System Prompt</label>
250283
<textarea id="system-prompt" placeholder="Optional system prompt…"></textarea>
251284

@@ -303,15 +336,31 @@ <h1>Gemini Prompt</h1>
303336
let showAll = false;
304337

305338
// ── API key ────────────────────────────────────────────────────────────────
339+
function updateApiKeyUI() {
340+
const hasKey = !!localStorage.getItem(STORAGE_KEY_API);
341+
document.getElementById('api-key-row').style.display = hasKey ? 'block' : 'none';
342+
}
343+
306344
function getApiKey() {
307345
let key = localStorage.getItem(STORAGE_KEY_API);
308346
if (!key) {
309347
key = prompt('Enter your Gemini API key:');
310-
if (key) localStorage.setItem(STORAGE_KEY_API, key.trim());
348+
if (key) {
349+
localStorage.setItem(STORAGE_KEY_API, key.trim());
350+
updateApiKeyUI();
351+
}
311352
}
312353
return key;
313354
}
314355

356+
document.getElementById('change-api-key-btn').addEventListener('click', () => {
357+
const key = prompt('Enter your new Gemini API key:');
358+
if (key && key.trim()) {
359+
localStorage.setItem(STORAGE_KEY_API, key.trim());
360+
updateApiKeyUI();
361+
}
362+
});
363+
315364
// ── System prompt history ─────────────────────────────────────────────────
316365
function loadHistory() {
317366
try { return JSON.parse(localStorage.getItem(STORAGE_KEY_HIST) || '[]'); }
@@ -476,6 +525,7 @@ <h1>Gemini Prompt</h1>
476525
document.getElementById('system-prompt').value = hist[0];
477526
}
478527
renderHistory();
528+
updateApiKeyUI();
479529
})();
480530
</script>
481531
</body>

0 commit comments

Comments
 (0)