-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
286 lines (244 loc) · 11.8 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-S2218Z2X7B"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-S2218Z2X7B');
</script>
<title>Calendrier Zen Flex</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/evo-calendar/css/evo-calendar.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.9.0/css/all.min.css"
integrity="sha512-q3eWabyZPc1XTCmF+8/LuE1ozpg5xxn7iO89yfSOd5/oKvyqLngoNGsx8jq92Y8eXJ/IRxQbEC+FGSYxtk2oiw=="
crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="theme.css">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="icon.png" />
</head>
<body>
<div class="container">
<section class="section">
<h1 class="title">Calendrier Zen Flex</h1>
<div class="columns">
<div class="column is-one-quarter">
<div class="day-card card" id="yesterday">
<div class="card-content">
<div class="media">
<div class="media-left">
<figure class="image is-48x48">
<span class="icon is-large">
<i class="fas fa-2x fa-spinner fa-pulse"></i>
</span>
</figure>
</div>
<div class="media-content">
<p class="title is-4">Hier</p>
<p class="subtitle is-6 date"></p>
<p class="subtitle is-6 type"></p>
</div>
</div>
</div>
</div>
</div>
<div class="column is-one-quarter">
<div class="day-card card" id="today">
<div class="card-content">
<div class="media">
<div class="media-left">
<figure class="image is-48x48">
<span class="icon is-large">
<i class="fas fa-2x fa-spinner fa-pulse"></i>
</span>
</figure>
</div>
<div class="media-content">
<p class="title is-4">Aujourd'hui</p>
<p class="subtitle is-6 date"></p>
<p class="subtitle is-6 type"></p>
</div>
</div>
</div>
</div>
</div>
<div class="column is-one-quarter">
<div class="day-card card" id="tomorrow">
<div class="card-content">
<div class="media">
<div class="media-left">
<figure class="image is-48x48">
<span class="icon is-large">
<i class="fas fa-2x fa-spinner fa-pulse"></i>
</span>
</figure>
</div>
<div class="media-content">
<p class="title is-4">Demain</p>
<p class="subtitle is-6 date"></p>
<p class="subtitle is-6 type"></p>
</div>
</div>
</div>
</div>
</div>
<div class="column is-one-quarter">
<div class="day-card card" id="after-tomorrow">
<div class="card-content">
<div class="media">
<div class="media-left">
<figure class="image is-48x48">
<span class="icon is-large">
<i class="fas fa-2x fa-spinner fa-pulse"></i>
</span>
</figure>
</div>
<div class="media-content">
<p class="title is-4">Après-demain</p>
<p class="subtitle is-6 date"></p>
<p class="subtitle is-6 type"></p>
</div>
</div>
</div>
</div>
</div>
</div>
<div id="calendar"></div>
</section>
</div>
<footer class="footer">
<div class="content has-text-centered">
<p>
<strong>Zen Flex Calendar</strong> by <a href="https://github.com/masfaraud">Steven Masfaraud</a>. Les
données sont fournies sans garantie.
<a href="https://github.com/masfaraud/ZenFlex">Source github</a>.
</p>
</div>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"
integrity="sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/evo-calendar/js/evo-calendar.min.js"></script>
<script>
// initialize your calendar, once the page's DOM is ready
$(document).ready(function () {
$('#calendar').evoCalendar({
theme: 'Midnight Blue',
language: 'fr',
todayHighlight: true,
firstDayOfWeek: 1,
eventHeaderFormat: 'D d MM yyyy'
});
const options = { weekday: undefined, year: 'numeric', month: 'short', day: 'numeric' };
$.getJSON("https://masfaraud.github.io/ZenFlex/data.json", function (data) {
var now = new Date();
var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
var stop = new Date();
stop.setDate(stop.getDate() + 365);
var yesterday = new Date();
yesterday.setDate(yesterday.getDate() - 1);
var after_tomorrow = new Date();
after_tomorrow.setDate(after_tomorrow.getDate() + 2);
function dayType(day) {
if (day.getDay() == 6 || day.getDay() == 0) {
return "eco"
}
var month = day.getMonth();
if (month > 3 && month < 9) {
return "eco";
}
if (month == 3 && day.getDate() > 15) {
return "eco";
}
if (month == 9 && day.getDate() <= 15) {
return "eco";
}
var formated_date = day.toLocaleDateString('en', options);
if (data['sobriete'].includes(formated_date)) {
return "sobriete"
}
if (data['bonus'].includes(formated_date)) {
return "bonus"
}
// If in the past, should be eco
if (day <= now) {
return "eco"
}
// If day is tomorrow: before 5pm tomorrow is undecided, after it is eco
if (day == tomorrow && now.getHours() >= 17) {
return "eco"
}
return "undecided"
}
const icons = { "sobriete": "fa-piggy-bank", "eco": "fa-bolt", "bonus": "fa-gift", "undecided": "fa-question" }
const clean_types = { "sobriete": "Jour sobriété", "eco": "Jour éco", "bonus": "Jour bonus", "undecided": "Jour non défini" }
function updateCard(card_id, day) {
day_type = dayType(day);
card = $(card_id);
card.addClass(day_type);
icon = card.find("i");
icon.removeClass("fa-spinner");
icon.removeClass("fa-pulse");
icon.addClass(icons[day_type]);
card.find("p.date").text(day.toLocaleDateString('en', options));
card.find("p.type").text(clean_types[day_type]);
}
updateCard("#yesterday", yesterday)
updateCard("#today", now)
updateCard("#tomorrow", tomorrow)
updateCard("#after-tomorrow", after_tomorrow)
for (var day = new Date(2023, 8, 1); day <= stop; day.setDate(day.getDate() + 1)) {
day_type = dayType(day)
var formated_date = day.toLocaleDateString('en', options);
if (day_type == 'sobriete') {
$('#calendar').evoCalendar('addCalendarEvent', {
id: "sobriete" + formated_date,
name: 'Jour Sobriété',
description: 'Jour sobriété Zen Flex',
date: formated_date,
type: 'event',
color: '#e71f1f',
});
}
else if (day_type == 'bonus') {
$('#calendar').evoCalendar('addCalendarEvent', {
id: "sobriete" + formated_date,
name: 'Jour Bonus',
description: 'Jour Bonus Zen Flex',
date: formated_date,
type: 'event',
color: '#1f4ce7',
});
}
else if (day_type == 'eco') {
$('#calendar').evoCalendar('addCalendarEvent', {
id: "eco" + formated_date,
name: 'Jour éco',
description: 'Jour éco',
date: formated_date,
type: 'event',
color: '#1fe76e',
});
}
else if (day_type == 'undecided') {
$('#calendar').evoCalendar('addCalendarEvent', {
id: "indef" + formated_date,
name: 'Jour indéfini',
description: 'Attendre la veille pour connaître le type de jour',
date: formated_date,
type: 'event',
color: '#eee',
});
}
};
}).fail(function () {
console.log("An error has occurred.");
});
});
</script>
</body>
</html>