-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.html
More file actions
377 lines (331 loc) · 14.3 KB
/
settings.html
File metadata and controls
377 lines (331 loc) · 14.3 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Ustawienia - Deep Work Timer</title>
<link
href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Outfit:wght@300;600;800&display=swap"
rel="stylesheet">
<link rel="stylesheet" href="styles.css">
<style>
/* Settings window specific styles */
body {
margin: 0;
padding: 0;
overflow-y: auto;
background: transparent;
}
.settings-window-container {
padding: 20px;
height: 100vh;
display: flex;
flex-direction: column;
/* Match main window container styles */
background: linear-gradient(145deg, var(--bg-primary) 0%, var(--bg-secondary) 100%);
border-radius: 24px;
border: 1px solid var(--border);
overflow: hidden;
}
/* Custom Scrollbar Styles (apply to the scrollable body) */
.settings-body::-webkit-scrollbar {
width: 8px;
}
.settings-body::-webkit-scrollbar-track {
background: transparent;
margin: 10px;
}
.settings-body::-webkit-scrollbar-thumb {
background: var(--border);
border-radius: 10px;
transition: background 0.2s ease;
}
.settings-body::-webkit-scrollbar-thumb:hover {
background: var(--accent);
}
/* Firefox scrollbar */
.settings-body {
scrollbar-width: thin;
scrollbar-color: var(--border) transparent;
}
.settings-header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 24px;
-webkit-app-region: drag;
}
.settings-title {
font-family: 'Outfit', sans-serif;
font-size: 24px;
font-weight: 800;
color: var(--text-primary);
margin: 0;
}
.settings-close-btn {
background: none;
border: none;
font-size: 20px;
color: var(--text-secondary);
cursor: pointer;
padding: 8px 12px;
border-radius: 8px;
transition: all 0.2s ease;
-webkit-app-region: no-drag;
}
.settings-close-btn:hover {
background: var(--border);
color: var(--text-primary);
}
.settings-body {
display: flex;
flex-direction: column;
gap: 24px;
flex: 1;
overflow-y: auto;
-webkit-overflow-scrolling: touch;
padding-bottom: 20px;
padding-right: 12px;
scrollbar-gutter: stable;
}
</style>
</head>
<body>
<div class="settings-window-container">
<div class="settings-header">
<h3 class="settings-title">Ustawienia</h3>
<button class="settings-close-btn" id="settingsCloseBtn">✕</button>
</div>
<div class="settings-body">
<!-- Theme Section -->
<div class="settings-section">
<div class="settings-section-title">Motyw</div>
<div class="settings-control">
<div class="theme-toggle-group">
<button class="theme-toggle-btn" id="darkThemeBtn" data-theme="dark">
<span class="theme-icon">🌙</span>
<span class="theme-label">Ciemny</span>
</button>
<button class="theme-toggle-btn" id="lightThemeBtn" data-theme="light">
<span class="theme-icon">☀️</span>
<span class="theme-label">Jasny</span>
</button>
</div>
</div>
</div>
<!-- Distractions Section -->
<div class="settings-section">
<div class="settings-section-title">Rozpraszacze</div>
<div class="settings-control">
<label class="settings-checkbox-wrapper">
<input type="checkbox" id="askDistractionCheckbox" class="settings-checkbox">
<span class="settings-checkbox-custom"></span>
<span class="settings-checkbox-label">Pytaj o rozpraszacze przed każdą sesją</span>
</label>
</div>
</div>
<!-- AI Motivation Section -->
<div class="settings-section">
<div class="settings-section-title">AI Motywacja</div>
<!-- Provider Selection -->
<div class="settings-control">
<label class="settings-input-label">Dostawca AI</label>
<div class="provider-toggle-group">
<label class="provider-radio-label">
<input type="radio" name="aiProvider" value="openai" id="providerOpenAI" checked>
<span>🔵 OpenAI</span>
</label>
<label class="provider-radio-label">
<input type="radio" name="aiProvider" value="azure" id="providerAzure">
<span>🟢 Azure OpenAI</span>
</label>
</div>
</div>
<!-- OpenAI Fields -->
<div id="openaiFields" class="provider-fields">
<div class="settings-control">
<label class="settings-input-label">OpenAI API Key</label>
<input type="password" class="settings-input" id="openaiApiKeyInput" placeholder="sk-...">
</div>
</div>
<!-- Azure Fields -->
<div id="azureFields" class="provider-fields" style="display: none;">
<div class="settings-control">
<label class="settings-input-label">Azure Endpoint</label>
<input type="text" class="settings-input" id="azureEndpointInput"
placeholder="https://your-resource.openai.azure.com">
</div>
<div class="settings-control">
<label class="settings-input-label">Azure API Key</label>
<input type="password" class="settings-input" id="azureApiKeyInput" placeholder="Azure API key">
</div>
<div class="settings-control">
<label class="settings-input-label">Deployment Name</label>
<input type="text" class="settings-input" id="azureDeploymentInput" placeholder="gpt-4o-mini">
</div>
</div>
<div class="settings-hint">Wybierz dostawcę i wprowadź dane. Pozostaw puste, aby wyłączyć AI motywację.
</div>
</div>
</div>
</div>
<script>
const { ipcRenderer } = require('electron');
// Close button
document.getElementById('settingsCloseBtn').addEventListener('click', () => {
ipcRenderer.send('close-settings');
});
// Load and apply theme
function loadTheme() {
const savedTheme = localStorage.getItem('theme') || 'dark';
if (savedTheme === 'light') {
document.documentElement.setAttribute('data-theme', 'light');
} else {
document.documentElement.removeAttribute('data-theme');
}
updateThemeButtonStates(savedTheme);
}
function setTheme(theme) {
if (theme === 'light') {
document.documentElement.setAttribute('data-theme', 'light');
} else {
document.documentElement.removeAttribute('data-theme');
}
localStorage.setItem('theme', theme);
updateThemeButtonStates(theme);
// Notify main window about theme change
ipcRenderer.send('theme-changed', theme);
}
function updateThemeButtonStates(theme) {
const darkBtn = document.getElementById('darkThemeBtn');
const lightBtn = document.getElementById('lightThemeBtn');
if (theme === 'light') {
lightBtn.classList.add('active');
darkBtn.classList.remove('active');
} else {
darkBtn.classList.add('active');
lightBtn.classList.remove('active');
}
}
// Theme buttons
document.getElementById('darkThemeBtn').addEventListener('click', () => setTheme('dark'));
document.getElementById('lightThemeBtn').addEventListener('click', () => setTheme('light'));
// Distraction checkbox
const askDistractionCheckbox = document.getElementById('askDistractionCheckbox');
function loadDistractionCheckPreference() {
const saved = localStorage.getItem('hideDistractionCheck');
const distractionCheckHidden = saved === 'true';
askDistractionCheckbox.checked = !distractionCheckHidden;
}
function saveDistractionCheckPreference() {
const shouldAsk = askDistractionCheckbox.checked;
localStorage.setItem('hideDistractionCheck', shouldAsk ? 'false' : 'true');
}
askDistractionCheckbox.addEventListener('change', saveDistractionCheckPreference);
// AI Settings
const providerOpenAI = document.getElementById('providerOpenAI');
const providerAzure = document.getElementById('providerAzure');
const openaiFields = document.getElementById('openaiFields');
const azureFields = document.getElementById('azureFields');
const openaiApiKeyInput = document.getElementById('openaiApiKeyInput');
const azureEndpointInput = document.getElementById('azureEndpointInput');
const azureApiKeyInput = document.getElementById('azureApiKeyInput');
const azureDeploymentInput = document.getElementById('azureDeploymentInput');
function toggleProviderFields() {
const selectedProvider = document.querySelector('input[name="aiProvider"]:checked')?.value || 'openai';
if (selectedProvider === 'azure') {
openaiFields.style.display = 'none';
azureFields.style.display = 'block';
} else {
openaiFields.style.display = 'block';
azureFields.style.display = 'none';
}
}
function loadAiSettings() {
const provider = localStorage.getItem('ai_provider') || 'openai';
if (provider === 'azure' && providerAzure) {
providerAzure.checked = true;
} else if (providerOpenAI) {
providerOpenAI.checked = true;
}
const openaiApiKey = localStorage.getItem('openai_api_key');
if (openaiApiKey && openaiApiKeyInput) {
openaiApiKeyInput.value = openaiApiKey;
}
const azureEndpoint = localStorage.getItem('azure_endpoint');
const azureApiKey = localStorage.getItem('azure_api_key');
const azureDeployment = localStorage.getItem('azure_deployment');
if (azureEndpoint && azureEndpointInput) {
azureEndpointInput.value = azureEndpoint;
}
if (azureApiKey && azureApiKeyInput) {
azureApiKeyInput.value = azureApiKey;
}
if (azureDeployment && azureDeploymentInput) {
azureDeploymentInput.value = azureDeployment;
}
toggleProviderFields();
}
function saveAiProvider() {
const selectedProvider = document.querySelector('input[name="aiProvider"]:checked')?.value || 'openai';
localStorage.setItem('ai_provider', selectedProvider);
toggleProviderFields();
}
function saveOpenAiApiKey() {
const apiKey = openaiApiKeyInput.value.trim();
if (apiKey) {
localStorage.setItem('openai_api_key', apiKey);
} else {
localStorage.removeItem('openai_api_key');
}
}
function saveAzureEndpoint() {
const endpoint = azureEndpointInput.value.trim();
if (endpoint) {
localStorage.setItem('azure_endpoint', endpoint);
} else {
localStorage.removeItem('azure_endpoint');
}
}
function saveAzureApiKey() {
const apiKey = azureApiKeyInput.value.trim();
if (apiKey) {
localStorage.setItem('azure_api_key', apiKey);
} else {
localStorage.removeItem('azure_api_key');
}
}
function saveAzureDeployment() {
const deployment = azureDeploymentInput.value.trim();
if (deployment) {
localStorage.setItem('azure_deployment', deployment);
} else {
localStorage.removeItem('azure_deployment');
}
}
// Event listeners
if (providerOpenAI) providerOpenAI.addEventListener('change', saveAiProvider);
if (providerAzure) providerAzure.addEventListener('change', saveAiProvider);
if (openaiApiKeyInput) {
openaiApiKeyInput.addEventListener('blur', saveOpenAiApiKey);
openaiApiKeyInput.addEventListener('change', saveOpenAiApiKey);
}
if (azureEndpointInput) {
azureEndpointInput.addEventListener('blur', saveAzureEndpoint);
azureEndpointInput.addEventListener('change', saveAzureEndpoint);
}
if (azureApiKeyInput) {
azureApiKeyInput.addEventListener('blur', saveAzureApiKey);
azureApiKeyInput.addEventListener('change', saveAzureApiKey);
}
if (azureDeploymentInput) {
azureDeploymentInput.addEventListener('blur', saveAzureDeployment);
azureDeploymentInput.addEventListener('change', saveAzureDeployment);
}
// Initialize
loadTheme();
loadDistractionCheckPreference();
loadAiSettings();
</script>
</body>
</html>