-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpopup.js
More file actions
54 lines (47 loc) · 1.59 KB
/
Copy pathpopup.js
File metadata and controls
54 lines (47 loc) · 1.59 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* Text Charismatizer Settings Popup
* Handles configuration of GitHub PAT token and model selection
*/
document.addEventListener('DOMContentLoaded', () => {
// Load saved settings from chrome.storage
chrome.storage.sync.get(['githubPat', 'model'], (result) => {
document.getElementById('github-pat').value = result.githubPat || '';
document.getElementById('model').value = result.model || 'gpt-4o-mini';
});
/**
* Display status message to user
* @param {string} message - The message to display
* @param {boolean} [isError=false] - Whether this is an error message
*/
function showStatus(message, isError = false) {
const statusEl = document.getElementById('status-message');
statusEl.textContent = message;
statusEl.className = isError ? 'error' : 'success';
statusEl.style.display = 'block';
// Auto-hide message after 3 seconds
setTimeout(() => {
statusEl.style.display = 'none';
}, 3000);
}
// Handle settings form submission
document.getElementById('save').addEventListener('click', () => {
const githubPat = document.getElementById('github-pat').value;
const model = document.getElementById('model').value;
// Validate required fields
if (!githubPat) {
showStatus('Please enter your GitHub PAT token', true);
return;
}
if (!model) {
showStatus('Please enter the model name', true);
return;
}
// Save settings to chrome.storage
chrome.storage.sync.set({
githubPat,
model
}, () => {
showStatus('Settings saved successfully!');
});
});
});