PAUTREL Johan commited on
Commit
2b05c91
·
verified ·
1 Parent(s): 035a859

Add 1 files

Browse files
Files changed (1) hide show
  1. index.html +457 -25
index.html CHANGED
@@ -3,7 +3,7 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>Calendrier Interactif 2025-2030</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
8
  <script src="https://accounts.google.com/gsi/client" async defer></script>
9
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
@@ -36,10 +36,26 @@
36
  .multi-day-middle {
37
  border-radius: 0;
38
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  @media (max-width: 768px) {
40
  .calendar-day {
41
  min-height: 100px;
42
  }
 
 
 
43
  }
44
  </style>
45
  </head>
@@ -47,7 +63,7 @@
47
  <div class="container mx-auto px-4 py-8">
48
  <!-- Header -->
49
  <header class="flex flex-col md:flex-row justify-between items-center mb-8">
50
- <h1 class="text-3xl font-bold text-blue-800 mb-4 md:mb-0">Calendrier Interactif</h1>
51
  <div id="auth-section" class="flex items-center space-x-4">
52
  <div id="user-info" class="hidden items-center">
53
  <img id="user-pic" class="w-10 h-10 rounded-full mr-2" src="" alt="Profile">
@@ -78,15 +94,26 @@
78
  <div class="bg-white rounded-xl shadow-md p-6 mb-8">
79
  <div class="flex flex-col md:flex-row justify-between items-center space-y-4 md:space-y-0">
80
  <div class="flex items-center space-x-4">
81
- <button id="prev-year" class="bg-blue-100 hover:bg-blue-200 text-blue-800 p-2 rounded-full transition">
82
  <i class="fas fa-chevron-left"></i>
83
  </button>
84
- <h2 id="current-year" class="text-2xl font-bold text-blue-800">2025</h2>
85
- <button id="next-year" class="bg-blue-100 hover:bg-blue-200 text-blue-800 p-2 rounded-full transition">
86
  <i class="fas fa-chevron-right"></i>
87
  </button>
 
 
 
88
  </div>
89
  <div class="flex items-center space-x-2">
 
 
 
 
 
 
 
 
90
  <button id="export-btn" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg text-sm font-medium transition flex items-center">
91
  <i class="fas fa-file-export mr-2"></i> Exporter
92
  </button>
@@ -101,11 +128,51 @@
101
  </div>
102
  </div>
103
 
104
- <!-- Calendar -->
105
- <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4" id="calendar-container">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  <!-- Months will be inserted here by JavaScript -->
107
  </div>
108
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
109
  <!-- Task Modal -->
110
  <div id="task-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
111
  <div class="bg-white rounded-xl shadow-xl p-6 w-full max-w-md">
@@ -124,6 +191,16 @@
124
  <label for="task-time" class="block text-sm font-medium text-gray-700 mb-1">Heure (optionnel)</label>
125
  <input type="time" id="task-time" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
126
  </div>
 
 
 
 
 
 
 
 
 
 
127
  <div class="flex justify-end space-x-3 pt-2">
128
  <button id="cancel-task" class="px-4 py-2 text-gray-600 hover:text-gray-800 font-medium rounded-lg transition">
129
  Annuler
@@ -136,6 +213,21 @@
136
  </div>
137
  </div>
138
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  <!-- Multi-day selection info -->
140
  <div id="multi-day-info" class="fixed bottom-4 left-1/2 transform -translate-x-1/2 bg-white shadow-lg rounded-lg px-4 py-2 hidden">
141
  <span class="text-blue-800 font-medium">Sélection multiple activée - Sélectionnez plusieurs jours</span>
@@ -148,6 +240,8 @@
148
  <script>
149
  // Global variables
150
  let currentYear = 2025;
 
 
151
  let calendarData = {};
152
  let selectedDate = null;
153
  let multiDaySelection = false;
@@ -155,12 +249,17 @@
155
  let multiDayEnd = null;
156
  let currentUser = null;
157
  let isDragging = false;
 
 
 
158
 
159
  // Initialize the calendar
160
  document.addEventListener('DOMContentLoaded', function() {
161
  initializeCalendar();
162
  setupEventListeners();
163
  loadFromLocalStorage();
 
 
164
  });
165
 
166
  function initializeCalendar() {
@@ -182,11 +281,17 @@
182
  }
183
 
184
  function renderCalendar() {
185
- const container = document.getElementById('calendar-container');
 
 
 
 
 
 
 
 
186
  container.innerHTML = '';
187
 
188
- document.getElementById('current-year').textContent = currentYear;
189
-
190
  for (let month = 0; month < 12; month++) {
191
  const monthElement = document.createElement('div');
192
  monthElement.className = 'bg-white rounded-xl shadow-md overflow-hidden';
@@ -215,6 +320,67 @@
215
  }
216
  }
217
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
218
  function renderMonthDays(month) {
219
  const monthContainer = document.getElementById(`month-${month}`);
220
  const firstDay = new Date(currentYear, month, 1).getDay();
@@ -242,6 +408,14 @@
242
  dayElement.dataset.month = month;
243
  dayElement.dataset.day = day;
244
 
 
 
 
 
 
 
 
 
245
  // Check if this day is part of a multi-day selection
246
  const isMultiDay = checkMultiDaySelection(currentYear, month, day);
247
  if (isMultiDay) {
@@ -269,32 +443,128 @@
269
  return '';
270
  }
271
 
272
- return calendarData[year][month][day].map((task, index) => `
273
- <div class="task-item bg-blue-100 rounded px-2 py-1 text-sm flex justify-between items-center" data-index="${index}">
 
 
274
  <div>
275
- ${task.time ? `<span class="text-blue-600 font-medium">${task.time}</span> - ` : ''}
276
  <span>${task.text}</span>
277
  ${task.user ? `<span class="text-xs text-gray-500 ml-1">(${task.user})</span>` : ''}
278
  </div>
279
- <button class="delete-task text-red-500 hover:text-red-700 text-xs p-1">
280
  <i class="fas fa-trash-alt"></i>
281
  </button>
282
  </div>
283
- `).join('');
 
 
 
 
 
 
 
 
 
 
 
 
284
  }
285
 
286
  function setupEventListeners() {
287
- // Year navigation
288
- document.getElementById('prev-year').addEventListener('click', () => {
289
- if (currentYear > 2025) {
290
- currentYear--;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
291
  renderCalendar();
292
  }
293
  });
294
 
295
- document.getElementById('next-year').addEventListener('click', () => {
296
- if (currentYear < 2030) {
297
- currentYear++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
  renderCalendar();
299
  }
300
  });
@@ -302,7 +572,7 @@
302
  // Task modal
303
  document.addEventListener('click', function(e) {
304
  if (e.target.closest('.add-task-btn')) {
305
- const dayElement = e.target.closest('.calendar-day');
306
  selectedDate = {
307
  year: parseInt(dayElement.dataset.year),
308
  month: parseInt(dayElement.dataset.month),
@@ -320,7 +590,7 @@
320
 
321
  if (e.target.closest('.delete-task')) {
322
  const taskItem = e.target.closest('.task-item');
323
- const dayElement = e.target.closest('.calendar-day');
324
  const taskIndex = parseInt(taskItem.dataset.index);
325
 
326
  const year = parseInt(dayElement.dataset.year);
@@ -350,7 +620,9 @@
350
  const newTask = {
351
  text: taskText,
352
  time: taskTime || null,
353
- user: currentUser ? currentUser.name : null
 
 
354
  };
355
 
356
  calendarData[selectedDate.year][selectedDate.month][selectedDate.day].push(newTask);
@@ -406,6 +678,70 @@
406
  endMultiDaySelection();
407
  }
408
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
409
  }
410
 
411
  // Google Sign-In
@@ -676,6 +1012,102 @@
676
  function handleDayTouchEnd() {
677
  isDragging = false;
678
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
679
  </script>
680
  <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=johanpautrel/calendrier-interactif" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
681
  </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Calendrier Premium 2025-2030</title>
7
  <script src="https://cdn.tailwindcss.com"></script>
8
  <script src="https://accounts.google.com/gsi/client" async defer></script>
9
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
 
36
  .multi-day-middle {
37
  border-radius: 0;
38
  }
39
+ .week-view-day {
40
+ min-height: 150px;
41
+ }
42
+ .color-picker {
43
+ width: 24px;
44
+ height: 24px;
45
+ border-radius: 50%;
46
+ cursor: pointer;
47
+ border: 2px solid transparent;
48
+ }
49
+ .color-picker.selected {
50
+ border-color: #000;
51
+ }
52
  @media (max-width: 768px) {
53
  .calendar-day {
54
  min-height: 100px;
55
  }
56
+ .week-view-day {
57
+ min-height: 120px;
58
+ }
59
  }
60
  </style>
61
  </head>
 
63
  <div class="container mx-auto px-4 py-8">
64
  <!-- Header -->
65
  <header class="flex flex-col md:flex-row justify-between items-center mb-8">
66
+ <h1 class="text-3xl font-bold text-blue-800 mb-4 md:mb-0">Calendrier Premium</h1>
67
  <div id="auth-section" class="flex items-center space-x-4">
68
  <div id="user-info" class="hidden items-center">
69
  <img id="user-pic" class="w-10 h-10 rounded-full mr-2" src="" alt="Profile">
 
94
  <div class="bg-white rounded-xl shadow-md p-6 mb-8">
95
  <div class="flex flex-col md:flex-row justify-between items-center space-y-4 md:space-y-0">
96
  <div class="flex items-center space-x-4">
97
+ <button id="prev-period" class="bg-blue-100 hover:bg-blue-200 text-blue-800 p-2 rounded-full transition">
98
  <i class="fas fa-chevron-left"></i>
99
  </button>
100
+ <h2 id="current-period" class="text-2xl font-bold text-blue-800">Janvier 2025</h2>
101
+ <button id="next-period" class="bg-blue-100 hover:bg-blue-200 text-blue-800 p-2 rounded-full transition">
102
  <i class="fas fa-chevron-right"></i>
103
  </button>
104
+ <button id="today-btn" class="bg-blue-100 hover:bg-blue-200 text-blue-800 px-3 py-1 rounded-full text-sm transition">
105
+ Aujourd'hui
106
+ </button>
107
  </div>
108
  <div class="flex items-center space-x-2">
109
+ <div class="flex space-x-1 mr-4">
110
+ <button id="month-view-btn" class="bg-blue-600 text-white px-3 py-1 rounded-l-lg text-sm transition">
111
+ Mois
112
+ </button>
113
+ <button id="week-view-btn" class="bg-blue-100 hover:bg-blue-200 text-blue-800 px-3 py-1 rounded-r-lg text-sm transition">
114
+ Semaine
115
+ </button>
116
+ </div>
117
  <button id="export-btn" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg text-sm font-medium transition flex items-center">
118
  <i class="fas fa-file-export mr-2"></i> Exporter
119
  </button>
 
128
  </div>
129
  </div>
130
 
131
+ <!-- Search Bar -->
132
+ <div class="bg-white rounded-xl shadow-md p-4 mb-8">
133
+ <div class="flex flex-col md:flex-row items-center space-y-2 md:space-y-0 md:space-x-4">
134
+ <div class="relative w-full md:w-96">
135
+ <input type="text" id="search-input" placeholder="Rechercher des tâches..." class="w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
136
+ <i class="fas fa-search absolute left-3 top-3 text-gray-400"></i>
137
+ </div>
138
+ <div class="flex items-center space-x-2">
139
+ <label for="search-category" class="text-sm text-gray-600">Catégorie:</label>
140
+ <select id="search-category" class="border border-gray-300 rounded-lg px-2 py-1 text-sm focus:outline-none focus:ring-1 focus:ring-blue-500">
141
+ <option value="all">Toutes</option>
142
+ <option value="work">Travail</option>
143
+ <option value="personal">Personnel</option>
144
+ <option value="family">Famille</option>
145
+ <option value="other">Autre</option>
146
+ </select>
147
+ </div>
148
+ <button id="search-btn" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg text-sm font-medium transition">
149
+ Rechercher
150
+ </button>
151
+ <button id="clear-search" class="text-gray-600 hover:text-gray-800 text-sm font-medium transition">
152
+ Effacer
153
+ </button>
154
+ </div>
155
+ </div>
156
+
157
+ <!-- Calendar Views -->
158
+ <div id="month-view" class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4">
159
  <!-- Months will be inserted here by JavaScript -->
160
  </div>
161
 
162
+ <div id="week-view" class="hidden bg-white rounded-xl shadow-md overflow-hidden">
163
+ <div class="grid grid-cols-7 gap-px bg-gray-200 p-px">
164
+ <!-- Week days header -->
165
+ ${['Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi', 'Dimanche'].map(day => `
166
+ <div class="bg-blue-100 text-blue-800 text-center font-medium py-2">
167
+ ${day}
168
+ </div>
169
+ `).join('')}
170
+ </div>
171
+ <div class="grid grid-cols-7 gap-px bg-gray-200 p-px" id="week-days">
172
+ <!-- Week days content will be inserted here -->
173
+ </div>
174
+ </div>
175
+
176
  <!-- Task Modal -->
177
  <div id="task-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
178
  <div class="bg-white rounded-xl shadow-xl p-6 w-full max-w-md">
 
191
  <label for="task-time" class="block text-sm font-medium text-gray-700 mb-1">Heure (optionnel)</label>
192
  <input type="time" id="task-time" class="w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500">
193
  </div>
194
+ <div>
195
+ <label class="block text-sm font-medium text-gray-700 mb-1">Catégorie</label>
196
+ <div class="flex space-x-2">
197
+ <div class="color-picker bg-red-200 selected" data-color="red" data-category="work"></div>
198
+ <div class="color-picker bg-blue-200" data-color="blue" data-category="personal"></div>
199
+ <div class="color-picker bg-green-200" data-color="green" data-category="family"></div>
200
+ <div class="color-picker bg-yellow-200" data-color="yellow" data-category="other"></div>
201
+ <div class="color-picker bg-purple-200" data-color="purple" data-category="event"></div>
202
+ </div>
203
+ </div>
204
  <div class="flex justify-end space-x-3 pt-2">
205
  <button id="cancel-task" class="px-4 py-2 text-gray-600 hover:text-gray-800 font-medium rounded-lg transition">
206
  Annuler
 
213
  </div>
214
  </div>
215
 
216
+ <!-- Search Results Modal -->
217
+ <div id="search-modal" class="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 hidden">
218
+ <div class="bg-white rounded-xl shadow-xl p-6 w-full max-w-2xl max-h-[80vh] overflow-y-auto">
219
+ <div class="flex justify-between items-center mb-4">
220
+ <h3 class="text-xl font-bold text-blue-800">Résultats de recherche</h3>
221
+ <button id="close-search-modal" class="text-gray-500 hover:text-gray-700">
222
+ <i class="fas fa-times"></i>
223
+ </button>
224
+ </div>
225
+ <div id="search-results" class="space-y-3">
226
+ <!-- Search results will be inserted here -->
227
+ </div>
228
+ </div>
229
+ </div>
230
+
231
  <!-- Multi-day selection info -->
232
  <div id="multi-day-info" class="fixed bottom-4 left-1/2 transform -translate-x-1/2 bg-white shadow-lg rounded-lg px-4 py-2 hidden">
233
  <span class="text-blue-800 font-medium">Sélection multiple activée - Sélectionnez plusieurs jours</span>
 
240
  <script>
241
  // Global variables
242
  let currentYear = 2025;
243
+ let currentMonth = 0; // January
244
+ let currentWeek = 0; // First week of the year
245
  let calendarData = {};
246
  let selectedDate = null;
247
  let multiDaySelection = false;
 
249
  let multiDayEnd = null;
250
  let currentUser = null;
251
  let isDragging = false;
252
+ let currentView = 'month'; // 'month' or 'week'
253
+ let selectedColor = 'red';
254
+ let selectedCategory = 'work';
255
 
256
  // Initialize the calendar
257
  document.addEventListener('DOMContentLoaded', function() {
258
  initializeCalendar();
259
  setupEventListeners();
260
  loadFromLocalStorage();
261
+ updateCurrentPeriodDisplay();
262
+ setupColorPickers();
263
  });
264
 
265
  function initializeCalendar() {
 
281
  }
282
 
283
  function renderCalendar() {
284
+ if (currentView === 'month') {
285
+ renderMonthView();
286
+ } else {
287
+ renderWeekView();
288
+ }
289
+ }
290
+
291
+ function renderMonthView() {
292
+ const container = document.getElementById('month-view');
293
  container.innerHTML = '';
294
 
 
 
295
  for (let month = 0; month < 12; month++) {
296
  const monthElement = document.createElement('div');
297
  monthElement.className = 'bg-white rounded-xl shadow-md overflow-hidden';
 
320
  }
321
  }
322
 
323
+ function renderWeekView() {
324
+ const weekContainer = document.getElementById('week-days');
325
+ weekContainer.innerHTML = '';
326
+
327
+ // Get the first day of the week
328
+ const firstDayOfWeek = getFirstDayOfWeek(currentYear, currentWeek);
329
+
330
+ // Render each day of the week
331
+ for (let i = 0; i < 7; i++) {
332
+ const dayDate = new Date(firstDayOfWeek);
333
+ dayDate.setDate(firstDayOfWeek.getDate() + i);
334
+
335
+ const year = dayDate.getFullYear();
336
+ const month = dayDate.getMonth();
337
+ const day = dayDate.getDate();
338
+ const dayOfWeek = dayDate.getDay();
339
+ const isWeekend = dayOfWeek === 0 || dayOfWeek === 6;
340
+
341
+ const dayElement = document.createElement('div');
342
+ dayElement.className = `week-view-day bg-white ${isWeekend ? 'bg-blue-50' : ''} p-2 relative`;
343
+ dayElement.dataset.year = year;
344
+ dayElement.dataset.month = month;
345
+ dayElement.dataset.day = day;
346
+
347
+ const dayName = dayDate.toLocaleString('fr-FR', { weekday: 'short' });
348
+ const formattedDate = dayDate.toLocaleDateString('fr-FR', { day: 'numeric', month: 'short' });
349
+
350
+ dayElement.innerHTML = `
351
+ <div class="flex justify-between items-start mb-1">
352
+ <div>
353
+ <span class="text-sm font-medium text-gray-500">${dayName}</span>
354
+ <span class="text-lg font-medium ${isWeekend ? 'text-blue-600' : 'text-gray-800'} ml-2">${formattedDate}</span>
355
+ </div>
356
+ <button class="add-task-btn text-blue-500 hover:text-blue-700 text-sm p-1 rounded-full transition">
357
+ <i class="fas fa-plus"></i>
358
+ </button>
359
+ </div>
360
+ <div class="tasks-container space-y-1 overflow-y-auto max-h-32">
361
+ ${renderTasks(year, month, day)}
362
+ </div>
363
+ `;
364
+
365
+ weekContainer.appendChild(dayElement);
366
+ }
367
+ }
368
+
369
+ function getFirstDayOfWeek(year, week) {
370
+ const date = new Date(year, 0, 1);
371
+ const dayOfWeek = date.getDay();
372
+ const firstDay = new Date(date);
373
+
374
+ // Adjust for Monday as first day of week
375
+ const diff = dayOfWeek === 0 ? 6 : dayOfWeek - 1;
376
+ firstDay.setDate(date.getDate() - diff);
377
+
378
+ // Add the weeks
379
+ firstDay.setDate(firstDay.getDate() + (week * 7));
380
+
381
+ return firstDay;
382
+ }
383
+
384
  function renderMonthDays(month) {
385
  const monthContainer = document.getElementById(`month-${month}`);
386
  const firstDay = new Date(currentYear, month, 1).getDay();
 
408
  dayElement.dataset.month = month;
409
  dayElement.dataset.day = day;
410
 
411
+ // Check if this day is today
412
+ const today = new Date();
413
+ if (date.getFullYear() === today.getFullYear() &&
414
+ date.getMonth() === today.getMonth() &&
415
+ date.getDate() === today.getDate()) {
416
+ dayElement.classList.add('border-2', 'border-blue-500');
417
+ }
418
+
419
  // Check if this day is part of a multi-day selection
420
  const isMultiDay = checkMultiDaySelection(currentYear, month, day);
421
  if (isMultiDay) {
 
443
  return '';
444
  }
445
 
446
+ return calendarData[year][month][day].map((task, index) => {
447
+ const colorClass = getColorClass(task.color);
448
+ return `
449
+ <div class="task-item ${colorClass} rounded px-2 py-1 text-sm flex justify-between items-center" data-index="${index}">
450
  <div>
451
+ ${task.time ? `<span class="font-medium">${task.time}</span> - ` : ''}
452
  <span>${task.text}</span>
453
  ${task.user ? `<span class="text-xs text-gray-500 ml-1">(${task.user})</span>` : ''}
454
  </div>
455
+ <button class="delete-task text-gray-600 hover:text-gray-800 text-xs p-1">
456
  <i class="fas fa-trash-alt"></i>
457
  </button>
458
  </div>
459
+ `;
460
+ }).join('');
461
+ }
462
+
463
+ function getColorClass(color) {
464
+ switch(color) {
465
+ case 'red': return 'bg-red-200';
466
+ case 'blue': return 'bg-blue-200';
467
+ case 'green': return 'bg-green-200';
468
+ case 'yellow': return 'bg-yellow-200';
469
+ case 'purple': return 'bg-purple-200';
470
+ default: return 'bg-blue-100';
471
+ }
472
  }
473
 
474
  function setupEventListeners() {
475
+ // Period navigation
476
+ document.getElementById('prev-period').addEventListener('click', () => {
477
+ if (currentView === 'month') {
478
+ if (currentYear > 2025 || (currentYear === 2025 && currentMonth > 0)) {
479
+ if (currentMonth === 0) {
480
+ currentYear--;
481
+ currentMonth = 11;
482
+ } else {
483
+ currentMonth--;
484
+ }
485
+ updateCurrentPeriodDisplay();
486
+ renderCalendar();
487
+ }
488
+ } else {
489
+ if (currentWeek > 0) {
490
+ currentWeek--;
491
+ } else {
492
+ currentYear--;
493
+ currentWeek = getWeeksInYear(currentYear) - 1;
494
+ }
495
+ updateCurrentPeriodDisplay();
496
+ renderCalendar();
497
+ }
498
+ });
499
+
500
+ document.getElementById('next-period').addEventListener('click', () => {
501
+ if (currentView === 'month') {
502
+ if (currentYear < 2030 || (currentYear === 2030 && currentMonth < 11)) {
503
+ if (currentMonth === 11) {
504
+ currentYear++;
505
+ currentMonth = 0;
506
+ } else {
507
+ currentMonth++;
508
+ }
509
+ updateCurrentPeriodDisplay();
510
+ renderCalendar();
511
+ }
512
+ } else {
513
+ const weeksInYear = getWeeksInYear(currentYear);
514
+ if (currentWeek < weeksInYear - 1) {
515
+ currentWeek++;
516
+ } else {
517
+ currentYear++;
518
+ currentWeek = 0;
519
+ }
520
+ updateCurrentPeriodDisplay();
521
  renderCalendar();
522
  }
523
  });
524
 
525
+ document.getElementById('today-btn').addEventListener('click', () => {
526
+ const today = new Date();
527
+ currentYear = today.getFullYear();
528
+ currentMonth = today.getMonth();
529
+
530
+ // Calculate current week for week view
531
+ const firstDayOfYear = new Date(currentYear, 0, 1);
532
+ const pastDaysOfYear = (today - firstDayOfYear) / 86400000;
533
+ currentWeek = Math.floor((pastDaysOfYear + firstDayOfYear.getDay() - 1) / 7);
534
+
535
+ updateCurrentPeriodDisplay();
536
+ renderCalendar();
537
+ });
538
+
539
+ // View switching
540
+ document.getElementById('month-view-btn').addEventListener('click', () => {
541
+ if (currentView !== 'month') {
542
+ currentView = 'month';
543
+ document.getElementById('month-view-btn').classList.remove('bg-blue-100', 'text-blue-800');
544
+ document.getElementById('month-view-btn').classList.add('bg-blue-600', 'text-white');
545
+ document.getElementById('week-view-btn').classList.remove('bg-blue-600', 'text-white');
546
+ document.getElementById('week-view-btn').classList.add('bg-blue-100', 'text-blue-800');
547
+
548
+ document.getElementById('month-view').classList.remove('hidden');
549
+ document.getElementById('week-view').classList.add('hidden');
550
+
551
+ updateCurrentPeriodDisplay();
552
+ renderCalendar();
553
+ }
554
+ });
555
+
556
+ document.getElementById('week-view-btn').addEventListener('click', () => {
557
+ if (currentView !== 'week') {
558
+ currentView = 'week';
559
+ document.getElementById('week-view-btn').classList.remove('bg-blue-100', 'text-blue-800');
560
+ document.getElementById('week-view-btn').classList.add('bg-blue-600', 'text-white');
561
+ document.getElementById('month-view-btn').classList.remove('bg-blue-600', 'text-white');
562
+ document.getElementById('month-view-btn').classList.add('bg-blue-100', 'text-blue-800');
563
+
564
+ document.getElementById('month-view').classList.add('hidden');
565
+ document.getElementById('week-view').classList.remove('hidden');
566
+
567
+ updateCurrentPeriodDisplay();
568
  renderCalendar();
569
  }
570
  });
 
572
  // Task modal
573
  document.addEventListener('click', function(e) {
574
  if (e.target.closest('.add-task-btn')) {
575
+ const dayElement = e.target.closest('.calendar-day, .week-view-day');
576
  selectedDate = {
577
  year: parseInt(dayElement.dataset.year),
578
  month: parseInt(dayElement.dataset.month),
 
590
 
591
  if (e.target.closest('.delete-task')) {
592
  const taskItem = e.target.closest('.task-item');
593
+ const dayElement = e.target.closest('.calendar-day, .week-view-day');
594
  const taskIndex = parseInt(taskItem.dataset.index);
595
 
596
  const year = parseInt(dayElement.dataset.year);
 
620
  const newTask = {
621
  text: taskText,
622
  time: taskTime || null,
623
+ user: currentUser ? currentUser.name : null,
624
+ color: selectedColor,
625
+ category: selectedCategory
626
  };
627
 
628
  calendarData[selectedDate.year][selectedDate.month][selectedDate.day].push(newTask);
 
678
  endMultiDaySelection();
679
  }
680
  });
681
+
682
+ // Search functionality
683
+ document.getElementById('search-btn').addEventListener('click', performSearch);
684
+ document.getElementById('clear-search').addEventListener('click', clearSearch);
685
+ document.getElementById('close-search-modal').addEventListener('click', () => {
686
+ document.getElementById('search-modal').classList.add('hidden');
687
+ });
688
+
689
+ // Allow pressing Enter in search input
690
+ document.getElementById('search-input').addEventListener('keypress', function(e) {
691
+ if (e.key === 'Enter') {
692
+ performSearch();
693
+ }
694
+ });
695
+ }
696
+
697
+ function setupColorPickers() {
698
+ const colorPickers = document.querySelectorAll('.color-picker');
699
+ colorPickers.forEach(picker => {
700
+ picker.addEventListener('click', function() {
701
+ // Remove selected class from all pickers
702
+ document.querySelectorAll('.color-picker').forEach(p => {
703
+ p.classList.remove('selected');
704
+ });
705
+
706
+ // Add selected class to clicked picker
707
+ this.classList.add('selected');
708
+
709
+ // Update selected color and category
710
+ selectedColor = this.dataset.color;
711
+ selectedCategory = this.dataset.category;
712
+ });
713
+ });
714
+ }
715
+
716
+ function updateCurrentPeriodDisplay() {
717
+ const periodElement = document.getElementById('current-period');
718
+
719
+ if (currentView === 'month') {
720
+ const monthName = new Date(currentYear, currentMonth, 1).toLocaleString('fr-FR', { month: 'long' });
721
+ const capitalizedMonthName = monthName.charAt(0).toUpperCase() + monthName.slice(1);
722
+ periodElement.textContent = `${capitalizedMonthName} ${currentYear}`;
723
+ } else {
724
+ const firstDayOfWeek = getFirstDayOfWeek(currentYear, currentWeek);
725
+ const lastDayOfWeek = new Date(firstDayOfWeek);
726
+ lastDayOfWeek.setDate(firstDayOfWeek.getDate() + 6);
727
+
728
+ const firstDayStr = firstDayOfWeek.toLocaleDateString('fr-FR', { day: 'numeric', month: 'short' });
729
+ const lastDayStr = lastDayOfWeek.toLocaleDateString('fr-FR', { day: 'numeric', month: 'short', year: 'numeric' });
730
+
731
+ periodElement.textContent = `Semaine du ${firstDayStr} au ${lastDayStr}`;
732
+ }
733
+ }
734
+
735
+ function getWeeksInYear(year) {
736
+ const firstDay = new Date(year, 0, 1);
737
+ const lastDay = new Date(year, 11, 31);
738
+
739
+ // Adjust for Monday as first day of week
740
+ const dayOffset = firstDay.getDay() === 0 ? 6 : firstDay.getDay() - 1;
741
+ firstDay.setDate(firstDay.getDate() - dayOffset);
742
+
743
+ const diff = lastDay - firstDay;
744
+ return Math.ceil(diff / (1000 * 60 * 60 * 24 * 7));
745
  }
746
 
747
  // Google Sign-In
 
1012
  function handleDayTouchEnd() {
1013
  isDragging = false;
1014
  }
1015
+
1016
+ // Search functions
1017
+ function performSearch() {
1018
+ const searchTerm = document.getElementById('search-input').value.trim().toLowerCase();
1019
+ const categoryFilter = document.getElementById('search-category').value;
1020
+
1021
+ if (!searchTerm && categoryFilter === 'all') {
1022
+ alert('Veuillez entrer un terme de recherche ou sélectionner une catégorie');
1023
+ return;
1024
+ }
1025
+
1026
+ const results = [];
1027
+
1028
+ // Search through all calendar data
1029
+ for (let year in calendarData) {
1030
+ for (let month in calendarData[year]) {
1031
+ for (let day in calendarData[year][month]) {
1032
+ const tasks = calendarData[year][month][day];
1033
+
1034
+ for (let task of tasks) {
1035
+ // Check if task matches search criteria
1036
+ const matchesText = searchTerm ? task.text.toLowerCase().includes(searchTerm) : true;
1037
+ const matchesCategory = categoryFilter === 'all' || task.category === categoryFilter;
1038
+
1039
+ if (matchesText && matchesCategory) {
1040
+ results.push({
1041
+ year: parseInt(year),
1042
+ month: parseInt(month),
1043
+ day: parseInt(day),
1044
+ task: task
1045
+ });
1046
+ }
1047
+ }
1048
+ }
1049
+ }
1050
+ }
1051
+
1052
+ displaySearchResults(results);
1053
+ }
1054
+
1055
+ function displaySearchResults(results) {
1056
+ const resultsContainer = document.getElementById('search-results');
1057
+ resultsContainer.innerHTML = '';
1058
+
1059
+ if (results.length === 0) {
1060
+ resultsContainer.innerHTML = '<p class="text-gray-600">Aucun résultat trouvé</p>';
1061
+ } else {
1062
+ results.forEach(result => {
1063
+ const dateStr = new Date(result.year, result.month, result.day)
1064
+ .toLocaleDateString('fr-FR', { weekday: 'long', day: 'numeric', month: 'long', year: 'numeric' });
1065
+
1066
+ const colorClass = getColorClass(result.task.color);
1067
+
1068
+ const resultElement = document.createElement('div');
1069
+ resultElement.className = `p-3 rounded-lg ${colorClass}`;
1070
+ resultElement.innerHTML = `
1071
+ <div class="flex justify-between items-start">
1072
+ <div>
1073
+ <h4 class="font-bold">${result.task.text}</h4>
1074
+ <p class="text-sm">${dateStr}${result.task.time ? ` à ${result.task.time}` : ''}</p>
1075
+ <p class="text-xs mt-1">Catégorie: ${result.task.category}</p>
1076
+ </div>
1077
+ <button class="delete-search-result text-gray-600 hover:text-gray-800 text-sm p-1"
1078
+ data-year="${result.year}" data-month="${result.month}" data-day="${result.day}" data-index="${calendarData[result.year][result.month][result.day].indexOf(result.task)}">
1079
+ <i class="fas fa-trash-alt"></i>
1080
+ </button>
1081
+ </div>
1082
+ `;
1083
+
1084
+ resultsContainer.appendChild(resultElement);
1085
+ });
1086
+
1087
+ // Add event listeners to delete buttons in search results
1088
+ document.querySelectorAll('.delete-search-result').forEach(btn => {
1089
+ btn.addEventListener('click', function() {
1090
+ const year = parseInt(this.dataset.year);
1091
+ const month = parseInt(this.dataset.month);
1092
+ const day = parseInt(this.dataset.day);
1093
+ const index = parseInt(this.dataset.index);
1094
+
1095
+ calendarData[year][month][day].splice(index, 1);
1096
+ saveToLocalStorage();
1097
+ performSearch(); // Refresh search results
1098
+ renderCalendar();
1099
+ });
1100
+ });
1101
+ }
1102
+
1103
+ document.getElementById('search-modal').classList.remove('hidden');
1104
+ }
1105
+
1106
+ function clearSearch() {
1107
+ document.getElementById('search-input').value = '';
1108
+ document.getElementById('search-category').value = 'all';
1109
+ document.getElementById('search-modal').classList.add('hidden');
1110
+ }
1111
  </script>
1112
  <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=johanpautrel/calendrier-interactif" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
1113
  </html>