From 9b1430a11921893318532eab4e556d10d871d5ff Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Tue, 20 Apr 2021 13:47:48 +0100 Subject: [PATCH] launch price check on start --- .../copilot/templates/copilot/compose.html | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/lnbits/extensions/copilot/templates/copilot/compose.html b/lnbits/extensions/copilot/templates/copilot/compose.html index 1b17140c..62c6b86d 100644 --- a/lnbits/extensions/copilot/templates/copilot/compose.html +++ b/lnbits/extensions/copilot/templates/copilot/compose.html @@ -124,29 +124,34 @@ }) } }, + getPrice: function () { + self = this + if ('{{ copilot.show_price }}' != 'None') { + LNbits.api + .request('GET', 'https://api.opennode.com/v1/rates', 'filla') + .then(function (response) { + self.price = String( + new Intl.NumberFormat('en-US', { + style: 'currency', + currency: 'USD' + }).format(response.data.data.BTCUSD.USD) + ) + console.log(self.price) + }) + .catch(function (error) { + LNbits.utils.notifyApiError(error) + }) + } + }, animation1: function () { self = this + self.getPrice setTimeout(function () { setInterval(function () { self.connection.send('') self.counter++ if (self.counter % 20 === 0) { - if ('{{ copilot.show_price }}' != 'None') { - LNbits.api - .request('GET', 'https://api.opennode.com/v1/rates', 'filla') - .then(function (response) { - self.price = String( - new Intl.NumberFormat('en-US', { - style: 'currency', - currency: 'USD' - }).format(response.data.data.BTCUSD.USD) - ) - console.log(self.price) - }) - .catch(function (error) { - LNbits.utils.notifyApiError(error) - }) - } + self.getPrice } }, 1000) }, 2000)