-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
38 lines (33 loc) · 1.13 KB
/
app.js
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
document.querySelector(".menu-hamburger").addEventListener(
"click", function() { toggleVisibility(".menu-nav"); });
function toggleVisibility(selector) {
var element = document.querySelector(selector);
if(element.style.display == "block") {
element.style.display = "none";
} else {
element.style.display = "block";
}
}
function meetupLinks() {
return document.querySelectorAll('[data-meetup-event]');
}
function updateMeetupDetails(jsonp) {
var meetupURL = jsonp.data[0].link;
var options = { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' };
var date = new Date(jsonp.data[0].time)
var meetupDate = date.toLocaleDateString('it-IT', options);
var meetupPlaceholders = meetupLinks();
for (var i in meetupPlaceholders ) {
meetupPlaceholders[i].innerHTML = meetupDate;
meetupPlaceholders[i].href = meetupURL;
}
}
function getMeetupData() {
if (meetupLinks().length == 0) {
return;
}
var script = document.createElement('script');
script.src = 'http://api.meetup.com/turn-into-coders/events' + '?callback=updateMeetupDetails';
document.getElementsByTagName('body')[0].appendChild(script);
}
getMeetupData();