-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.html
207 lines (199 loc) · 6.75 KB
/
main.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Nooth Clubs - Events</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.0/papaparse.min.js"></script>
<style>
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap');
body {
font-family: 'Roboto', sans-serif;
background-color: #15478C;
color: #FFFFFF;
transition: opacity 1s ease-in-out;
}
.slides-container {
background-color: #008B9E;
padding: 32px 0;
}
.schedule-section {
display: flex;
overflow-x: auto;
padding: 16px 0;
}
.club-card {
background-color: #ffffff;
color: #15478C;
box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15);
border-radius: 8px;
padding: 16px;
margin-right: 16px;
width: 280px;
flex-shrink: 0;
opacity: 1;
transform: translateY(0) scale(1);
transition: all 0.5s ease-out;
position: relative;
}
.club-card.animated {
opacity: 1;
transform: translateY(0) scale(1);
}
.in-progress {
background-color: #C5413F;
color: #FFFFFF;
font-weight: bold;
padding: 4px 8px;
border-radius: 4px;
position: absolute;
top: 8px;
right: 8px;
}
@media (max-width: 768px) {
.club-card {
width: 100%;
margin-right: 8px;
padding: 12px;
}
.schedule-section {
flex-direction: column;
overflow-x: visible;
}
}
</style>
</head>
<body class="text-lg">
<div class="container mx-auto flex justify-between items-center py-8 mb-4">
<img src="logo.png" alt="Nooth Clubs Logo" class="h-12" width="auto">
<div id="currentDateTime" class="text-2xl text-[#F5BD18]"></div>
</div>
<div class="container mx-auto mb-8">
<h2 class="text-3xl font-bold text-[#F5BD18] mb-4">Today</h2>
</div>
<div class="slides-container mb-12">
<div class="container mx-auto">
<div id="today" class="schedule-section"></div>
</div>
</div>
<div class="container mx-auto mb-8">
<h2 class="text-3xl font-bold text-[#F5BD18] mb-4">Tomorrow</h2>
</div>
<div class="slides-container mb-12">
<div class="container mx-auto">
<div id="tomorrow" class="schedule-section"></div>
</div>
</div>
<div class="container mx-auto mb-8">
<h2 class="text-3xl font-bold text-[#F5BD18] mb-4">Later This Week</h2>
</div>
<div class="slides-container mb-12">
<div class="container mx-auto">
<div id="laterThisWeek" class="schedule-section"></div>
</div>
</div>
<script>
function updateDateTime() {
const now = new Date();
const options = {
weekday: 'long',
year: 'numeric',
month: 'long',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
timeZone: 'Europe/Dublin'
};
document.getElementById('currentDateTime').textContent = now.toLocaleDateString('en-US', options);
}
function createClubCard(event, isInProgress) {
event.summary = event.summary.replace('[Physical Activity] MU Life', '').trim();
const card = document.createElement('div');
card.classList.add('club-card');
card.innerHTML = `
<h3 class="text-2xl font-medium text-[#15478C] mb-3">${event.summary}</h3>
<p class="text-lg font-semibold text-[#15478C] mb-1">${new Date(event.dtstart).toLocaleDateString([], { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })}</p>
<p class="text-xl text-[#3C4043] mb-2">${new Date(event.dtstart).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })} - ${new Date(event.dtend).toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })}</p>
<p class="text-lg text-[#5F6368]">${event.location}</p>
`;
if (isInProgress) {
const inProgressLabel = document.createElement('span');
inProgressLabel.classList.add('in-progress');
inProgressLabel.innerText = "In Progress";
card.appendChild(inProgressLabel);
}
return card;
}
function generateClubCards(events) {
const now = new Date();
const uniqueEventKeys = new Set();
const uniqueEvents = events.filter(event => {
const dayKey = `${new Date(event.dtstart).toDateString()}`;
const key = `${event.dtstart}-${event.dtend}-${event.location}-${event.summary}`;
if (uniqueEventKeys.has(key + dayKey)) {
return false;
} else {
uniqueEventKeys.add(key + dayKey);
return true;
}
});
uniqueEvents.sort((a, b) => {
const dateComparison = new Date(a.dtstart) - new Date(b.dtstart);
if (dateComparison !== 0) {
return dateComparison;
}
return a.summary.localeCompare(b.summary);
}).forEach(event => {
const startTime = new Date(event.dtstart);
const endTime = new Date(event.dtend);
const isInProgress = now >= startTime && now <= endTime;
// Get the current week's start and end (Sunday to Saturday)
const startOfWeek = new Date(now);
startOfWeek.setDate(now.getDate() - now.getDay());
startOfWeek.setHours(0, 0, 0, 0);
const endOfWeek = new Date(startOfWeek);
endOfWeek.setDate(startOfWeek.getDate() + 6);
endOfWeek.setHours(23, 59, 59, 999);
// Only display events happening this week
if (startTime >= startOfWeek && startTime <= endOfWeek) {
const card = createClubCard(event, isInProgress);
if (startTime.getDay() === now.getDay()) {
document.getElementById('today').appendChild(card);
} else if (startTime.getDay() === (now.getDay() + 1) % 7) {
document.getElementById('tomorrow').appendChild(card);
} else {
document.getElementById('laterThisWeek').appendChild(card);
}
}
});
}
function fetchCSVData() {
Papa.parse('events.csv', {
download: true,
header: true,
complete: function(results) {
const events = results.data.map(event => {
return {
dtstart: new Date(event.dtstart),
dtend: new Date(event.dtend),
location: event.location,
summary: event.summary
};
});
generateClubCards(events);
},
error: function(error) {
console.error('Error fetching CSV data:', error);
}
});
}
function init() {
updateDateTime();
setInterval(updateDateTime, 60000);
fetchCSVData();
}
window.onload = init;
</script>
</body>
</html>