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

34 lines
1.1 KiB
JavaScript
Raw Normal View History

//require whatwg-fetch/fetch.js
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 name = nextEvent.name
const link = nextEvent.link
const date = new Date(nextEvent.time).toLocaleDateString('en-us', { month: 'short', day: 'numeric' })
const element = document.getElementsByClassName('js-social-link--meetup')[0]
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
}
fetch(url)
.then(function(response) {
return response.json()
})
.then(function(data) {
injectData(data)
})
.catch(function(error) {
console.log(error)
})
})