-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.html
More file actions
667 lines (585 loc) · 30.6 KB
/
template.html
File metadata and controls
667 lines (585 loc) · 30.6 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
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>__PLAN_TITLE__</title>
<style>
:root {
--cell-height: 55px;
--badge-w: #d32f2f;
--badge-l: #2e7d32;
--badge-p: #ef6c00;
--badge-c: #1565c0;
--badge-grp: #546e7a;
}
body {
font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
background-color: #f8f9fa;
margin: 0;
padding: 20px;
color: #333;
}
h1 {
text-align: center;
font-weight: 300;
margin-bottom: 20px;
color: #222;
}
/* --- PANEL FILTRÓW --- */
.filters-container {
background: white;
border: 1px solid #e0e0e0;
border-radius: 8px;
padding: 15px;
margin-bottom: 20px;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
display: flex;
gap: 30px;
flex-wrap: wrap;
justify-content: center;
}
.filter-group {
display: flex;
flex-direction: column;
gap: 8px;
min-width: 200px;
}
.filter-header {
font-weight: 700;
font-size: 0.9rem;
color: #555;
text-transform: uppercase;
border-bottom: 2px solid #eee;
padding-bottom: 5px;
margin-bottom: 5px;
display: flex;
justify-content: space-between;
align-items: center;
}
.filter-actions button {
background: none;
border: none;
color: #1565c0;
font-size: 0.7rem;
cursor: pointer;
text-decoration: underline;
padding: 0;
margin-left: 10px;
}
.checkbox-list {
max-height: 150px;
overflow-y: auto;
display: grid;
grid-template-columns: 1fr;
gap: 4px;
}
/* Styl Scrollbara */
.checkbox-list::-webkit-scrollbar {
width: 6px;
}
.checkbox-list::-webkit-scrollbar-thumb {
background: #ccc;
border-radius: 3px;
}
.checkbox-label {
font-size: 0.85rem;
display: flex;
align-items: center;
cursor: pointer;
user-select: none;
}
.checkbox-label input {
margin-right: 8px;
}
.checkbox-label:hover {
color: #000;
}
/* --- GŁÓWNY LAYOUT --- */
.schedule-wrapper {
min-width: 1300px;
background: white;
border-radius: 8px;
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
display: grid;
grid-template-columns: 50px repeat(5, 1fr);
grid-template-rows: 50px 1fr;
position: relative;
height: 950px;
overflow: hidden;
border: 1px solid #e0e0e0;
}
.header-cell {
background: #34495e;
color: white;
display: flex;
align-items: center;
justify-content: center;
font-weight: 600;
font-size: 0.9rem;
border-right: 1px solid rgba(255, 255, 255, 0.1);
z-index: 20;
}
.time-col {
background: #fafafa;
border-right: 1px solid #e0e0e0;
position: relative;
}
.day-col {
position: relative;
background: #fff;
border-right: 1px solid #f0f0f0;
}
.hour-mark {
position: absolute;
width: 100%;
height: var(--cell-height);
border-bottom: 1px dashed #f0f0f0;
box-sizing: border-box;
pointer-events: none;
}
.time-col .hour-mark {
border-bottom: 1px solid #e0e0e0;
display: flex;
justify-content: center;
align-items: flex-start;
font-size: 0.75rem;
color: #888;
padding-top: 4px;
}
/* --- KAFELEK --- */
.event {
position: absolute;
border-radius: 6px;
box-sizing: border-box;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
cursor: pointer;
transition: all 0.2s ease;
overflow: hidden;
z-index: 10;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
padding: 18px 4px 14px 4px;
border: 1px solid rgba(0, 0, 0, 0.08);
}
.event:hover {
transform: scale(1.02);
z-index: 100 !important;
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}
.event.event-dimmed {
opacity: 0.32;
}
.event.event-dimmed:hover {
opacity: 0.5;
}
.event.event-my-plan {
box-shadow: 0 0 0 3px #1565c0;
}
.subject-name {
font-weight: 700;
font-size: 0.75rem;
color: #2c3e50;
text-align: center;
line-height: 1.2;
width: 100%;
word-wrap: break-word;
}
.event-time {
position: absolute;
bottom: 2px;
right: 5px;
font-size: 0.65rem;
color: #444;
font-weight: 600;
background: rgba(255, 255, 255, 0.6);
padding: 0 2px;
border-radius: 3px;
}
.group-badge {
position: absolute;
top: 0;
left: 0;
padding: 1px 6px;
height: 18px;
background-color: var(--badge-grp);
color: white;
font-weight: 600;
font-size: 0.65rem;
display: flex;
align-items: center;
justify-content: center;
border-bottom-right-radius: 6px;
z-index: 2;
}
.type-badge {
position: absolute;
top: 0;
right: 0;
width: 20px;
height: 20px;
color: white;
font-weight: 700;
font-size: 0.7rem;
display: flex;
align-items: center;
justify-content: center;
border-bottom-left-radius: 6px;
z-index: 2;
}
</style>
</head>
<body>
<h1>Plan Zajęć Semestralnych</h1>
<div class="filters-container">
<div class="filter-group">
<div class="filter-header">
Przedmioty
<div class="filter-actions">
<button onclick="toggleAll('subject', true)">Wszystkie</button>
<button onclick="toggleAll('subject', false)">Żadne</button>
</div>
</div>
<div class="checkbox-list" id="subjectFilters">
</div>
</div>
<div class="filter-group" style="min-width: 150px;">
<div class="filter-header">
Typ Zajęć
<div class="filter-actions">
<button onclick="toggleAll('type', true)">Wszystkie</button>
<button onclick="toggleAll('type', false)">Żadne</button>
</div>
</div>
<div class="checkbox-list" id="typeFilters">
</div>
</div>
</div>
<p class="schedule-hint" style="font-size: 0.85rem; color: #666; margin: 0 0 12px 0;">Kliknij kafelek, aby wybrać grupę z przedmiotu (reszta planu się przyciemni). Kliknij ponownie, aby odznaczyć.</p>
<div id="unselectedSummary" class="unselected-summary" style="display: none; font-size: 0.9rem; margin-bottom: 12px; padding: 10px 14px; background: #fff8e1; border: 1px solid #ffca28; border-radius: 6px; color: #5d4e37;"></div>
<div id="allSelectedSummary" class="all-selected-summary" style="display: none; font-size: 0.9rem; margin-bottom: 12px; padding: 10px 14px; background: #e8f5e9; border: 1px solid #81c784; border-radius: 6px; color: #2e7d32;"></div>
<div class="schedule-wrapper">
<div class="header-cell">Godz</div>
<div class="header-cell">Poniedziałek</div>
<div class="header-cell">Wtorek</div>
<div class="header-cell">Środa</div>
<div class="header-cell">Czwartek</div>
<div class="header-cell">Piątek</div>
<div class="time-col" id="timeColumn"></div>
<div class="day-col" id="col-Poniedziałek"></div>
<div class="day-col" id="col-Wtorek"></div>
<div class="day-col" id="col-Środa"></div>
<div class="day-col" id="col-Czwartek"></div>
<div class="day-col" id="col-Piątek"></div>
</div>
<script>
// --- 1. DANE Z PLIKU FIXED.CSV ---
const rawData = [
{ day: "Poniedziałek", start: "08:00", end: "09:30", subject: "Bazy danych", type: "CWL", group: "4", room: "110, bud. B9" },
{ day: "Poniedziałek", start: "08:00", end: "10:15", subject: "Sieci 4G i 5G", type: "CWL", group: "3", room: "302, bud. D6" },
{ day: "Poniedziałek", start: "09:45", end: "11:15", subject: "Bazy danych", type: "CWL", group: "5", room: "110, bud. B9" },
{ day: "Poniedziałek", start: "09:45", end: "11:15", subject: "Koło naukowe", type: "CWP", group: "1", room: "010, bud. B9" },
{ day: "Poniedziałek", start: "11:30", end: "13:00", subject: "Inżynieria ruchu w sieci Internet", type: "W", group: "1", room: "201, bud. D6" },
{ day: "Poniedziałek", start: "13:15", end: "14:45", subject: "Inżynieria ruchu w sieci Internet", type: "CWP", group: "1", room: "011, bud. B9" },
{ day: "Poniedziałek", start: "15:00", end: "16:30", subject: "Środowisko regulacyjne sieci komórkowych", type: "W", group: "1", room: "on-line, bud. A0" },
{ day: "Poniedziałek", start: "16:45", end: "18:15", subject: "Bazy danych", type: "W", group: "1", room: "201, bud. D6" },
{ day: "Poniedziałek", start: "18:30", end: "20:00", subject: "Systemy sygnalizacji i zarządzania", type: "CWL", group: "1", room: "111, bud. B9" },
{ day: "Wtorek", start: "08:00", end: "09:30", subject: "Komunikacja interpersonalna i antropologia komunikacji", type: "W", group: "1", room: "1.14, bud. C7" },
{ day: "Wtorek", start: "09:45", end: "11:15", subject: "Koło naukowe", type: "KONW", group: "1", room: "010, bud. B9" },
{ day: "Wtorek", start: "11:30", end: "13:00", subject: "Sieci 4G i 5G", type: "CWL", group: "4", room: "302, bud. D6" },
{ day: "Wtorek", start: "15:00", end: "16:30", subject: "Środowisko regulacyjne sieci komórkowych", type: "CWP", group: "1", room: "on-line, bud. A0" },
{ day: "Wtorek", start: "17:15", end: "18:45", subject: "Bezpieczeństwo sieci IP w praktyce", type: "W", group: "1", room: "on-line, bud. A0" },
{ day: "Wtorek", start: "19:00", end: "20:30", subject: "Systemy sygnalizacji i zarządzania", type: "W", group: "1", room: "on-line, bud. A0" },
{ day: "Środa", start: "07:45", end: "09:15", subject: "Programowanie sieciowe", type: "W", group: "1", room: "on-line, bud. A0" },
{ day: "Środa", start: "09:45", end: "11:15", subject: "Bazy danych", type: "CWL", group: "2", room: "219, bud. C2" },
{ day: "Środa", start: "09:45", end: "11:15", subject: "Bazy danych", type: "CWP", group: "2", room: "219, bud. C2" },
{ day: "Środa", start: "09:45", end: "12:00", subject: "Inżynieria ruchu w sieci Internet", type: "CWL", group: "1", room: "111, bud. B9" },
{ day: "Środa", start: "12:30", end: "14:45", subject: "Inżynieria ruchu w sieci Internet", type: "CWL", group: "2", room: "111, bud. B9" },
{ day: "Środa", start: "13:15", end: "14:45", subject: "Bazy danych", type: "CWL", group: "1", room: "104, bud. B9" },
{ day: "Środa", start: "13:15", end: "14:45", subject: "Bazy danych", type: "CWP", group: "1", room: "104, bud. B9" },
{ day: "Środa", start: "15:00", end: "16:30", subject: "Bazy danych", type: "CWL", group: "3", room: "104, bud. B9" },
{ day: "Środa", start: "15:00", end: "16:30", subject: "Bazy danych", type: "CWP", group: "3", room: "104, bud. B9" },
{ day: "Środa", start: "16:45", end: "19:00", subject: "Bezpieczeństwo sieci IP w praktyce", type: "CWL", group: "3", room: "103, bud. B9" },
{ day: "Środa", start: "19:15", end: "20:00", subject: "Inżynieria ruchu w sieci Internet", type: "CWP", group: "2", room: "011, bud. B9" },
{ day: "Czwartek", start: "08:00", end: "10:15", subject: "Sieci 4G i 5G", type: "CWL", group: "2", room: "302, bud. D6" },
{ day: "Czwartek", start: "09:45", end: "12:00", subject: "Inżynieria ruchu w sieci Internet", type: "CWL", group: "3", room: "111, bud. B9" },
{ day: "Czwartek", start: "10:15", end: "12:30", subject: "Sieci 4G i 5G", type: "CWL", group: "1", room: "302, bud. D6" },
{ day: "Czwartek", start: "10:45", end: "13:00", subject: "Bezpieczeństwo sieci IP w praktyce", type: "CWL", group: "2", room: "103, bud. B9" },
{ day: "Czwartek", start: "13:15", end: "14:45", subject: "Uczenie maszynowe w teleinformatyce", type: "CWP", group: "1", room: "010, bud. B9" },
{ day: "Czwartek", start: "14:15", end: "16:30", subject: "Bezpieczeństwo sieci IP w praktyce", type: "CWL", group: "4", room: "103, bud. B9" },
{ day: "Czwartek", start: "15:00", end: "16:30", subject: "Uczenie maszynowe w teleinformatyce", type: "KONW", group: "1", room: "010, bud. B9" },
{ day: "Czwartek", start: "16:45", end: "19:00", subject: "Bezpieczeństwo sieci IP w praktyce", type: "CWL", group: "1", room: "103, bud. B9" },
{ day: "Czwartek", start: "18:15", end: "20:30", subject: "Inżynieria ruchu w sieci Internet", type: "CWL", group: "4", room: "111, bud. B9" },
{ day: "Piątek", start: "08:00", end: "09:30", subject: "Sieci 4G i 5G", type: "W", group: "1", room: "201, bud. D6" },
{ day: "Piątek", start: "09:45", end: "11:15", subject: "Kodowanie i kryptografia", type: "W", group: "1", room: "201, bud. D6" },
{ day: "Piątek", start: "11:30", end: "13:00", subject: "Kodowanie i kryptografia", type: "CWP", group: "3", room: "012, bud. B9" },
{ day: "Piątek", start: "11:30", end: "13:00", subject: "Przetwarzanie i przesyłanie informacji multimedialnych", type: "CWA", group: "2", room: "302, bud. D6" },
{ day: "Piątek", start: "11:30", end: "13:00", subject: "Kodowanie i kryptografia", type: "CWA", group: "1", room: "010, bud. B9" },
{ day: "Piątek", start: "13:15", end: "14:45", subject: "Przetwarzanie i przesyłanie informacji multimedialnych", type: "CWA", group: "3", room: "302, bud. D6" },
{ day: "Piątek", start: "13:15", end: "14:45", subject: "Kodowanie i kryptografia", type: "CWA", group: "2", room: "010, bud. B9" },
{ day: "Piątek", start: "13:15", end: "14:45", subject: "Kodowanie i kryptografia", type: "CWP", group: "1", room: "012, bud. B9" },
{ day: "Piątek", start: "15:00", end: "16:30", subject: "Przetwarzanie i przesyłanie informacji multimedialnych", type: "CWA", group: "1", room: "302, bud. D6" },
{ day: "Piątek", start: "15:00", end: "16:30", subject: "Kodowanie i kryptografia", type: "CWP", group: "2", room: "012, bud. B9" },
{ day: "Piątek", start: "15:00", end: "16:30", subject: "Kodowanie i kryptografia", type: "CWA", group: "3", room: "010, bud. B9" },
{ day: "Piątek", start: "16:45", end: "18:15", subject: "Programowanie sieciowe", type: "CWP", group: "1", room: "104, bud. B9" },
{ day: "Piątek", start: "16:45", end: "18:15", subject: "Programowanie sieciowe", type: "CWL", group: "1", room: "104, bud. B9" },
{ day: "Piątek", start: "18:15", end: "20:30", subject: "Programowanie sieciowe", type: "CWP", group: "1", room: "104, bud. B9" },
{ day: "Piątek", start: "18:30", end: "20:00", subject: "Programowanie sieciowe", type: "CWL", group: "2", room: "104, bud. B9" }
];
// --- 2. METADANE I KOLORY (DOBRANE RĘCZNIE) ---
const metaData = {
"Bazy danych": { ects: 4, status: "Obowiązkowy", verify: "Egzamin", short: "Bazy danych", color: "#e3f2fd" },
"Inżynieria ruchu w sieci Internet": { ects: 4, status: "Do wyboru", verify: "Zaliczenie", short: "Inż. Ruchu", color: "#ffe0b2" },
"Systemy sygnalizacji i zarządzania": { ects: 3, status: "Do wyboru", verify: "Zaliczenie", short: "Sys. Sygn.", color: "#ffcdd2" },
"Sieci 4G i 5G": { ects: 4, status: "Do wyboru", verify: "Zaliczenie", short: "Sieci 4G/5G", color: "#c8e6c9" },
"Komunikacja interpersonalna i antropologia komunikacji": { ects: 2, status: "Do wyboru", verify: "Zaliczenie", short: "Kom. Interpers.", color: "#fff9c4" },
"Koło naukowe": { ects: 4, status: "Do wyboru", verify: "Zaliczenie", short: "Koło Nauk.", color: "#e1bee7" },
"Bezpieczeństwo sieci IP w praktyce": { ects: 4, status: "Do wyboru", verify: "Zaliczenie", short: "Bezp. IP", color: "#f8bbd0" },
"Programowanie sieciowe": { ects: 4, status: "Do wyboru", verify: "Zaliczenie", short: "Prog. Siec.", color: "#b2dfdb" },
"Uczenie maszynowe w teleinformatyce": { ects: 3, status: "Do wyboru", verify: "Zaliczenie", short: "Ucz. Masz.", color: "#cfd8dc" },
"Kodowanie i kryptografia": { ects: 4, status: "Obowiązkowy", verify: "Egzamin", short: "Krypto", color: "#f0f4c3" },
"Przetwarzanie i przesyłanie informacji multimedialnych": { ects: 1, status: "Obowiązkowy", verify: "Zaliczenie", short: "Multi", color: "#b3e5fc" },
"Środowisko regulacyjne sieci komórkowych": { ects: 4, status: "Do wyboru", verify: "Zaliczenie", short: "Środ. Reg.", color: "#d1c4e9" }
};
const typeMap = {
"CWL": { badge: "L", color: "var(--badge-l)", name: "Laboratorium" },
"W": { badge: "W", color: "var(--badge-w)", name: "Wykład" },
"CWP": { badge: "P", color: "var(--badge-p)", name: "Projekt" },
"CWA": { badge: "C", color: "var(--badge-c)", name: "Ćwiczenia" },
"KONW": { badge: "K", color: "var(--badge-c)", name: "Konwersatorium" }
};
function timeToMinutes(t) {
const [h, m] = t.split(':').map(Number);
return h * 60 + m;
}
// --- 3. GENEROWANIE SIATKI ---
const startHour = 7;
const cellHeight = 55; // px
const timeCol = document.getElementById('timeColumn');
for (let i = 7; i <= 21; i++) {
const div = document.createElement('div');
div.className = 'hour-mark';
div.style.top = (i - startHour) * cellHeight + 'px';
if (timeCol) div.innerText = i + ":00";
timeCol.appendChild(div);
document.querySelectorAll('.day-col').forEach(col => {
const line = div.cloneNode(true);
line.innerText = '';
col.appendChild(line);
});
}
// --- 4. LOGIKA FILTROWANIA I RENDEROWANIA ---
// Moja grupa: klik w kafelek = wybór tej grupy dla (przedmiot, typ). Np. lab gr.1, projekt gr.2 osobno.
const myPlan = {}; // "subject|type" -> group
const STORAGE_KEY = 'usos_timetable_' + (location.pathname || '/').replace(/^\/$/, 'index').replace(/^\//, '').replace(/\//g, '_') || 'index';
function loadOptions() {
try {
const s = localStorage.getItem(STORAGE_KEY);
return s ? JSON.parse(s) : null;
} catch (e) { return null; }
}
function saveOptions() {
const activeSubjects = Array.from(document.querySelectorAll('#subjectFilters input:checked')).map(cb => cb.value);
const activeTypes = Array.from(document.querySelectorAll('#typeFilters input:checked')).map(cb => cb.value);
try {
localStorage.setItem(STORAGE_KEY, JSON.stringify({ activeSubjects, activeTypes, myPlan: { ...myPlan } }));
} catch (e) { /* quota or private mode */ }
}
function planKey(ev) {
return ev.subject + "|" + ev.type;
}
function toggleMyPlan(ev) {
const key = planKey(ev);
if (myPlan[key] === ev.group) {
delete myPlan[key];
} else {
myPlan[key] = ev.group;
}
renderSchedule();
}
// Przy starcie: automatycznie zaznacz wszystkie Wykłady (W)
function selectAllWykład() {
rawData.forEach(d => {
if (d.type === 'W') {
myPlan[d.subject + '|W'] = d.group;
}
});
}
// Które przedmioty/typy nie mają jeszcze wybranej grupy (z uwzgl. aktywnych filtrów)
function updateUnselectedSummary(activeSubjects, activeTypes) {
const subjectTypes = {}; // subject -> Set of types (from filtered data)
rawData.forEach(d => {
if (!activeSubjects.includes(d.subject) || !activeTypes.includes(d.type)) return;
if (!subjectTypes[d.subject]) subjectTypes[d.subject] = new Set();
subjectTypes[d.subject].add(d.type);
});
const missing = []; // { subject, types: [] }
Object.keys(subjectTypes).sort().forEach(subj => {
const types = subjectTypes[subj];
const notChosen = [...types].filter(t => !myPlan[subj + "|" + t]);
if (notChosen.length > 0) {
const typeNames = notChosen.map(t => typeMap[t] ? typeMap[t].name : t).join(", ");
missing.push({ subject: subj, types: typeNames });
}
});
const unselEl = document.getElementById('unselectedSummary');
const allEl = document.getElementById('allSelectedSummary');
if (missing.length > 0) {
unselEl.style.display = 'block';
allEl.style.display = 'none';
unselEl.innerHTML = '<strong>Nie wybrano jeszcze grupy dla:</strong> ' +
missing.map(m => m.subject + ' <span style="color:#795548">(' + m.types + ')</span>').join(', ');
} else {
unselEl.style.display = 'none';
allEl.style.display = 'block';
allEl.textContent = '✓ Wszystkie przedmioty mają wybraną grupę.';
}
}
// Pobierz unikalne wartości do filtrów
const uniqueSubjects = [...new Set(rawData.map(d => d.subject))].sort();
const uniqueTypes = [...new Set(rawData.map(d => d.type))].sort();
// Inicjalizacja filtrów (przywraca zaznaczenia z localStorage)
function initFilters() {
const saved = loadOptions();
const savedSubjects = saved && saved.activeSubjects ? new Set(saved.activeSubjects) : null;
const savedTypes = saved && saved.activeTypes ? new Set(saved.activeTypes) : null;
const subContainer = document.getElementById('subjectFilters');
uniqueSubjects.forEach(sub => {
const checked = savedSubjects == null ? true : savedSubjects.has(sub);
const label = document.createElement('label');
label.className = 'checkbox-label';
label.innerHTML = `<input type="checkbox" ${checked ? 'checked' : ''} value="${String(sub).replace(/&/g, '&').replace(/"/g, '"')}" onchange="renderSchedule()"> ${String(sub).replace(/&/g, '&').replace(/</g, '<')}`;
subContainer.appendChild(label);
});
const typeContainer = document.getElementById('typeFilters');
uniqueTypes.forEach(typ => {
const checked = savedTypes == null ? true : savedTypes.has(typ);
const typeName = typeMap[typ] ? typeMap[typ].name : typ;
const label = document.createElement('label');
label.className = 'checkbox-label';
label.innerHTML = `<input type="checkbox" ${checked ? 'checked' : ''} value="${String(typ).replace(/&/g, '&').replace(/"/g, '"')}" onchange="renderSchedule()"> ${String(typeName).replace(/&/g, '&').replace(/</g, '<')} (${String(typ).replace(/&/g, '&')})`;
typeContainer.appendChild(label);
});
if (saved && saved.myPlan && typeof saved.myPlan === 'object') {
Object.keys(saved.myPlan).forEach(k => {
if (rawData.some(d => planKey(d) === k)) myPlan[k] = saved.myPlan[k];
});
}
}
// Helpery do przycisków "Wszystkie/Żadne"
function toggleAll(type, checked) {
const container = type === 'subject' ? document.getElementById('subjectFilters') : document.getElementById('typeFilters');
const inputs = container.querySelectorAll('input');
inputs.forEach(inp => inp.checked = checked);
renderSchedule();
}
// Główna funkcja renderująca
function renderSchedule() {
// 1. Pobierz aktywne filtry
const activeSubjects = Array.from(document.querySelectorAll('#subjectFilters input:checked')).map(cb => cb.value);
const activeTypes = Array.from(document.querySelectorAll('#typeFilters input:checked')).map(cb => cb.value);
// 2. Wyczyść kolumny
document.querySelectorAll('.day-col .event').forEach(el => el.remove());
// 3. Filtruj dane
const filteredData = rawData.filter(item =>
activeSubjects.includes(item.subject) && activeTypes.includes(item.type)
);
// 4. Grupuj wg dnia
const eventsByDay = { "Poniedziałek": [], "Wtorek": [], "Środa": [], "Czwartek": [], "Piątek": [] };
filteredData.forEach(item => {
const startMin = timeToMinutes(item.start);
const endMin = timeToMinutes(item.end);
const top = (startMin - (startHour * 60)) / 60 * cellHeight;
const durationMin = endMin - startMin;
const height = (durationMin / 60) * cellHeight;
const parsed = {
...item,
top: top,
height: height,
startMin: startMin,
endMin: endMin,
durationMin: durationMin,
meta: metaData[item.subject] || { ects: "?", status: "?", verify: "?", short: item.subject, color: "#eee" },
typeMeta: typeMap[item.type] || { badge: "?", color: "#333", name: item.type }
};
if (eventsByDay[item.day]) eventsByDay[item.day].push(parsed);
});
// 5. Oblicz layout (overlaps) i rysuj
Object.keys(eventsByDay).forEach(day => {
const dayEvents = eventsByDay[day];
layoutDay(dayEvents); // Przelicz pozycje tylko dla widocznych!
const container = document.getElementById('col-' + day);
const hasMyPlan = Object.keys(myPlan).length > 0;
dayEvents.forEach(ev => {
const el = document.createElement('div');
el.className = 'event';
el.style.top = ev.top + 'px';
el.style.height = ev.height + 'px';
el.style.width = ev.widthPercent + '%';
el.style.left = ev.leftPercent + '%';
el.style.backgroundColor = ev.meta.color;
el.style.zIndex = 5 + ev.colIndex;
const isInMyPlan = myPlan[planKey(ev)] === ev.group;
if (hasMyPlan && !isInMyPlan) {
el.classList.add('event-dimmed');
}
if (isInMyPlan) {
el.classList.add('event-my-plan');
}
let nameStyle = '';
if (ev.durationMin <= 45) {
nameStyle = 'font-size: 0.65rem; line-height: 1.0;';
}
el.innerHTML = `
<div class="group-badge">Gr. ${ev.group}</div>
<div class="type-badge" style="background-color: ${ev.typeMeta.color}">${ev.typeMeta.badge}</div>
<div class="subject-name" style="${nameStyle}">${ev.meta.short}</div>
<div class="event-time">${ev.start} - ${ev.end}</div>
`;
el.onclick = (e) => { e.preventDefault(); toggleMyPlan(ev); };
container.appendChild(el);
});
});
updateUnselectedSummary(activeSubjects, activeTypes);
saveOptions();
}
// Algorytm układania (ten sam co wcześniej)
function layoutDay(events) {
events.sort((a, b) => (a.startMin - b.startMin) || (b.endMin - a.endMin));
const columns = [];
events.forEach(ev => {
let placed = false;
for (let i = 0; i < columns.length; i++) {
const lastInCol = columns[i][columns[i].length - 1];
if (ev.startMin >= lastInCol.endMin) {
columns[i].push(ev);
ev.colIndex = i;
placed = true;
break;
}
}
if (!placed) {
columns.push([ev]);
ev.colIndex = columns.length - 1;
}
});
events.forEach(ev => {
const overlapping = events.filter(other =>
other !== ev && !(other.endMin <= ev.startMin || other.startMin >= ev.endMin)
);
let maxCol = ev.colIndex;
overlapping.forEach(o => { if (o.colIndex > maxCol) maxCol = o.colIndex; });
const totalCols = maxCol + 1;
ev.widthPercent = 98 / totalCols;
ev.leftPercent = 1 + (ev.colIndex * ev.widthPercent);
});
}
// Start (przywróć z localStorage; jeśli brak zapisanych grup, domyślnie zaznacz Wykłady)
initFilters();
if (Object.keys(myPlan).length === 0) selectAllWykład();
renderSchedule();
</script>
</body>
</html>