-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLiturgicalDay.html
More file actions
358 lines (306 loc) · 9.57 KB
/
LiturgicalDay.html
File metadata and controls
358 lines (306 loc) · 9.57 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Liturgical Day Widget</title>
<link rel="stylesheet" href="/index.css">
<style>
body {
background: transparent !important;
font-family: 'Inter', sans-serif;
margin: 0;
padding: 0.75rem;
box-sizing: border-box;
font-size: 0.85rem;
/* Text color based on theme */
color: #333; /* Default light theme text */
}
[data-theme="dark"] body {
color: #a6a6d1; /* Dark theme text color */
background: transparent !important;
}
.widget-container {
background: transparent !important;
border: none !important;
box-shadow: none !important;
backdrop-filter: none !important;
border-radius: 12px;
padding: 0.5rem;
text-align: center;
width: 100%;
max-height: calc(100vh - 1.5rem);
overflow-y: auto;
position: relative;
transition: all 0.3s ease;
}
/* Force all elements to have transparent backgrounds */
* {
background: transparent !important;
background-color: transparent !important;
background-image: none !important;
}
/* Exception: Allow liturgical color circles to show their actual colors */
.celebration-colour {
background: var(--liturgical-color) !important;
background-color: var(--liturgical-color) !important;
}
/* Only allow text colors to change */
.widget-title,
.celebration-title,
.celebration-rank,
.loading,
.error-message {
background: transparent !important;
background-color: transparent !important;
}
.widget-container::before {
display: none;
}
.widget-header {
text-align: center;
margin-bottom: 0.5rem;
padding-bottom: 0.5rem;
border-bottom: none;
}
.widget-title {
font-size: 1.2rem;
font-weight: 700;
margin: 0;
color: inherit; /* Inherit from body */
}
.season-info {
font-size: 0.8rem;
color: inherit; /* Inherit from body */
margin-bottom: 0.5rem;
padding: 0.4rem 0.6rem;
background: transparent;
border-radius: 8px;
text-align: center;
text-transform: capitalize;
border: none;
animation: fadeInUp 0.6s ease-out 0.2s both;
position: relative;
overflow: hidden;
}
.season-info::before {
display: none;
}
.celebrations {
margin-top: 0.5rem;
}
.celebration {
margin-bottom: 0.5rem;
padding: 0.5rem;
border-radius: 8px;
background: transparent;
border: none;
transition: all 0.3s ease;
animation: fadeInUp 0.6s ease-out calc(0.4s + var(--delay, 0s)) both;
position: relative;
overflow: hidden;
text-align: center;
}
.celebration:hover {
transform: translateY(-1px);
box-shadow: none;
}
.celebration::before {
display: none;
}
.celebration-title {
font-size: 0.9rem;
font-weight: 600;
color: inherit; /* Inherit from body */
margin: 0;
line-height: 1.3;
margin-bottom: 0.5rem;
word-wrap: break-word;
hyphens: auto;
text-align: center;
}
.celebration-rank {
font-size: 0.7rem;
color: inherit; /* Inherit from body */
opacity: 0.7;
font-style: italic;
margin-top: 0.2rem;
padding: 0.2rem 0.4rem;
background: transparent;
border-radius: 4px;
display: inline-block;
margin-bottom: 0.5rem;
}
.celebration-colour {
display: inline-block;
width: 18px;
height: 18px;
border-radius: 50%;
margin: 0.25rem auto;
border: 2px solid rgba(51, 51, 51, 0.2); /* Light theme border */
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
transition: all 0.3s ease;
}
[data-theme="dark"] .celebration-colour {
border: 2px solid rgba(166, 166, 209, 0.2); /* Dark theme border */
box-shadow: 0 1px 4px rgba(255, 255, 255, 0.15);
}
.celebration-colour:hover {
transform: scale(1.1);
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.error-message {
color: #dc3545; /* Light theme error color */
font-weight: 600;
text-align: center;
padding: 1.5rem 0.75rem;
background: transparent;
border: none;
border-radius: 8px;
animation: fadeInUp 0.6s ease-out;
font-size: 0.8rem;
}
[data-theme="dark"] .error-message {
color: #ff6b6b; /* Dark theme error color */
}
.loading {
text-align: center;
color: inherit; /* Inherit from body */
opacity: 0.7;
padding: 1.5rem 0.75rem;
font-size: 0.9rem;
animation: pulse 1.5s ease-in-out infinite;
}
.loading::after {
content: '';
display: inline-block;
width: 16px;
height: 16px;
border: 2px solid #6e44ff; /* Light theme spinner */
border-radius: 50%;
border-top-color: transparent;
animation: spin 1s linear infinite;
margin-left: 0.5rem;
vertical-align: middle;
}
[data-theme="dark"] .loading::after {
border: 2px solid #00ddeb; /* Dark theme spinner */
border-top-color: transparent;
}
/* Animations */
@keyframes fadeInUp {
from {
opacity: 0;
transform: translateY(15px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes pulse {
0%, 100% {
opacity: 0.7;
}
50% {
opacity: 1;
}
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
/* Responsive design */
@media (max-width: 480px) {
.widget-container {
padding: 0.4rem;
}
.widget-title {
font-size: 1rem;
}
}
</style>
</head>
<body>
<div class="widget-container">
<div class="widget-header">
<h2 class="widget-title">✝ Liturgical Day</h2>
</div>
<div id="liturgical-content" class="loading">Loading liturgical information...</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', () => {
// Handle theme and transparency
const params = new URLSearchParams(window.location.search);
const theme = params.get('theme');
if (theme === 'dark' || theme === 'light') {
document.documentElement.setAttribute('data-theme', theme);
}
// Color mapping for liturgical colors
const colorMap = {
'green': '#228B22',
'red': '#DC143C',
'white': '#FFFFFF',
'violet': '#8A2BE2',
'purple': '#800080',
'rose': '#FF69B4',
'gold': '#FFD700',
'black': '#2F2F2F'
};
// Load liturgical data
loadLiturgicalData();
async function loadLiturgicalData() {
const contentElement = document.getElementById('liturgical-content');
try {
const liturgicalUrl = 'http://calapi.inadiutorium.cz/api/v0/en/calendars/default/today';
const proxyUrl = `/api/proxy?targetUrl=${encodeURIComponent(liturgicalUrl)}`;
const response = await fetch(proxyUrl);
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
}
const data = await response.json();
let html = '';
// Celebrations
if (data.celebrations && Array.isArray(data.celebrations) && data.celebrations.length > 0) {
html += '<div class="celebrations">';
data.celebrations.forEach((celebration, index) => {
html += `<div class="celebration" style="--delay: ${index * 0.1}s;">`;
if (celebration.title) {
// Parse and wrap the title for better formatting
let formattedTitle = celebration.title;
// Split long titles at common break points
formattedTitle = formattedTitle
.replace(/,\s+/g, '<br>') // Break at commas
.replace(/\s+in\s+Ordinary\s+Time/g, '<br>in Ordinary Time') // Break before "in Ordinary Time"
.replace(/\s+(ferial|memorial|feast|solemnity)$/g, '<br>$1') // Break before rank words at end
.replace(/\s+(optional\s+memorial|obligatory\s+memorial)$/g, '<br>$1') // Break before memorial types
.replace(/,\s*(priest|bishop|martyr|virgin|doctor|hermit|religious|widow)/g, '<br>$1') // Break before titles
.replace(/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday),?\s*/g, '$1<br>'); // Break after day names
html += `<div class="celebration-title">${formattedTitle}</div>`;
// Add color indicator if available
if (celebration.colour) {
const colorValue = colorMap[celebration.colour.toLowerCase()] || celebration.colour;
html += `<span class="celebration-colour" style="--liturgical-color: ${colorValue};" title="Liturgical color: ${colorValue}"></span>`;
}
}
if (celebration.rank) {
html += `<div class="celebration-rank">${celebration.rank}</div>`;
}
html += '</div>';
});
}
html += '</div>';
contentElement.innerHTML = html || '<div class="error-message">No liturgical information available for today.</div>';
} catch (error) {
contentElement.innerHTML = `
<div class="error-message">
Failed to load liturgical information.<br>
<small>Error: ${error.message}</small>
</div>
`;
}
}
});
</script>
</body>
</html>