-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsettings.html
More file actions
904 lines (785 loc) · 34 KB
/
settings.html
File metadata and controls
904 lines (785 loc) · 34 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
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
<!--
Copyright (C) 2025 Preborned Software
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>iCable Settings</title>
<link rel="icon" type="image/x-icon" href="images/favicon.ico">
<link rel="stylesheet" href="css/style.css">
<style>
body {
overflow-y: auto;
overflow-x: hidden;
}
#settings-container {
max-width: 1200px;
margin: 0 auto;
padding: 2rem;
min-height: 100vh;
box-sizing: border-box;
}
.settings-header {
text-align: center;
margin-bottom: 2rem;
}
.settings-header h1 {
color: var(--accent-color);
margin-bottom: 0.5rem;
}
.settings-tabs {
display: flex;
gap: 0.5rem;
margin-bottom: 2rem;
border-bottom: 2px solid var(--tertiary-bg);
overflow-x: auto;
}
.tab-button {
padding: 1rem 2rem;
background: transparent;
border: none;
color: var(--text-color);
font-size: 1rem;
cursor: pointer;
border-bottom: 3px solid transparent;
transition: all 0.3s ease;
white-space: nowrap;
}
.tab-button:hover {
background: var(--secondary-bg);
}
.tab-button.active {
color: var(--accent-color);
border-bottom-color: var(--accent-color);
}
.tab-content {
display: none;
animation: fadeIn 0.3s ease;
}
.tab-content.active {
display: block;
}
@keyframes fadeIn {
from { opacity: 0; }
to { opacity: 1; }
}
.settings-section {
background: var(--secondary-bg);
padding: 2rem;
border-radius: 0.75rem;
border: 1px solid var(--tertiary-bg);
margin-bottom: 1.5rem;
}
.settings-section h3 {
color: var(--accent-color);
margin-bottom: 1.5rem;
padding-bottom: 0.5rem;
border-bottom: 1px solid var(--tertiary-bg);
}
.form-row {
display: grid;
grid-template-columns: 200px 1fr;
gap: 1rem;
align-items: center;
margin-bottom: 1.5rem;
}
.form-row label {
font-weight: bold;
}
.form-row input[type="text"],
.form-row input[type="url"],
.form-row input[type="number"],
.form-row select {
padding: 0.8rem;
border: 1px solid var(--tertiary-bg);
border-radius: 0.375rem;
background: var(--primary-bg-end);
color: var(--text-color);
font-size: 1rem;
}
.form-row input[type="checkbox"] {
width: 1.5rem;
height: 1.5rem;
}
.color-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 1rem;
}
.color-input-group {
display: flex;
gap: 0.5rem;
align-items: center;
}
.color-input-group label {
min-width: 120px;
}
.color-input-group input[type="color"] {
width: 50px;
height: 40px;
border: none;
border-radius: 0.375rem;
cursor: pointer;
}
.color-input-group input[type="text"] {
flex: 1;
padding: 0.5rem;
border: 1px solid var(--tertiary-bg);
border-radius: 0.375rem;
background: var(--primary-bg-end);
color: var(--text-color);
}
.button-group {
display: flex;
gap: 1rem;
margin-top: 1.5rem;
}
.btn {
padding: 0.8rem 1.5rem;
border: none;
border-radius: 0.5rem;
font-size: 1rem;
cursor: pointer;
transition: all 0.3s ease;
}
.btn-primary {
background: var(--accent-color);
color: white;
}
.btn-primary:hover {
transform: translateY(-2px);
box-shadow: 0 5px 15px rgba(0, 170, 255, 0.3);
}
.btn-secondary {
background: var(--tertiary-bg);
color: var(--text-color);
}
.btn-danger {
background: #e74c3c;
color: white;
}
.btn-danger:hover {
background: #c0392b;
}
.message-list {
max-height: 200px;
overflow-y: auto;
background: var(--primary-bg-end);
padding: 1rem;
border-radius: 0.5rem;
margin-bottom: 1rem;
}
.message-item {
display: flex;
justify-content: space-between;
align-items: center;
padding: 0.5rem;
background: var(--secondary-bg);
border-radius: 0.375rem;
margin-bottom: 0.5rem;
}
.message-item button {
background: transparent;
border: none;
color: #e74c3c;
cursor: pointer;
font-size: 1.2rem;
}
.data-actions {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
gap: 1rem;
}
.data-card {
background: var(--primary-bg-end);
padding: 1.5rem;
border-radius: 0.5rem;
text-align: center;
}
.data-card h4 {
color: var(--accent-color);
margin-bottom: 1rem;
}
.back-link {
display: inline-block;
margin-bottom: 1rem;
color: var(--accent-color);
text-decoration: none;
}
.back-link:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div id="settings-container">
<div class="settings-header">
<h1>Settings</h1>
<p>Customize your iCable experience • Press M for menu</p>
</div>
<div class="settings-tabs">
<button class="tab-button active" onclick="switchTab('general')">General</button>
<button class="tab-button" onclick="switchTab('integrations')">Integrations</button>
<button class="tab-button" onclick="switchTab('channels')">Channels</button>
<button class="tab-button" onclick="switchTab('appearance')">Appearance</button>
<button class="tab-button" onclick="switchTab('data')">Data</button>
<button class="tab-button" onclick="switchTab('about')">About</button>
</div>
<div class="tab-content active" id="tab-general">
<div class="settings-section">
<h3>Guide Settings</h3>
<div class="form-row">
<label>View Hours</label>
<input type="number" id="guide-view-hours" min="1" max="6" value="2">
</div>
<div class="form-row">
<label>Total Guide Hours</label>
<input type="number" id="guide-total-hours" min="6" max="24" value="12">
</div>
<div class="form-row">
<label>12-Hour Format</label>
<input type="checkbox" id="guide-12hour" checked>
</div>
</div>
<div class="settings-section">
<h3>Player Settings</h3>
<div class="form-row">
<label>Default Quality</label>
<select id="player-quality">
<option value="auto">Auto</option>
<option value="1080p">1080p</option>
<option value="720p">720p</option>
<option value="480p">480p</option>
</select>
</div>
<div class="form-row">
<label>Autoplay</label>
<input type="checkbox" id="player-autoplay" checked>
</div>
<div class="form-row">
<label>Default Muted</label>
<input type="checkbox" id="player-muted">
</div>
</div>
<div class="button-group">
<button class="btn btn-primary" onclick="saveGeneral()">Save Changes</button>
</div>
</div>
<div class="tab-content" id="tab-integrations">
<div class="settings-section">
<h3>Guide Data Sources</h3>
<div class="form-row">
<label>XMLTV URL</label>
<input type="url" id="int-xmltv" placeholder="http://example.com/xmltv.xml">
</div>
<div class="form-row">
<label>JSON Guide URL</label>
<input type="url" id="int-json" placeholder="http://example.com/guide.json">
</div>
<div class="form-row">
<label>M3U Playlist URL</label>
<input type="url" id="int-m3u" placeholder="http://example.com/channels.m3u">
</div>
</div>
<div class="settings-section">
<h3>Media Servers</h3>
<div class="form-row">
<label>Jellyfin Server</label>
<input type="url" id="int-jellyfin-url" placeholder="http://localhost:8096">
</div>
<div class="form-row">
<label>Jellyfin API Key</label>
<input type="text" id="int-jellyfin-key" placeholder="Your API Key">
</div>
<div class="form-row">
<label>Enable Jellyfin</label>
<input type="checkbox" id="int-jellyfin-enabled">
</div>
</div>
<div class="settings-section">
<h3>APIs</h3>
<div class="form-row">
<label>TMDb API Key</label>
<input type="text" id="int-tmdb" placeholder="For movie/TV posters">
</div>
<div class="form-row">
<label>OpenWeather API Key</label>
<input type="text" id="int-weather" placeholder="For weather widget">
</div>
<div class="form-row">
<label>Enable Weather</label>
<input type="checkbox" id="int-weather-enabled">
</div>
</div>
<div class="button-group">
<button class="btn btn-primary" onclick="saveIntegrations()">Save Changes</button>
<button class="btn btn-secondary" onclick="testIntegrations()">Test Connections</button>
</div>
</div>
<div class="tab-content" id="tab-channels">
<div class="settings-section">
<h3>Channel Management</h3>
<p>Manage your channels, create custom channels, and organize your lineup.</p>
<div class="button-group">
<button class="btn btn-primary" onclick="window.location.href='channel-creator.html'">+ Create Custom Channel</button>
<button class="btn btn-secondary" onclick="loadChannels()">Refresh List</button>
</div>
</div>
<div class="settings-section">
<h3>Custom Channels</h3>
<div id="custom-channel-list" style="max-height: 300px; overflow-y: auto;">
<p>Loading custom channels...</p>
</div>
</div>
<div class="settings-section">
<h3>All Channels</h3>
<div id="channel-list-container" style="max-height: 400px; overflow-y: auto;">
<p>Loading channels...</p>
</div>
</div>
</div>
<div class="tab-content" id="tab-appearance">
<div class="settings-section">
<h3>Color Theme</h3>
<div class="color-grid">
<div class="color-input-group">
<label>Primary Start</label>
<input type="color" id="color-primary-start" value="#1d2b4b">
<input type="text" id="color-primary-start-text" value="#1d2b4b">
</div>
<div class="color-input-group">
<label>Primary End</label>
<input type="color" id="color-primary-end" value="#0c1428">
<input type="text" id="color-primary-end-text" value="#0c1428">
</div>
<div class="color-input-group">
<label>Secondary BG</label>
<input type="color" id="color-secondary" value="#2a3a5e">
<input type="text" id="color-secondary-text" value="#2a3a5e">
</div>
<div class="color-input-group">
<label>Tertiary BG</label>
<input type="color" id="color-tertiary" value="#4d648d">
<input type="text" id="color-tertiary-text" value="#4d648d">
</div>
<div class="color-input-group">
<label>Accent Color</label>
<input type="color" id="color-accent" value="#00aaff">
<input type="text" id="color-accent-text" value="#00aaff">
</div>
<div class="color-input-group">
<label>Text Color</label>
<input type="color" id="color-text" value="#f0f0f0">
<input type="text" id="color-text-text" value="#f0f0f0">
</div>
</div>
<div class="button-group">
<button class="btn btn-primary" onclick="saveColors()">Apply Colors</button>
<button class="btn btn-secondary" onclick="resetColors()">Reset to Default</button>
</div>
</div>
<div class="settings-section">
<h3>Custom Messages</h3>
<div class="message-list" id="message-list"></div>
<div style="display: flex; gap: 0.5rem;">
<input type="text" id="new-message" placeholder="Enter custom message" style="flex: 1; padding: 0.8rem; border: 1px solid var(--tertiary-bg); border-radius: 0.375rem; background: var(--primary-bg-end); color: var(--text-color);">
<button class="btn btn-primary" onclick="addMessage()">Add</button>
</div>
</div>
<div class="settings-section">
<h3>System Logo</h3>
<input type="file" id="logo-upload" accept="image/*" style="margin-bottom: 1rem;">
<div class="button-group">
<button class="btn btn-primary" onclick="uploadLogo()">Upload Logo</button>
<button class="btn btn-secondary" onclick="removeLogo()">Remove Logo</button>
</div>
</div>
</div>
<div class="tab-content" id="tab-data">
<div class="settings-section">
<h3>Data Management</h3>
<div class="data-actions">
<div class="data-card">
<h4>Export Data</h4>
<p>Download your settings and channels as a backup file.</p>
<button class="btn btn-primary" onclick="exportData()">Export</button>
</div>
<div class="data-card">
<h4>Import Data</h4>
<p>Restore settings from a backup file.</p>
<input type="file" id="import-file" accept=".json" style="display: none;" onchange="importData()">
<button class="btn btn-secondary" onclick="document.getElementById('import-file').click()">Import</button>
</div>
<div class="data-card">
<h4>Reset Everything</h4>
<p>Delete all data and start fresh.</p>
<button class="btn btn-danger" onclick="resetAll()">Reset</button>
</div>
</div>
</div>
<div class="settings-section">
<h3>Storage Info</h3>
<p id="storage-info">Calculating...</p>
</div>
</div>
<div class="tab-content" id="tab-about">
<div class="settings-section">
<h3>About iCable</h3>
<p><strong>Version:</strong> 1.0.0</p>
<p><strong>License:</strong> GNU General Public License v3.0</p>
<p><strong>Copyright:</strong> © 2025 Preborned Software</p>
<p style="margin-top: 1.5rem;">iCable is a free, open-source TV guide and streaming platform. Your privacy is our priority - all data stays on your device.</p>
</div>
<div class="settings-section">
<h3>Support</h3>
<p>Having issues? Need help? Visit our documentation or report bugs on GitHub.</p>
<div class="button-group">
<button class="btn btn-secondary">Documentation</button>
<button class="btn btn-secondary">Report Issue</button>
</div>
</div>
</div>
</div>
<div id="menu-overlay"></div>
<nav id="side-menu">
<div id="widget-slideshow-container">
<div id="hourly-forecast-widget" class="widget-slide">
<div class="widget-title">HOURLY FORECAST</div>
<div class="forecast-items"></div>
</div>
<div id="recommendation-widget" class="widget-slide">
<div class="widget-title">COMING UP NEXT</div>
<div class="rec-content"></div>
</div>
<div id="custom-message-widget" class="widget-slide">
<div class="widget-title">MESSAGE</div>
<div class="widget-content"></div>
</div>
</div>
<h2>Menu</h2>
<ul>
<li><a href="index.html" class="menu-button">Guide</a></li>
<li><a href="ondemand.html" class="menu-button">On-Demand</a></li>
</ul>
</nav>
<script src="scripts/config-manager.js"></script>
<script src="scripts/menu-widgets.js"></script>
<script>
let config = {};
function switchTab(tabName) {
document.querySelectorAll('.tab-button').forEach(btn => btn.classList.remove('active'));
document.querySelectorAll('.tab-content').forEach(content => content.classList.remove('active'));
event.target.classList.add('active');
document.getElementById(`tab-${tabName}`).classList.add('active');
if (tabName === 'appearance') loadAppearance();
if (tabName === 'channels') loadChannels();
if (tabName === 'data') updateStorageInfo();
}
function loadSettings() {
config = window.iCableConfig.get();
document.getElementById('guide-view-hours').value = config.guide?.viewHours || 2;
document.getElementById('guide-total-hours').value = config.guide?.totalHours || 12;
document.getElementById('guide-12hour').checked = config.guide?.use12Hour !== false;
document.getElementById('player-quality').value = config.player?.defaultQuality || 'auto';
document.getElementById('player-autoplay').checked = config.player?.autoplay !== false;
document.getElementById('player-muted').checked = config.player?.muted === true;
document.getElementById('int-xmltv').value = config.integrations?.xmltvUrl || '';
document.getElementById('int-json').value = config.integrations?.jsonUrl || '';
document.getElementById('int-m3u').value = config.integrations?.m3uUrl || '';
document.getElementById('int-jellyfin-url').value = config.integrations?.jellyfin?.url || '';
document.getElementById('int-jellyfin-key').value = config.integrations?.jellyfin?.apiKey || '';
document.getElementById('int-jellyfin-enabled').checked = config.integrations?.jellyfin?.enabled === true;
document.getElementById('int-tmdb').value = config.appearance?.tmdbApiKey || '';
document.getElementById('int-weather').value = config.appearance?.weatherApiKey || '';
document.getElementById('int-weather-enabled').checked = config.appearance?.enableWeather === true;
}
function saveGeneral() {
config.guide = config.guide || {};
config.player = config.player || {};
config.guide.viewHours = parseInt(document.getElementById('guide-view-hours').value);
config.guide.totalHours = parseInt(document.getElementById('guide-total-hours').value);
config.guide.use12Hour = document.getElementById('guide-12hour').checked;
config.player.defaultQuality = document.getElementById('player-quality').value;
config.player.autoplay = document.getElementById('player-autoplay').checked;
config.player.muted = document.getElementById('player-muted').checked;
window.iCableConfig.save(config);
alert('Settings saved successfully!');
}
function saveIntegrations() {
config.integrations = config.integrations || {};
config.integrations.jellyfin = config.integrations.jellyfin || {};
config.integrations.xmltvUrl = document.getElementById('int-xmltv').value;
config.integrations.jsonUrl = document.getElementById('int-json').value;
config.integrations.m3uUrl = document.getElementById('int-m3u').value;
config.integrations.jellyfin.url = document.getElementById('int-jellyfin-url').value;
config.integrations.jellyfin.apiKey = document.getElementById('int-jellyfin-key').value;
config.integrations.jellyfin.enabled = document.getElementById('int-jellyfin-enabled').checked;
config.appearance.tmdbApiKey = document.getElementById('int-tmdb').value;
config.appearance.weatherApiKey = document.getElementById('int-weather').value;
config.appearance.enableWeather = document.getElementById('int-weather-enabled').checked;
window.iCableConfig.save(config);
alert('Integration settings saved!');
}
function testIntegrations() {
alert('Testing connections... (This feature will verify your URLs and API keys)');
}
function loadChannels() {
const customContainer = document.getElementById('custom-channel-list');
const customChannels = config.customChannels || [];
if (customChannels.length === 0) {
customContainer.innerHTML = '<p style="text-align: center; opacity: 0.6; padding: 1rem;">No custom channels yet. Create your first one!</p>';
} else {
let html = '';
customChannels.forEach((ch, index) => {
const logo = ch.logoId ? 'from storage' : (ch.logo || 'images/placeholder.png');
html += `
<div class="channel-item" style="margin-bottom: 0.8rem; padding: 0.8rem; background: var(--primary-bg-end); border-radius: 0.5rem; display: flex; align-items: center; gap: 1rem;">
<img src="${ch.logo || 'https://placehold.co/60x60/4d648d/FFFFFF?text=' + ch.name}" style="width: 3rem; height: 3rem; object-fit: contain;">
<div style="flex: 1;">
<strong>${ch.fullName || ch.name}</strong><br>
<small>Channel ${ch.number} | ${ch.stream?.type || 'Unknown'} stream</small>
</div>
<button onclick="deleteCustomChannel(${index})" style="background: #e74c3c; color: white; border: none; padding: 0.5rem 1rem; border-radius: 0.375rem; cursor: pointer;">Delete</button>
</div>
`;
});
customContainer.innerHTML = html;
}
const container = document.getElementById('channel-list-container');
const allChannels = [...(config.channels || []), ...customChannels];
if (allChannels.length === 0) {
container.innerHTML = '<p style="text-align: center; opacity: 0.6; padding: 1rem;">No channels configured yet. Add integrations or create custom channels.</p>';
return;
}
let html = '';
allChannels.forEach(ch => {
html += `<div class="channel-item" style="margin-bottom: 0.5rem;"><img src="${ch.logo || 'images/placeholder.png'}" style="width: 3rem; height: 3rem; object-fit: contain;"><div><strong>${ch.fullName || ch.name}</strong><br><small>Channel ${ch.number}</small></div></div>`;
});
container.innerHTML = html;
}
function deleteCustomChannel(index) {
if (!confirm('Are you sure you want to delete this custom channel?')) return;
config.customChannels.splice(index, 1);
window.iCableConfig.save(config);
loadChannels();
}
function openChannelEditor() {
window.location.href = 'channel-creator.html';
}
function createCustomChannel() {
window.location.href = 'channel-creator.html';
}
function loadAppearance() {
const colors = config.appearance?.colors || window.iCableConfig.DEFAULT.appearance.colors;
document.getElementById('color-primary-start').value = colors.primaryBgStart;
document.getElementById('color-primary-start-text').value = colors.primaryBgStart;
document.getElementById('color-primary-end').value = colors.primaryBgEnd;
document.getElementById('color-primary-end-text').value = colors.primaryBgEnd;
document.getElementById('color-secondary').value = colors.secondaryBg;
document.getElementById('color-secondary-text').value = colors.secondaryBg;
document.getElementById('color-tertiary').value = colors.tertiaryBg;
document.getElementById('color-tertiary-text').value = colors.tertiaryBg;
document.getElementById('color-accent').value = colors.accent;
document.getElementById('color-accent-text').value = colors.accent;
document.getElementById('color-text').value = colors.text;
document.getElementById('color-text-text').value = colors.text;
syncColorInputs();
loadMessages();
}
function syncColorInputs() {
['primary-start', 'primary-end', 'secondary', 'tertiary', 'accent', 'text'].forEach(id => {
const colorInput = document.getElementById(`color-${id}`);
const textInput = document.getElementById(`color-${id}-text`);
colorInput.addEventListener('input', () => {
textInput.value = colorInput.value;
});
textInput.addEventListener('input', () => {
colorInput.value = textInput.value;
});
});
}
function saveColors() {
config.appearance.colors = {
primaryBgStart: document.getElementById('color-primary-start').value,
primaryBgEnd: document.getElementById('color-primary-end').value,
secondaryBg: document.getElementById('color-secondary').value,
tertiaryBg: document.getElementById('color-tertiary').value,
accent: document.getElementById('color-accent').value,
text: document.getElementById('color-text').value,
liveBg: '#78909c',
pastBg: '#263238'
};
window.iCableConfig.save(config);
window.iCableConfig.applyTheme(config.appearance.colors);
alert('Colors applied! Refresh the guide to see changes.');
}
function resetColors() {
config.appearance.colors = window.iCableConfig.DEFAULT.appearance.colors;
window.iCableConfig.save(config);
window.iCableConfig.applyTheme(config.appearance.colors);
loadAppearance();
alert('Colors reset to default!');
}
function loadMessages() {
const list = document.getElementById('message-list');
const messages = config.appearance?.customMessages || [];
list.innerHTML = messages.map((msg, i) => `
<div class="message-item">
<span>${msg}</span>
<button onclick="removeMessage(${i})">×</button>
</div>
`).join('');
}
function addMessage() {
const input = document.getElementById('new-message');
const msg = input.value.trim();
if (!msg) return;
config.appearance.customMessages = config.appearance.customMessages || [];
config.appearance.customMessages.push(msg);
window.iCableConfig.save(config);
input.value = '';
loadMessages();
}
function removeMessage(index) {
config.appearance.customMessages.splice(index, 1);
window.iCableConfig.save(config);
loadMessages();
}
async function uploadLogo() {
const file = document.getElementById('logo-upload').files[0];
if (!file) return;
try {
const logoId = await window.iCableConfig.saveImage(file);
config.appearance.systemLogoId = logoId;
window.iCableConfig.save(config);
alert('Logo uploaded successfully!');
} catch (error) {
alert('Failed to upload logo: ' + error.message);
}
}
function removeLogo() {
if (config.appearance.systemLogoId) {
window.iCableConfig.deleteImage(config.appearance.systemLogoId);
config.appearance.systemLogoId = null;
window.iCableConfig.save(config);
alert('Logo removed!');
}
}
function exportData() {
window.iCableConfig.export();
}
async function importData() {
const file = document.getElementById('import-file').files[0];
if (!file) return;
try {
const imported = await window.iCableConfig.import(file);
config = imported;
loadSettings();
alert('Data imported successfully! Refresh the page to see changes.');
} catch (error) {
alert('Failed to import data: ' + error.message);
}
}
function resetAll() {
window.iCableConfig.reset();
}
function updateStorageInfo() {
if (navigator.storage && navigator.storage.estimate) {
navigator.storage.estimate().then(estimate => {
const used = (estimate.usage / 1024 / 1024).toFixed(2);
const quota = (estimate.quota / 1024 / 1024).toFixed(2);
document.getElementById('storage-info').textContent = `Using ${used} MB of ${quota} MB available`;
});
} else {
document.getElementById('storage-info').textContent = 'Storage info not available';
}
}
function toggleMenu() {
const settingsContainer = document.getElementById('settings-container');
const menuOverlay = document.getElementById('menu-overlay');
const sideMenu = document.getElementById('side-menu');
if (!sideMenu) {
console.error('Side menu not found');
return;
}
const isOpening = !sideMenu.classList.contains('visible');
if (settingsContainer) settingsContainer.classList.toggle('blurred');
if (menuOverlay) menuOverlay.classList.toggle('visible');
sideMenu.classList.toggle('visible');
if (isOpening) {
setTimeout(() => {
const firstMenuItem = sideMenu.querySelector('.menu-button');
if (firstMenuItem) firstMenuItem.focus();
}, 100);
}
}
window.addEventListener('load', () => {
loadSettings();
setTimeout(() => {
const cfg = window.iCableConfig.get();
if (cfg.appearance?.enableWeather) {
navigator.geolocation.getCurrentPosition(pos => {
window.MenuWidgets.init(cfg, pos.coords);
}, () => {
window.MenuWidgets.init(cfg);
});
} else {
window.MenuWidgets.init(cfg);
}
}, 100);
const menuOverlay = document.getElementById('menu-overlay');
if (menuOverlay) {
menuOverlay.addEventListener('click', toggleMenu);
}
});
document.addEventListener('keydown', (e) => {
const menu = document.getElementById('side-menu');
if (menu && menu.classList.contains('visible')) {
if (e.key.toLowerCase() === 'm' || e.key === 'Escape') {
e.preventDefault();
toggleMenu();
return;
}
if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
e.preventDefault();
const menuButtons = Array.from(menu.querySelectorAll('.menu-button'));
const currentIndex = menuButtons.findIndex(btn => btn === document.activeElement);
if (e.key === 'ArrowUp') {
const prevIndex = currentIndex <= 0 ? menuButtons.length - 1 : currentIndex - 1;
menuButtons[prevIndex].focus();
} else {
const nextIndex = currentIndex >= menuButtons.length - 1 ? 0 : currentIndex + 1;
menuButtons[nextIndex].focus();
}
return;
}
if (e.key === 'Enter') {
e.preventDefault();
if (document.activeElement.classList.contains('menu-button')) {
document.activeElement.click();
}
return;
}
return;
}
if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA' || e.target.tagName === 'SELECT') return;
if (e.key.toLowerCase() === 'm') {
e.preventDefault();
toggleMenu();
}
});
</script>
</body>
</html>