2017-09-09 19:22:04 +02:00
|
|
|
//
|
|
|
|
// Vex modals
|
|
|
|
//
|
|
|
|
|
2017-09-09 21:20:59 +02:00
|
|
|
/* global vex, fetch */
|
2017-09-09 19:22:04 +02:00
|
|
|
/* exported krlcModals */
|
|
|
|
|
|
|
|
/* eslint-disable spaced-comment */
|
|
|
|
//=require vex-js/dist/js/vex.combined.js
|
|
|
|
/* eslint-enable spaced-comment */
|
|
|
|
|
|
|
|
const krlcModals = (() => { // eslint-disable-line no-unused-vars
|
|
|
|
const _config = {
|
2017-09-09 21:20:59 +02:00
|
|
|
btcVexTriggers: document.querySelectorAll('.js-vex-btc')
|
2017-09-09 19:22:04 +02:00
|
|
|
}
|
|
|
|
|
2017-09-09 21:20:59 +02:00
|
|
|
let btcAddress
|
|
|
|
|
2017-09-09 19:22:04 +02:00
|
|
|
const _private = {
|
2017-09-09 21:20:59 +02:00
|
|
|
getBtcAddress() {
|
|
|
|
const url = '/api/site.json'
|
|
|
|
|
|
|
|
fetch(url)
|
|
|
|
.then(res => res.json())
|
|
|
|
.then(data_ => {
|
|
|
|
btcAddress = data_[0].author.bitcoin
|
|
|
|
})
|
|
|
|
.catch(err => console.error(err))
|
|
|
|
|
|
|
|
return btcAddress
|
|
|
|
},
|
|
|
|
|
|
|
|
vexBtc() {
|
|
|
|
_config.btcVexTriggers.forEach(el => {
|
2017-09-09 19:22:04 +02:00
|
|
|
el.addEventListener('click', e => {
|
|
|
|
e.preventDefault()
|
|
|
|
|
|
|
|
vex.defaultOptions.className = 'vex-theme-kremalicious vex-bitcoin'
|
|
|
|
vex.dialog.buttons.YES.text = 'Close'
|
2017-09-09 21:20:59 +02:00
|
|
|
vex.open({unsafeContent: '<h3 class="vex__title">My Bitcoin Address</h3>\n <img src="/assets/img/btc-qr.png" />\n <pre class="highlight"><a href="bitcoin:' + btcAddress + '"><code class="btcAddress nt">' + btcAddress + '</code></a></pre>'})
|
|
|
|
})
|
2017-09-09 19:22:04 +02:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
2017-09-09 21:20:59 +02:00
|
|
|
init() {
|
|
|
|
_private.getBtcAddress()
|
|
|
|
_private.vexBtc()
|
|
|
|
}
|
2017-09-09 19:22:04 +02:00
|
|
|
}
|
|
|
|
})(); // eslint-disable-line semi
|