-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinterface.js
More file actions
62 lines (52 loc) · 2.32 KB
/
interface.js
File metadata and controls
62 lines (52 loc) · 2.32 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
55
56
57
58
59
60
61
62
// interface.js
// Version: 1.0
// Instructions for AI: do not remove comments! MUST NOT REMOVE COMMENTS.
'use strict';
window.MaxExtensionInterface = {
// Function to create a toggle checkbox
createToggle: function (id, labelText, initialState, onChangeCallback) {
const toggleContainer = document.createElement('div');
toggleContainer.className = 'toggle-container';
toggleContainer.style.cssText = `
display: flex;
align-items: center;
margin-top: 8px;
padding-left: 8px;
`;
const checkbox = document.createElement('input');
checkbox.type = 'checkbox';
checkbox.id = id;
checkbox.checked = initialState;
checkbox.style.marginRight = '8px';
const label = document.createElement('label');
label.htmlFor = id;
label.textContent = labelText;
toggleContainer.appendChild(checkbox);
toggleContainer.appendChild(label);
checkbox.addEventListener('change', (event) => {
onChangeCallback(event.target.checked);
// Per-tab, best-effort UI persistence for this surface only.
// Profile config remains the authoritative source after full re-initialization.
localStorage.setItem(id, event.target.checked);
logConCgp(`${labelText} ${event.target.checked ? 'enabled' : 'disabled'}`);
});
return toggleContainer;
},
// Function to initialize toggle states from localStorage
loadToggleStates: function () {
const savedAutoSendState = localStorage.getItem('globalAutoSendEnabled');
if (savedAutoSendState !== null) {
globalMaxExtensionConfig.globalAutoSendEnabled = savedAutoSendState === 'true';
}
const savedHotkeysState = localStorage.getItem('enableShortcuts');
if (savedHotkeysState !== null) {
globalMaxExtensionConfig.enableShortcuts = savedHotkeysState === 'true';
}
// Load queue mode state from localStorage
const savedQueueModeState = localStorage.getItem('enableQueueMode');
if (savedQueueModeState !== null) {
// This ensures that the global config reflects the stored toggle state on load
globalMaxExtensionConfig.enableQueueMode = savedQueueModeState === 'true';
}
}
};