// // Vex modals // /* global vex, fetch, Clipboard, QRious */ /* exported krlcModals */ /* eslint-disable spaced-comment */ //=require vex-js/dist/js/vex.combined.js //=require clipboard/dist/clipboard.js //=require qrious/dist/qrious.js /* eslint-enable spaced-comment */ const krlcModals = (() => { // eslint-disable-line no-unused-vars const _config = { btcVexTriggers: document.querySelectorAll('.js-vex-btc') } let btcAddress let ethAddress const _private = { getBtcAddress() { const url = '/api/site.json' fetch(url) .then(res => res.json()) .then(data_ => { btcAddress = data_[0].author.bitcoin ethAddress = data_[0].author.ether }) .catch(err => console.error(err)) return {btcAddress, ethAddress} }, vexBtc() { _config.btcVexTriggers.forEach(el => { el.addEventListener('click', e => { e.preventDefault() vex.defaultOptions.className = 'vex-theme-kremalicious vex-bitcoin' vex.dialog.buttons.YES.text = 'Close' vex.open({unsafeContent: `

Say thanks

Bitcoin

${btcAddress}

Ethereum

${ethAddress}
` }) // Generate QR code const qrBtc = new QRious({ element: document.getElementById('qr-btc'), value: btcAddress }) const qrEth = new QRious({ element: document.getElementById('qr-eth'), value: ethAddress }) qrBtc.backgroundAlpha = 0 qrEth.backgroundAlpha = 0 qrBtc.foreground = '#6b7f88' qrEth.foreground = '#6b7f88' qrBtc.size = 160 qrEth.size = 160 // Clipboard button const clipboard = new Clipboard('.btn') clipboard.on('success', e => { e.trigger.classList.add('success') e.clearSelection() }) }) }) } } return { init() { _private.getBtcAddress() _private.vexBtc() } } })(); // eslint-disable-line semi