Skip to content

Commit

Permalink
Merge pull request #13 from MBAZA-NLP/calendar-events-branch
Browse files Browse the repository at this point in the history
Calendar events branch, The merge was agreed in our core meeting
  • Loading branch information
rutsam authored Oct 22, 2022
2 parents 1ffea27 + 482b5a5 commit ea7a704
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 57 deletions.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
74 changes: 74 additions & 0 deletions assets/js/calendar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
(function($){
const username = "[email protected]";
const key = "AIzaSyBxDGuEdlEgMyPbyjNjymNwI10vSdByrhs";
function injectCalendarEvents(title, uri, location, date, time) {
return `
<li>
<div class="post d-sm-flex align-items-center mb-20">
<div class="post__img mr-20">
<!-- <img src="assets/img/blog/14.jpg" alt="" /> -->
</div>
<div class="post__text">
<h5><a href="${uri}">${title}</a></h5>
<span><i class="far fa-map-marker-alt"></i> ${location}</span> <br />
<span><i class="far fa-calendar-alt"></i> ${date}</span> <br />
<span><i class="far fa-watch"></i> ${time}</span>
</div>
</div>
</li>
`;
}
function getDate(time) {
return time === undefined ? "" : "<b>" + time.split("T")[0] + "</b>";
}
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
? "<i>Pending</i>"
: 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);
60 changes: 3 additions & 57 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -353,63 +353,7 @@ <h5>Gallery</h5>

<div class="widget white-bg mb-40 pb-10 wow fadeInUp2 animated" data-wow-delay='.1s' id="events-section">
<h4 class="widget-title pt-40 mb-40 pl-35">Up Coming events</h4>
<ul class="post-list">
<li>
<div class="post d-sm-flex align-items-center mb-20">
<div class="post__img mr-20">
<img src="assets/img/blog/14.jpg" alt="">
</div>
<div class="post__text">
<h5><a href="#">Smaing Podcast Epis
Ode 15 With Phile</a></h5>
<span><i class="far fa-map-marker-alt"></i> Location</span> <br>
<span><i class="far fa-calendar-alt"></i> Date</span> <br>
<span><i class="far fa-watch"></i> Time</span>
</div>
</div>
</li>
<li>
<div class="post d-sm-flex align-items-center mb-20">
<div class="post__img mr-20">
<img src="assets/img/blog/15.jpg" alt="">
</div>
<div class="post__text">
<h5><a href="#">Epis Smaing Podcast
Ode 15 With Phile</a></h5>
<span><i class="far fa-map-marker-alt"></i> Location</span> <br>
<span><i class="far fa-calendar-alt"></i> Date</span> <br>
<span><i class="far fa-watch"></i> Time</span>
</div>
</div>
</li>
<li>
<div class="post d-sm-flex align-items-center mb-20">
<div class="post__img mr-20">
<img src="assets/img/blog/16.jpg" alt="">
</div>
<div class="post__text">
<h5><a href="#">Phile Podcast Smaing Epis
Ode 15 With </a></h5>
<span><i class="far fa-map-marker-alt"></i> Location</span> <br>
<span><i class="far fa-calendar-alt"></i> Date</span> <br>
<span><i class="far fa-watch"></i> Time</span>
</div>
</div>
</li>
<li>
<div class="post d-sm-flex align-items-center mb-20">
<div class="post__img mr-20">
<img src="assets/img/blog/17.jpg" alt="">
</div>
<div class="post__text">
<h5><a href="#">Smaing Podcast Epis
Ode 15 With Phile</a></h5>
<span><i class="far fa-map-marker-alt"></i> Location</span> <br>
<span><i class="far fa-calendar-alt"></i> Date</span> <br>
<span><i class="far fa-watch"></i> Time</span>
</div>
</div>
</li>
<ul class="post-list" id="calendar-post-list">
</ul>
</div>
</div>
Expand Down Expand Up @@ -599,6 +543,8 @@ <h5 class="semi-title mb-25">Follow Us</h5>
<script src="assets/js/plugins.js"></script>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
<script src="assets/js/main.js"></script>
<script src="assets/js/calendar.js"></script>

</body>

</html>

0 comments on commit ea7a704

Please sign in to comment.