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..94c6676 --- /dev/null +++ b/assets/js/calendar.js @@ -0,0 +1,74 @@ +(function($){ + const username = "mbazanlp.community@gmail.com"; + const key = "AIzaSyBxDGuEdlEgMyPbyjNjymNwI10vSdByrhs"; + 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 () { + + $.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
    + +