From acb6bf0ed46de9b1e2013ed2f3d7f74f65d564bd Mon Sep 17 00:00:00 2001 From: Kira-Floris Date: Sat, 15 Oct 2022 11:42:36 +0200 Subject: [PATCH 1/3] adding google calendar events --- .vscode/settings.json | 3 ++ assets/js/calendar.js | 73 +++++++++++++++++++++++++++++++++++++++++++ index.html | 60 ++--------------------------------- 3 files changed, 79 insertions(+), 57 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 assets/js/calendar.js diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6f3a291 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/assets/js/calendar.js b/assets/js/calendar.js new file mode 100644 index 0000000..220005a --- /dev/null +++ b/assets/js/calendar.js @@ -0,0 +1,73 @@ +(function($){ + function injectCalendarEvents(title, uri, location, date, time) { + return ` +
  • +
    +
    + +
    +
    +
    ${title}
    + ${location}
    + ${date}
    + ${time} +
    +
    +
  • + `; + } + function getDate(time) { + return time === undefined ? "" : "" + time.split("T")[0] + ""; + } + function getTime(time) { + return time === undefined ? "" : time.split("T")[1]; + } + function undefinedCase(text) { + return text === undefined ? "" : text; + } + function getTodayDate() { + var date = new Date(); + return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`; + } + $(window).on('load',async function () { + const username = ""; + const key = ""; + $.ajax({ + url: + "https://www.googleapis.com/calendar/v3/calendars/" + + username + + "/events?key=" + + key + + "&singleEvents=true&orderBy=startTime&timeMin=" + + getTodayDate() + + "T00:00:00.000Z", + success: await function (data) { + var calendarUl = document.getElementById("calendar-post-list"); + let htmlCode = ``; + data.items.forEach(function (item) { + item.summary === undefined + ? "" + : (htmlCode = + htmlCode + + injectCalendarEvents( + item.summary, + undefinedCase(item.htmlLink), + undefinedCase(item.location), + item.start.dateTime === undefined + ? "Pending" + : getDate(item.start.dateTime) + + " to " + + getDate(item.end.dateTime), + getTime(item.start.dateTime) + + " " + + undefinedCase(item.start.timeZone) + )); + }); + calendarUl.innerHTML = htmlCode; + }, + error: function (err) { + console.log(err); + }, + }); + }); +})(jQuery); \ No newline at end of file diff --git a/index.html b/index.html index 98c34f9..c10d65c 100644 --- a/index.html +++ b/index.html @@ -353,63 +353,7 @@
    Gallery

    Up Coming events

    -
    @@ -599,6 +543,8 @@
    Follow Us
    + + From 9e7e331eb18d9a77586d399524b645520a8efcc7 Mon Sep 17 00:00:00 2001 From: Kira-Floris Date: Sat, 15 Oct 2022 12:52:39 +0200 Subject: [PATCH 2/3] changing location for calendar credentials --- assets/js/calendar.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/assets/js/calendar.js b/assets/js/calendar.js index 220005a..9a72788 100644 --- a/assets/js/calendar.js +++ b/assets/js/calendar.js @@ -1,4 +1,6 @@ (function($){ + const username = ""; + const key = ""; function injectCalendarEvents(title, uri, location, date, time) { return `
  • @@ -30,8 +32,7 @@ return `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`; } $(window).on('load',async function () { - const username = ""; - const key = ""; + $.ajax({ url: "https://www.googleapis.com/calendar/v3/calendars/" + From 482b5a5e145950b9741dc72be5ce8b5dda8130ac Mon Sep 17 00:00:00 2001 From: Kira-Floris Date: Sat, 15 Oct 2022 16:08:36 +0200 Subject: [PATCH 3/3] adding google calendar api keys for mbaza --- assets/js/calendar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/js/calendar.js b/assets/js/calendar.js index 9a72788..94c6676 100644 --- a/assets/js/calendar.js +++ b/assets/js/calendar.js @@ -1,6 +1,6 @@ (function($){ - const username = ""; - const key = ""; + const username = "mbazanlp.community@gmail.com"; + const key = "AIzaSyBxDGuEdlEgMyPbyjNjymNwI10vSdByrhs"; function injectCalendarEvents(title, uri, location, date, time) { return `