-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
30 lines (24 loc) · 1.09 KB
/
Copy pathscript.js
File metadata and controls
30 lines (24 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
document.addEventListener('DOMContentLoaded', function() {
// Check if API key already exists in local storage
const savedApiKey = localStorage.getItem('geminiApiKey');
if (savedApiKey) {
document.getElementById('api-key').value = savedApiKey;
}
// Save API key to local storage
document.getElementById('save-api-key').addEventListener('click', function() {
const apiKey = document.getElementById('api-key').value.trim();
if (apiKey === '') {
alert('Please enter a valid Gemini API key');
return;
}
// Validate API key format (basic validation)
if (!apiKey.startsWith('AI') && apiKey.length < 10) {
alert('This doesn\'t look like a valid Gemini API key. Please check and try again.');
return;
}
// Save to local storage
localStorage.setItem('geminiApiKey', apiKey);
// Redirect to main menu immediately without showing an alert
window.location.href = 'main-menu.html';
});
});