-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
473 lines (407 loc) · 14.6 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
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
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Social Media Management Calendar</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
flex-direction: column;
align-items: center;
}
.calendar {
width: 100%;
max-width: 1200px;
margin: 20px;
}
.calendar-header {
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
background-color: #f0f0f0;
border-bottom: 1px solid #ccc;
}
.calendar-header div {
display: flex;
align-items: center;
}
.calendar-header div button,
.calendar-header div select {
margin: 0 5px;
padding: 5px 10px;
border: 1px solid #ccc;
background-color: #fff;
cursor: pointer;
}
.calendar-header div select.active {
background-color: rgb(241, 158, 14);
color: white;
border-radius: 10px;
height: 37px;
}
.calendar-grid {
display: grid;
grid-template-columns: repeat(7, 1fr);
grid-auto-rows: 120px;
gap: 1px;
}
.calendar-grid div {
position: relative;
background-color: #f9f9f9;
border: 1px solid #ccc;
padding: 5px;
cursor: pointer;
}
.calendar-grid div .date {
position: absolute;
top: 5px;
right: 5px;
font-size: 14px;
}
.calendar-grid div .month-name {
position: absolute;
top: 5px;
left: 5px;
font-size: 30px; /* Increased font size */
font-weight: bold;
color: #000000;
}
.calendar-grid div .platform-name {
position: absolute;
bottom: 10px;
left: 5px;
font-size: 12px; /* Adjusted font size */
color: #333;
}
.calendar-grid div .platform-names {
position: absolute;
bottom: 10px;
top: 8px;
border: none;
left: 30px;
font-weight: bold;
font-size: 12px; /* Adjusted font size */
color: #333;
background-color: rgb(252, 227, 211);
}
.calendar-grid div .red-dot {
position: absolute;
bottom: 5px;
left: 50%;
width: 6px;
height: 6px;
background-color: red;
border-radius: 50%;
transform: translateX(-50%);
}
.post {
margin-top: 20px;
background-color: #e0f7fa;
padding: 5px;
border-radius: 3px;
cursor: pointer;
}
.popup {
display: none;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
padding: 20px;
background-color: white;
border: 1px solid #ccc;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
max-height: 80%;
overflow-y: auto;
width: 300px;
}
.popup button {
padding: 5px 10px;
margin-top: 10px;
}
.days-header {
display: grid;
grid-template-columns: repeat(7, 1fr);
text-align: center;
background-color: #e0e0e0;
padding: 10px 0;
}
.year-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 20px;
padding: 20px;
}
.month-card {
border: 1px solid #ccc;
padding: 10px;
background-color: #fff;
}
.month-card h3 {
text-align: center;
margin: 0;
margin-bottom: 10px;
}
.month-card .calendar-grid {
grid-auto-rows: 50px;
}
.scheduled-posts {
top: 60%;
display: flex;
align-items: center;
height: 30px;
background-color: rgb(252, 227, 211) !important;
color: white;
padding: 2px 5px;
border-radius: 3px;
}
.scheduled-posts img {
width: 20px;
height: 20px;
margin-right: 5px;
}
#monthYearDisplay {
font-weight: bold;
}
</style>
</head>
<body>
<div class="calendar">
<div class="calendar-header">
<div>
<span id="monthYearDisplay">June 2024</span>
</div>
<div>
<button id="prevBtn">Back</button>
<div>
<select id="monthViewSelect" class="active">
<option value="1" selected>Today</option>
<option value="1">1 Month</option>
<option value="2">2 Months</option>
<option value="3">3 Months</option>
<option value="4">4 Months</option>
<option value="5">5 Months</option>
<option value="6">6 Months</option>
<option value="7">7 Months</option>
<option value="8">8 Months</option>
<option value="9">9 Months</ </option>
<option value="10">10 Months</option>
<option value="11">11 Months</option>
<option value="12">1 Year</option>
</select>
</div>
<button id="nextBtn">Next</button>
</div>
</div>
<div class="days-header" id="daysHeader">
<div>Sunday</div>
<div>Monday</div>
<div>Tuesday</div>
<div>Wednesday</div>
<div>Thursday</div>
<div>Friday</div>
<div>Saturday</div>
</div>
<div class="calendar-grid" id="calendarGrid">
<!-- Calendar dates will be injected here -->
</div>
<div class="year-grid" id="yearGrid">
<!-- Yearly view months will be injected here -->
</div>
</div>
<div class="popup" id="popup">
<h3>Posts</h3>
<div id="popupContent">
<!-- Post details will be injected here -->
</div>
<button id="closeBtn">Close</button>
</div>
<script>
const calendarGrid = document.getElementById('calendarGrid');
const monthYearDisplay = document.getElementById('monthYearDisplay');
const popup = document.getElementById('popup');
const popupContent = document.getElementById('popupContent');
const closeBtn = document.getElementById('closeBtn');
const monthViewSelect = document.getElementById('monthViewSelect');
const daysHeader = document.getElementById('daysHeader');
const yearGrid = document.getElementById('yearGrid');
const posts = [
{ date: '2024-06-11', title: 'LinkedIn Post 1', platform: 'LinkedIn' },
{ date: '2024-06-19', title: 'Instagram Post 2', platform: 'Instagram' },
{ date: '2024-06-23', title: 'Instagram Post 3', platform: 'Twitter' }
// Add more posts for testing, including posts on different platforms and dates
];
const currentDate = new Date();
let selectedDate = currentDate;
let isYearView = false;
let monthsToShow = 1;
function renderCalendar() {
const year = selectedDate.getFullYear();
const month = selectedDate.getMonth();
// Calculate start and end dates for display
const startDate = new Date(year, month);
const endDate = new Date(year, month + monthsToShow - 1);
// Format start and end month-year for display
const startMonthYear = startDate.toLocaleString('default', { month: 'long', year: 'numeric' });
const endMonthYear = endDate.toLocaleString('default', { month: 'long', year: 'numeric' });
// Set display text
monthYearDisplay.textContent = `${startMonthYear} - ${endMonthYear}`;
calendarGrid.innerHTML = '';
yearGrid.innerHTML = '';
daysHeader.style.display = isYearView ? 'none' : 'grid';
calendarGrid.style.display = isYearView ? 'none' : 'grid';
yearGrid.style.display = isYearView ? 'grid' : 'none';
if (isYearView) {
renderYearView(year);
} else {
renderMultiMonthView(year, month);
}
}
function renderMultiMonthView(year, startMonth) {
const firstDayOfFirstMonth = new Date(year, startMonth, 1);
const firstDayIndex = firstDayOfFirstMonth.getDay();
const totalDays = [];
for (let month = startMonth; month < startMonth + monthsToShow; month++) {
const lastDayOfMonth = new Date(year, month + 1, 0).getDate();
for (let day = 1; day <= lastDayOfMonth; day++) {
totalDays.push(new Date(year, month, day));
}
}
const rows = Math.ceil((firstDayIndex + totalDays.length) / 7) * 7;
for (let i = 0; i < rows; i++) {
if (i < firstDayIndex) {
calendarGrid.appendChild(document.createElement('div'));
} else {
const date = totalDays[i - firstDayIndex];
const dateCell = createDateCell(date);
calendarGrid.appendChild(dateCell);
}
}
}
function renderYearView(year) {
for (let month = 0; month < 12; month++) {
const monthCard = document.createElement('div');
monthCard.classList.add('month-card');
monthCard.innerHTML = `<h3>${new Date(year, month).toLocaleString('default', { month: 'long' })}</h3>`;
const daysHeaderClone = daysHeader.cloneNode(true);
monthCard.appendChild(daysHeaderClone);
const calendarGridClone = document.createElement('div');
calendarGridClone.classList.add('calendar-grid');
monthCard.appendChild(calendarGridClone);
const firstDayOfMonth = new Date(year, month, 1);
const lastDayOfMonth = new Date(year, month + 1, 0);
const firstDayIndex = firstDayOfMonth.getDay();
const lastDayIndex = lastDayOfMonth.getDate();
for (let i = 0; i < firstDayIndex; i++) {
const emptyCell = document.createElement('div');
calendarGridClone.appendChild(emptyCell);
}
for (let day = 1; day <= lastDayIndex; day++) {
const date = new Date(year, month, day);
const dateCell = createDateCell(date, year, month);
calendarGridClone.appendChild(dateCell);
}
yearGrid.appendChild(monthCard);
}
}
function createDateCell(date) {
const dateCell = document.createElement('div');
dateCell.style.border = '1px solid #ccc'; // Add border for visibility
const day = date.getDate();
const monthName = date.toLocaleString('default', { month: 'short' });
dateCell.innerHTML = `<span class="date">${day}</span>`;
if (day === 1 && !isYearView) {
const monthLabel = document.createElement('span');
monthLabel.classList.add('month-name');
monthLabel.textContent = monthName;
dateCell.appendChild(monthLabel);
}
const dateStr = `${date.getFullYear()}-${(date.getMonth() + 1).toString().padStart(2, '0')}-${date.getDate().toString().padStart(2, '0')}`;
const datePosts = posts.filter(p => p.date === dateStr);
if (monthsToShow === 1) {
const platforms = new Set();
datePosts.forEach(post => {
platforms.add(post.platform);
});
platforms.forEach(platform => {
const platformName = document.createElement('div');
platformName.classList.add('platform-name');
platformName.textContent = platform;
dateCell.appendChild(platformName);
});
} else if (monthsToShow >= 2 && monthsToShow <= 11) {
if (datePosts.length > 0) {
const scheduledPostsDiv = document.createElement('div');
scheduledPostsDiv.classList.add('scheduled-posts');
const iconImg = document.createElement('img');
iconImg.src = 'https://icones.pro/wp-content/uploads/2021/06/icone-d-image-orange.png';
iconImg.alt = 'Icon';
const scheduledText = document.createElement('div');
scheduledText.classList.add('platform-names');
scheduledText.textContent = '+9 Posts';
scheduledPostsDiv.appendChild(iconImg);
scheduledPostsDiv.appendChild(scheduledText);
dateCell.appendChild(scheduledPostsDiv);
// Log the newly created element
console.log('Scheduled posts div created:', scheduledPostsDiv);
}
} else if (monthsToShow === 12 && datePosts.length > 0) {
const redDot = document.createElement('div');
redDot.classList.add('red-dot');
dateCell.appendChild(redDot);
}
dateCell.onclick = () => openPopup(dateStr);
return dateCell;
}
function openPopup(dateStr) {
popup.style.display = 'block';
popupContent.innerHTML = '';
const datePosts = posts.filter(p => p.date === dateStr);
datePosts.forEach(post => {
const postDiv = document.createElement('div');
postDiv.classList.add('post');
postDiv.textContent = `${post.title} (${post.platform})`;
postDiv.onclick = () => navigateToPostDetails(post);
popupContent.appendChild(postDiv);
});
}
function navigateToPostDetails(post) {
alert(`Navigating to details for post: ${post.title}`);
}
function closePopup() {
popup.style.display = 'none';
}
document.getElementById('prevBtn').onclick = () => {
if (isYearView) {
selectedDate.setFullYear(selectedDate.getFullYear() - 1);
} else {
selectedDate.setMonth(selectedDate.getMonth() - monthsToShow);
}
renderCalendar();
};
document.getElementById('nextBtn').onclick = () => {
if (isYearView) {
selectedDate.setFullYear(selectedDate.getFullYear() + 1);
} else {
selectedDate.setMonth(selectedDate.getMonth() + monthsToShow);
}
renderCalendar();
};
monthViewSelect.onchange = () => {
isYearView = false;
monthsToShow = parseInt(monthViewSelect.value);
if (monthsToShow === 12) {
isYearView = true;
}
renderCalendar();
};
closeBtn.onclick = closePopup;
renderCalendar();
</script>
</body>
</html>