From 2889de7f0c2d587a17fbd322af57c29e84238620 Mon Sep 17 00:00:00 2001 From: Hong-Phuc Bui <hong-phuc.bui@htwsaar.de> Date: Thu, 16 Jan 2025 12:22:14 +0100 Subject: [PATCH] update parcel --- calendar/src/lib/calendar-view.js | 39 ++++++++++++++++++++++++++++++++++++++- 1 files changed, 38 insertions(+), 1 deletions(-) diff --git a/calendar/src/lib/calendar-view.js b/calendar/src/lib/calendar-view.js index 0804662..adbd128 100644 --- a/calendar/src/lib/calendar-view.js +++ b/calendar/src/lib/calendar-view.js @@ -64,4 +64,41 @@ } htmlSegment += "</table>"; return htmlSegment; -} \ No newline at end of file +} + +export function verticalCalendar(calendar, location){ + const days = [ + [], + [], + [], + [], + [], + [], + [] + ]; + /* + 0 -> 1 + 1 -> 2 + 2 -> 3 + 3 -> 4 + 4 -> 5 + 5 -> 6 + 6 -> 0 + * */ + for(const [idx,day] of days.entries() ) { + const idxOfWeekdays = (idx + location.firstDayOfWeek) % 7; + const dayName = location.weekDays[idxOfWeekdays]; + day.push(`<td>${dayName}</td>`); + } + for(const week of calendar.weeks) { + for(const [idx, day] of week.entries() ) { + days[idx].push(`<td>${day}</td>`); + } + } + let cal = "<table>\n"; + for(const day of days) { + cal += "<tr>" + day.join("") + "</tr>\n" + } + cal += "</table>"; + return cal; +} -- Gitblit v1.10.0-SNAPSHOT