-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcourses.html
524 lines (469 loc) · 14.2 KB
/
courses.html
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Curriculum</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Yuji+Syuku&display=swap" rel="stylesheet">
<style>
html {
width: 100vw;
overflow-x: hidden;
}
.teacher-name {
font-family: "Yuji Syuku", serif;
}
.table {
min-width: 800px;
}
.table-row {
display: grid;
grid-template-columns: 6rem 3rem repeat(5, 1fr);
}
.period-box {
display: grid;
grid-template-rows: repeat(auto-fill, 1fr);
}
.period-header {
background-color: #d3d3d3;
font-size: 22px;
text-align: center;
}
.table-cell {
border: 1px solid gray;
}
.period-cell {
border: 1px solid gray;
min-height: 6rem;
}
.time-box {
display: grid;
grid-template-rows: repeat(auto-fill, 1fr);
text-align: center;
}
.time-cell {
min-height: 2rem;
}
.floor-number {
text-align: center;
font-size: 3rem;
color: rgb(53, 15, 124);
font-family: Impact, Haettenschweiler, "Arial Narrow Bold", sans-serif;
}
.highlight {
background-color: rgb(255, 241, 116);
}
.indicator {
height: 2px;
background-color: rgba(255, 24, 24, 0.856);
position: absolute;
/* not working on android firefox */
/* width: 100vw; */
top: 0;
transition: all ease 0.3s;
}
.indicator-text {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
font-size: 20px;
color: rgb(6, 179, 57);
}
.text-center {
text-align: center;
}
.relative {
position: relative;
}
.py-1 {
padding-top: 1rem;
padding-bottom: 1rem;
}
.py-2 {
padding-top: 2rem;
padding-bottom: 2rem;
}
</style>
</head>
<body>
<div class="table">
<div class="table-header">
<div class="table-row">
<div class="table-cell"></div>
<div class="table-cell"></div>
<div id="weekdayContainer"></div>
</div>
</div>
<div class="table-body">
<div class="table-row">
<div class="table-cell" id="time-box-1"></div>
<div class="table-cell period-header"></div>
<div class="table-cell">
<div class="period-box">
<div class="period-cell">
Web デザイン I
</div>
<div class="period-cell teacher-name">
岩本
</div>
<div class="period-cell floor-number">
43
</div>
</div>
</div>
<div class="table-cell">
<div class="period-box">
<div class="period-cell">
英語 I
</div>
<div class="period-cell">
トベ サラミ
</div>
<div class="period-cell floor-number">
21
</div>
</div>
</div>
<div class="table-cell">
<div class="period-box">
<div class="period-cell">
ネットワーク I
</div>
<div class="period-cell">
深田
</div>
<div class="period-cell floor-number">
24
</div>
<!-- classroom で出席確認必要
教科書の point は試験の時出るかもしれません -->
</div>
</div>
<div class="table-cell">
<div class="period-box">
<div class="period-cell">
ビジネス日本語練習 I
</div>
<div class="period-cell">
吉田
</div>
<div class="period-cell floor-number">
21
</div>
</div>
</div>
<div class="table-cell">
<div class="period-box">
<div class="period-cell">
プログラミング I
</div>
<div class="period-cell">
根岸
</div>
<div class="period-cell floor-number">
61
</div>
</div>
</div>
</div>
<div class="table-row">
<div class="table-cell" id="time-box-2"></div>
<div class="table-cell period-header"></div>
<div class="table-cell">
<div class="period-box">
<div class="period-cell">
Web デザイン I
</div>
<div class="period-cell">
岩本
</div>
<div class="period-cell floor-number">
43
</div>
</div>
</div>
<div class="table-cell">
<div class="period-box">
<div class="period-cell">
ビジネスソフト I A (Excel)
</div>
<div class="period-cell">
森(烈)
</div>
<div class="period-cell floor-number">
61
</div>
</div>
</div>
<div class="table-cell">
<div class="period-box">
<div class="period-cell">
ビジネスソフト I B (Word)
</div>
<div class="period-cell">
伊藤
</div>
<div class="period-cell floor-number">
24
</div>
</div>
</div>
<div class="table-cell">
<div class="period-box">
<div class="period-cell">
コンピューターシステム I
</div>
<div class="period-cell">
山崎
</div>
<div class="period-cell floor-number">
31
</div>
</div>
</div>
<div class="table-cell">
<div class="period-box">
<div class="period-cell">
プログラミング I
</div>
<div class="period-cell">
根岸
</div>
<div class="period-cell floor-number">
61
</div>
</div>
</div>
</div>
<div class="table-row">
<div class="table-cell" id="time-box-3"></div>
<div class="table-cell period-header"></div>
<div class="table-cell">
<div class="period-box">
<div class="period-cell">
ビジネス日本語 I
</div>
<div class="period-cell">
澤田
</div>
<div class="period-cell floor-number">
41
</div>
</div>
</div>
<div class="table-cell">
<div class="period-box">
<div class="period-cell">
ビジネス基礎 I
</div>
<div class="period-cell">
森(大)
</div>
<div class="period-cell floor-number">
21
</div>
</div>
</div>
<div class="table-cell">
<div class="period-box">
<div class="period-cell">
12:35~13:00 HR
</div>
<div class="period-cell">
担任
</div>
<div class="period-cell floor-number">
24
</div>
</div>
</div>
</div>
</div>
</div>
<!-- https://releases.jquery.com/ -->
<script src="https://code.jquery.com/jquery-3.7.1.min.js"
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo=" crossorigin="anonymous"></script>
<script>
$(document).ready(function () {
function createPeriodHeader(time) {
let $periodHeader = $(`
<div class="period-box ">
<div class="period-cell" style="">
科目 📚
</div>
<div class="period-cell">
先生 👩🏫
</div>
<div class="period-cell">
教室 🏫
</div>
</div>
`);
return $periodHeader;
}
$.each($(".period-header"), function (index, item) {
let $periodHeader = createPeriodHeader();
$(item).append($periodHeader);
});
// let weekdays = ["日", "月", "火", "水", "木", "金", "土"];
let courses = [
{
id: 0,
subject: "Web デザイン I",
teacher: "岩本",
classroom: "43"
},
{
id: 1,
subject: "英語 I",
teacher: "トベ サラミ",
classroom: "21"
},]
let periods = [
{
id: 0,
startTime: "9:20",
endTime: "10:50"
},
{
id: 1,
startTime: "11:05",
endTime: "12:35"
},
{
id: 2,
startTime: "13:25",
endTime: "14:55"
},]
let weekdays = [
{ id: 0, japanese: "日", english: "Sunday" },
{ id: 1, japanese: "月", english: "Monday" },
{ id: 2, japanese: "火", english: "Tuesday" },
{ id: 3, japanese: "水", english: "Wednesday" },
{ id: 4, japanese: "木", english: "Thursday" },
{ id: 5, japanese: "金", english: "Friday" },
{ id: 6, japanese: "土", english: "Saturday" }
];
function createWeekday(weekday) {
let $weekday = $("<div></div>")
.text(weekday.japanese)
.addClass(["table-cell", "text-center", "py-1"]);
let today = new Date().getDay();
if (weekday.japanese === weekdays[today].japanese) {
$weekday.addClass("highlight");
}
return $weekday;
}
$.each(weekdays.slice(1, 6), function (index, weekday) {
let $weekday = createWeekday(weekday);
$("#weekdayContainer").append($weekday);
});
setTimeout(() => {
// wait for all the weekdays
// how to resolve this async problem in jquery
$("#weekdayContainer")
.children()
.unwrap();
});
let courseTimeObjects = [
{
index: 0,
startTime: "9:20",
endTime: "10:50"
},
{
index: 1,
startTime: "11:05",
endTime: "12:35"
},
{
index: 2,
startTime: "13:25",
endTime: "14:55"
}
];
function compareWithCurrentTime(timeObject) {
const currentTime = new Date();
const startTime = new Date();
const endTime = new Date();
const [startHours, startMinutes] = timeObject.startTime.split(":");
startTime.setHours(startHours);
startTime.setMinutes(startMinutes);
const [endHours, endMinutes] = timeObject.endTime.split(":");
endTime.setHours(endHours);
endTime.setMinutes(endMinutes);
let deltaStartPercent = -1;
let result = currentTime > startTime && currentTime < endTime;
if (result) {
deltaStartPercent =
((currentTime - startTime) / (endTime - startTime)) * 100;
}
return { result, deltaStartPercent };
}
function createCourseTime(time) {
let $courseTime = $(`
<div class="time-box">
<div class="time-cell">
${time.index + 1}限
</div>
<div class="time-cell">
${time.startTime}
</div>
<div class="time-cell">
~
</div>
<div class="time-cell">
${time.endTime}
</div>
</div>`);
return $courseTime;
}
const renderCourseTime = (time, $timeBox) => {
let oldIndicator = $timeBox.find('.indicator')
if (oldIndicator.length) {
oldIndicator.remove()
}
const compared = compareWithCurrentTime(time);
if (compared.result) {
$timeBox.addClass("highlight").addClass("relative");
const nowHours = new Date().getHours();
const nowMinutes = new Date().getMinutes();
const $indicator = $(`<div class='indicator'><div class="indicator-text">${nowHours}:${nowMinutes}</div></div>`).css("top", `${compared.deltaStartPercent}%`);
$timeBox.append($indicator);
updateIndicatorWidth();
}
};
$.each(courseTimeObjects, (index, time) => {
const $courseTime = createCourseTime(time);
$(`#time-box-${time.index + 1}`).append($courseTime);
});
$.each(courseTimeObjects, (index, time) => {
const $timeBox = $(`#time-box-${time.index + 1}`);
renderCourseTime(time, $timeBox);
});
$(window).on("focus", () => {
$.each(courseTimeObjects, (index, time) => {
const $timeBox = $(`#time-box-${time.index + 1}`);
$timeBox.removeClass("highlight");
renderCourseTime(time, $timeBox);
});
});
// Function to update the width of the indicator to match the width of the .table div
function updateIndicatorWidth() {
let tableWidth = $(".table").width(); // Get the width of the .table div
$(".indicator").css("width", tableWidth); // Set the width of the indicator to match the .table div width
}
// Call the function initially to set the width of the indicator
updateIndicatorWidth();
// Call the function whenever the window is resized to update the width of the indicator
$(window).on("resize", function () {
updateIndicatorWidth();
});
});
</script>
</body>
</html>