-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvacation-tracker.html
More file actions
317 lines (270 loc) · 9.8 KB
/
vacation-tracker.html
File metadata and controls
317 lines (270 loc) · 9.8 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
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>2024-25 방학 진행도</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
display: flex;
justify-content: center;
align-items: flex-start;
min-height: 100vh;
padding: 5px;
background-color: white;
}
.card {
background: white;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
padding: 20px;
max-width: 1200px;
}
.content-wrapper {
display: flex;
gap: 24px;
flex-wrap: wrap;
}
.progress-section {
flex: 1;
min-width: 300px;
}
.progress-bar {
width: 100%;
height: 24px;
background-color: #e2e8f0;
border-radius: 9999px;
overflow: hidden;
margin-bottom: 20px;
}
.progress-fill {
height: 100%;
background-color: #3b82f6;
transition: width 0.5s ease-in-out;
}
.stats {
text-align: center;
display: grid;
grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
gap: 16px;
}
.stat-item {
padding: 8px;
background-color: #f8fafc;
border-radius: 8px;
}
.stat-value {
font-size: 1.25rem;
font-weight: 600;
color: #1e40af;
}
.stat-label {
font-size: 0.875rem;
color: #64748b;
}
.calendar-section {
flex: 2;
min-width: 400px;
}
.calendar-grid {
display: grid;
grid-template-columns: 50px repeat(13, 1fr);
gap: 8px;
}
.weekday {
text-align: center;
font-size: 0.875rem;
font-weight: 500;
color: #666;
height: 16px;
display: flex;
align-items: center;
justify-content: center;
}
.week-label {
font-size: 0.75rem;
color: #000;
text-align: center;
padding: 4px;
height: 16px;
display: flex;
align-items: center;
justify-content: center;
}
.date-block {
width: 16px;
height: 16px;
border-radius: 4px;
justify-self: center;
}
.date-block.passed {
background-color: #ef4444;
}
.date-block.today {
background-color: #3b82f6;
}
.date-block.future {
background-color: #e2e8f0;
}
.date-block.out-of-range {
background-color: #f3f4f6;
background-image: url("./icon_x.svg");
background-size: cover;
}
.legend {
display: flex;
justify-content: center;
gap: 16px;
font-size: 0.875rem;
color: #666;
padding: 16px 0;
background-color: #f8fafc;
border-radius: 8px;
}
.legend-item {
display: flex;
align-items: center;
gap: 4px;
}
.legend-color {
width: 16px;
height: 16px;
border-radius: 4px;
}
@media (max-width: 900px) {
.content-wrapper {
flex-direction: column;
}
.progress-section,
.calendar-section {
width: 100%;
}
}
</style>
</head>
<body>
<div class="card">
<div class="content-wrapper">
<div class="progress-section">
<div class="progress-bar">
<div class="progress-fill" id="progress-fill"></div>
</div>
<div class="stats">
<div class="stat-item">
<div class="stat-value"><span id="progress-percentage">0</span>%</div>
<div class="stat-label">진행률</div>
</div>
<div class="stat-item">
<div class="stat-value"><span id="weeks-now">0</span>주차</div>
<div class="stat-label">현재 주</div>
</div>
<div class="stat-item">
<div class="stat-value"><span id="passed-days">0</span>일</div>
<div class="stat-label">경과 일수</div>
</div>
<div class="stat-item">
<div class="stat-value"><span id="days-left">0</span>일</div>
<div class="stat-label">남은 일수</div>
</div>
</div>
</div>
<div class="calendar-section">
<div class="calendar-grid" id="calendar-grid">
<!-- JavaScript will populate this -->
</div>
</div>
</div>
</div>
<script>
const startDate = new Date('2024-12-13');
const endDate = new Date('2025-03-03');
const weekdays = ['일', '월', '화', '수', '목', '금', '토'];
function updateProgress() {
const now = new Date();
const totalDuration = endDate.getTime() - startDate.getTime();
const elapsedDuration = now.getTime() - startDate.getTime();
const progress = Math.min(Math.max((elapsedDuration / totalDuration) * 100, 0), 100);
const msPerDay = 1000 * 60 * 60 * 24;
const totalDays = Math.ceil(totalDuration / msPerDay);
const passedDays = Math.min(Math.ceil(elapsedDuration / msPerDay), totalDays);
const daysLeft = Math.max(totalDays - passedDays, 0);
// 시작일의 요일을 얻어옴 (0: 일요일, 1: 월요일, ...)
const startDay = startDate.getDay();
// 첫 번째 일요일까지 남은 일수 계산 (시작일이 일요일이면 0, 아니면 다음 일요일까지의 일수)
const daysUntilFirstSunday = startDay === 0 ? 0 : 7 - startDay;
// DOM 업데이트
document.getElementById('progress-fill').style.width = `${progress}%`;
document.getElementById('progress-percentage').textContent = progress.toFixed(1);
document.getElementById('passed-days').textContent = passedDays;
document.getElementById('days-left').textContent = daysLeft;
document.getElementById('weeks-now').textContent = passedDays < daysUntilFirstSunday ? 0 : Math.floor((passedDays - daysUntilFirstSunday) / 7) + 1;
}
function getWeekLabel(date) {
const month = date.getMonth() + 1;
const weekOfMonth = Math.ceil(date.getDate() / 7);
return `${month}월 ${weekOfMonth}주`;
}
function createCalendar() {
const grid = document.getElementById('calendar-grid');
grid.innerHTML = '';
const weekLabels = [
'0', '1', '2', '3',
'4', '5', '6', '7',
'8', '9', '10', '11', '12'
];
// Add empty cell for top-left corner
const cornerDiv = document.createElement('div');
grid.appendChild(cornerDiv);
// Add week labels as column headers
weekLabels.forEach(label => {
const labelDiv = document.createElement('pre');
labelDiv.className = 'week-label';
labelDiv.textContent = label;
grid.appendChild(labelDiv);
});
// Add weekday rows
weekdays.forEach(day => {
// Add weekday label
const dayDiv = document.createElement('div');
dayDiv.className = 'weekday';
dayDiv.textContent = day;
grid.appendChild(dayDiv);
// Add date blocks for each week
const startDateCopy = new Date(startDate);
startDateCopy.setDate(startDateCopy.getDate() - startDateCopy.getDay());
if (day !== '일') {
startDateCopy.setDate(startDateCopy.getDate() + weekdays.indexOf(day));
}
for (let week = 0; week < weekLabels.length; week++) {
const date = new Date(startDateCopy);
date.setDate(date.getDate() + (week * 7));
const dateBlock = document.createElement('div');
dateBlock.className = 'date-block';
const currentDate = new Date();
if (date < startDate || date > endDate) {
dateBlock.classList.add('out-of-range');
} else if (date.toDateString() === currentDate.toDateString()) {
dateBlock.classList.add('today');
} else if (date < currentDate) {
dateBlock.classList.add('passed');
} else {
dateBlock.classList.add('future');
}
dateBlock.title = `${date.getFullYear()}년 ${date.getMonth() + 1}월 ${date.getDate()}일`;
grid.appendChild(dateBlock);
}
});
}
// Initial setup
createCalendar();
updateProgress();
setInterval(updateProgress, 1000);
</script>
</body>
</html>