1
0
mirror of https://github.com/bigchaindb/site.git synced 2024-11-23 02:00:18 +01:00
site/_src/_assets/javascripts/bigchain/meetup.js

40 lines
1.2 KiB
JavaScript

document.addEventListener('DOMContentLoaded', function() {
const url = 'https://bigchaindb-meetups.now.sh'
function injectData(data) {
const events = data
// just grab the first item of array
const nextEvent = events[0]
const element = document.getElementsByClassName('js-social-link--meetup')[0]
if (nextEvent) {
const name = nextEvent.name
const link = nextEvent.link
const date = new Date(nextEvent.time).toLocaleDateString('en-us', {
month: 'short',
day: 'numeric'
})
const elementTitle = document.getElementsByClassName('meetup-title')[0]
elementTitle.innerHTML = `<span class="hero__community__label">${date}</span><strong>${name}</strong>`
elementTitle.style.opacity = 1
element.href = link
} else {
element.classList.add('hide')
}
}
fetch(url)
.then(function(response) {
return response.json()
})
.then(function(data) {
injectData(data)
})
.catch(function(error) {
console.log(error)
})
})