Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
202 lines (199 loc) · 7.5 KB
/
Copy pathindex.html
File metadata and controls
202 lines (199 loc) · 7.5 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
<!DOCTYPE html>
<html lang="de">
<head>
<!-- jsCalendar style -->
<link rel="stylesheet" type="text/css" href="../js-calendar/jsCalendar.css">
<!-- jsCalendar script -->
<script type="text/javascript" src="../js-calendar/jsCalendar.js"></script>
<!-- jsCalendar language script -->
<script type="text/javascript" src="../js-calendar/jsCalendar.lang.de.js"></script>
<!-- auto jsCalendar element -->
<style>
/*set the date with events to yellow*/
.date-active {
background-color: #FFE31B!important;
color: black!important;
cursor: pointer!important;
}
/*unset the current color*/
.jsCalendar-current {
background-color: transparent!important;
color: black!important;
}
.modal {
position: absolute;
transform: translate3d(0, 5%, 0);
box-shadow: 0px 0px 8px #00000029;
background: none;
}
.modal:after {
content: "";
width: 20px;
height: 20px;
transform: rotate(-45deg);
background: #fff;
position: absolute;
box-shadow: 0px 0px 8px #00000029;
z-index: -1;
top: -5px;
left: 8px;
}
.modal-content {
text-decoration: none;
}
.modal-content a:nth-child(even) {
background-color: #F7F8F8;
}
.modal-content > a {
background-color: #fff;
display: grid;
padding: 0 0.5rem 0 0.5rem;
line-height: 24px;
grid-template-areas:
"p p p s"
}
.modal-content p {
grid-area: p;
display: grid;
justify-items: start;
}
.modal-content span {
content: '';
font-size: 3px;
width: 4em;
height: 4em;
margin-top: 2em;
margin-top: auto;
margin-bottom: auto;
border-top: 1px solid #697982;
border-left: 1px solid #697982;
transform: rotate(135deg);
}
.hidden {
display: none;
}
</style>
</head>
<body>
<!-- Calendar element -->
<div id="events-calendar">
</div>
<script type="text/javascript">
// Get elements
let elements = {
// Calendar element
calendar : document.getElementById("events-calendar"),
}
//calendar settings
elements.calendar.className = "clean-theme yellow";
let calendar = jsCalendar.new(elements.calendar, "12/09/2023", {
navigator : true,
navigatorPosition : "center",
zeroFill : false,
monthFormat : "month YYYY",
firstDayOfTheWeek : "2",
dayFormat : "DD",
language : "de"
});
let date_format = "DD/MM/YYYY";
//events which then come from evo
let events = [
{
id: "0",
date : "14/09/2023",
title: "Prima La Musica - Preisträgerkonzert",
time: "15:00",
location: "Konzerthaus Klagenfurt",
link: "https://www.google.com"
},
{
id: "1",
date : "14/09/2023",
title: "Vorspielstunde Klavier",
time: "17:30",
location: "Musikschule Winklern",
link: "https://www.google.com"
},
{
id: "2",
date : "16/09/2023",
title: "Vorspielstunde Harfe",
time: "17:30",
location: "Musikschule Flattach",
link: "https://www.google.com"
},
{
id: "3",
date : "16/09/2023",
title: "Vorspielstunde Blockflöte",
time: "14:00",
location: "Musikschule Flattach",
link: "https://www.google.com"
},
{
id: "4",
date : "18/09/2023",
title: "Vorspielstunde Harfe",
time: "17:30",
location: "Musikschule Flattach",
link: "https://www.google.com"
},
{
id: "5",
date : "18/01/2024",
title: "Vorspielstunde Harfe",
time: "17:30",
location: "Musikschule Flattach",
link: "https://www.google.com"
}
]
calendar.onDateRender(function(date, element, info) {
//get the current date and check if there is an event
currDate = jsCalendar.tools.dateToString(new Date(date.getTime()), date_format, "de");
let foundEvent = events.filter(event => event.date == currDate);
if (foundEvent.length != 0) {
//set the class if there is a event for this date
element.className = 'date-active';
//make div with class modal and hidden
const modalDiv = document.createElement("div");
modalDiv.classList.add('modal', 'hidden');
modalDiv.setAttribute('data-modalid', currDate);
const modalContent = document.createElement("div");
modalContent.classList.add('modal-content');
//go through each event and add span with id and title
foundEvent.forEach(function(item, index) {
modalContent.insertAdjacentHTML('beforeend', `
<a href='${item.link}' target='blank'>
<p>
<b>${item.title}</b>
${item.time}: ${item.location}
</p>
<span></span>
</a>
`);
});
modalDiv.appendChild(modalContent);
element.appendChild(modalDiv);
}
});
// Refresh layout
calendar.refresh();
//show/hide event popup
let showEvents = function(date, element){
currDate = jsCalendar.tools.dateToString(new Date(date.getTime()), date_format, "de");
let showDate = events.filter(event => event.date == currDate);
//get from the id backwards the parent element modal
let modalDiv = document.querySelector('[data-modalid = "'+currDate+'"]');
//toggle hidden class
if (showDate) {
modalDiv.classList.toggle("hidden");
}
};
// Add events
calendar.onDateClick(function(event, date){
// Show events
showEvents(date);
});
</script>
</body>
</html>