From 9267aba6d98f46219b25241ad030745346b62470 Mon Sep 17 00:00:00 2001 From: Ben Arc Date: Wed, 23 Jun 2021 22:31:44 +0100 Subject: [PATCH] Used prettier --- .../copilot/templates/copilot/compose.html | 193 +++++++++--------- .../copilot/templates/copilot/index.html | 53 +++-- .../copilot/templates/copilot/panel.html | 5 +- package-lock.json | 28 ++- 4 files changed, 159 insertions(+), 120 deletions(-) diff --git a/lnbits/extensions/copilot/templates/copilot/compose.html b/lnbits/extensions/copilot/templates/copilot/compose.html index 148ef93e4..d24dbf7f2 100644 --- a/lnbits/extensions/copilot/templates/copilot/compose.html +++ b/lnbits/extensions/copilot/templates/copilot/compose.html @@ -135,18 +135,23 @@ console.log('Something went wrong!') }) }, - pushAnim(content){ + pushAnim(content) { document.getElementById('animations').style.width = content[0] document.getElementById('animations').src = content[1] - setTimeout(function(){ document.getElementById('animations').src = '' }, 5000) + setTimeout(function () { + document.getElementById('animations').src = '' + }, 5000) }, - launch(){ + launch() { self = this - console.log("poo") + console.log('poo') LNbits.api .request( 'GET', - '/copilot/api/v1/copilot/ws/' + self.copilot.id + '/launching/rocket') + '/copilot/api/v1/copilot/ws/' + + self.copilot.id + + '/launching/rocket' + ) .then(function (response1) { self.$q.notify({ color: 'green', @@ -156,7 +161,7 @@ .catch(err => { LNbits.utils.notifyApiError(err) }) - }, + } }, mounted() { this.initCamera() @@ -168,9 +173,8 @@ LNbits.api .request( 'GET', - '/copilot/api/v1/copilot/' + - self.copilot.id, - localStorage.getItem('inkey') + '/copilot/api/v1/copilot/' + self.copilot.id, + localStorage.getItem('inkey') ) .then(function (response) { self.copilot = response.data @@ -178,108 +182,113 @@ .catch(err => { LNbits.utils.notifyApiError(err) }) - - this.connectionBitStamp = new WebSocket('wss://ws.bitstamp.net') - const obj = JSON.stringify({ - event: "bts:subscribe", - data: { channel: "live_trades_" + self.copilot.show_price}, - }) + this.connectionBitStamp = new WebSocket('wss://ws.bitstamp.net') - this.connectionBitStamp.onmessage = function (e) { - console.log(JSON.parse(e.data).data.price) - console.log(self.copilot) - if(self.copilot.show_price){ - if(self.copilot.show_price == "btcusd"){ - self.price = String( - new Intl.NumberFormat('en-US', { + const obj = JSON.stringify({ + event: 'bts:subscribe', + data: {channel: 'live_trades_' + self.copilot.show_price} + }) + + this.connectionBitStamp.onmessage = function (e) { + console.log(JSON.parse(e.data).data.price) + console.log(self.copilot) + if (self.copilot.show_price) { + if (self.copilot.show_price == 'btcusd') { + self.price = String( + new Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' - }).format(JSON.parse(e.data).data.price) - ) - } - else if(self.copilot.show_price == "btceur"){ - self.price = String( - new Intl.NumberFormat('en-US', { + }).format(JSON.parse(e.data).data.price) + ) + } else if (self.copilot.show_price == 'btceur') { + self.price = String( + new Intl.NumberFormat('en-US', { style: 'currency', currency: 'EUR' - }).format(JSON.parse(e.data).data.price) - ) - } - else if(self.copilot.show_price == "btcgbp"){ - self.price = String( - new Intl.NumberFormat('en-US', { + }).format(JSON.parse(e.data).data.price) + ) + } else if (self.copilot.show_price == 'btcgbp') { + self.price = String( + new Intl.NumberFormat('en-US', { style: 'currency', currency: 'GBP' - }).format(JSON.parse(e.data).data.price) - ) - } + }).format(JSON.parse(e.data).data.price) + ) } } - this.connectionBitStamp.onopen = () => this.connectionBitStamp.send(obj) - - const fetch = (data) => new Promise(resolve => setTimeout(resolve, 5000, this.pushAnim(data))) + } + this.connectionBitStamp.onopen = () => this.connectionBitStamp.send(obj) - const addTask = (() => { - let pending = Promise.resolve(); - const run = async (data) => { - try { - await pending; - } finally { - return fetch(data); - } + const fetch = data => + new Promise(resolve => setTimeout(resolve, 5000, this.pushAnim(data))) + + const addTask = (() => { + let pending = Promise.resolve() + const run = async data => { + try { + await pending + } finally { + return fetch(data) } - return (data) => (pending = run(data)) - })(); + } + return data => (pending = run(data)) + })() if (location.protocol !== 'http:') { - localUrl = 'wss://' + - document.domain + - ':' + - location.port + - '/copilot/ws/' + self.copilot.id + '/' + localUrl = + 'wss://' + + document.domain + + ':' + + location.port + + '/copilot/ws/' + + self.copilot.id + + '/' } else { - localUrl = 'ws://' + - document.domain + - ':' + - location.port + - '/copilot/ws/' + self.copilot.id + '/' + localUrl = + 'ws://' + + document.domain + + ':' + + location.port + + '/copilot/ws/' + + self.copilot.id + + '/' } this.connection = new WebSocket(localUrl) this.connection.onmessage = function (e) { - console.log(e.data) - res = e.data.split('-') - if (res[0] == 'rocket') { - addTask(['40%', '/copilot/static/rocket.gif']) - } - if (res[0] == 'face') { - addTask(['35%', '/copilot/static/face.gif']) - } - if (res[0] == 'bitcoin') { - addTask(['30%', '/copilot/static/bitcoin.gif']) - } - if (res[0] == 'confetti') { - addTask(['100%', '/copilot/static/confetti.gif']) - } - if (res[0] == 'martijn') { - addTask(['40%', '/copilot/static/martijn.gif']) - } - if (res[0] == 'rick') { - addTask(['40%', '/copilot/static/rick.gif']) - } - if (res[0] == 'true') { - document.getElementById('videoCamera').style.width = '20%' - self.initScreenShare() - } - if (res[0] == 'false') { - document.getElementById('videoCamera').style.width = '100%' - document.getElementById('videoScreen').src = null - } - console.log(res[1]) - if (res[1] != 'none') { - showNotif(res[1]) - } + console.log(e.data) + res = e.data.split('-') + if (res[0] == 'rocket') { + addTask(['40%', '/copilot/static/rocket.gif']) } + if (res[0] == 'face') { + addTask(['35%', '/copilot/static/face.gif']) + } + if (res[0] == 'bitcoin') { + addTask(['30%', '/copilot/static/bitcoin.gif']) + } + if (res[0] == 'confetti') { + addTask(['100%', '/copilot/static/confetti.gif']) + } + if (res[0] == 'martijn') { + addTask(['40%', '/copilot/static/martijn.gif']) + } + if (res[0] == 'rick') { + addTask(['40%', '/copilot/static/rick.gif']) + } + if (res[0] == 'true') { + document.getElementById('videoCamera').style.width = '20%' + self.initScreenShare() + } + if (res[0] == 'false') { + document.getElementById('videoCamera').style.width = '100%' + document.getElementById('videoScreen').src = null + } + console.log(res[1]) + if (res[1] != 'none') { + showNotif(res[1]) + } + } this.connection.onopen = () => this.launch } }) diff --git a/lnbits/extensions/copilot/templates/copilot/index.html b/lnbits/extensions/copilot/templates/copilot/index.html index c72628b31..78739f193 100644 --- a/lnbits/extensions/copilot/templates/copilot/index.html +++ b/lnbits/extensions/copilot/templates/copilot/index.html @@ -105,7 +105,14 @@ - +
- - +
@@ -485,19 +491,17 @@ sendFormDataCopilot: function () { var self = this console.log(self.formDialogCopilot.data.animation1threshold) - if(self.formDialogCopilot.data.id){ + if (self.formDialogCopilot.data.id) { this.updateCopilot( - self.g.user.wallets[0].adminkey, - self.formDialogCopilot.data - ) - } - else{ + self.g.user.wallets[0].adminkey, + self.formDialogCopilot.data + ) + } else { this.createCopilot( - self.g.user.wallets[0].adminkey, - self.formDialogCopilot.data - ) + self.g.user.wallets[0].adminkey, + self.formDialogCopilot.data + ) } - }, createCopilot: function (wallet, data) { @@ -588,14 +592,19 @@ var updatedData = {} console.log(data) for (const property in data) { - if(data[property]){ + if (data[property]) { updatedData[property] = data[property] } } console.log(updatedData) LNbits.api - .request('PUT', '/copilot/api/v1/copilot/' + updatedData.id, wallet, updatedData) + .request( + 'PUT', + '/copilot/api/v1/copilot/' + updatedData.id, + wallet, + updatedData + ) .then(function (response) { self.CopilotLinks.push(mapCopilot(response.data)) self.formDialogCopilot.show = false diff --git a/lnbits/extensions/copilot/templates/copilot/panel.html b/lnbits/extensions/copilot/templates/copilot/panel.html index 1cf74b405..4f29c205a 100644 --- a/lnbits/extensions/copilot/templates/copilot/panel.html +++ b/lnbits/extensions/copilot/templates/copilot/panel.html @@ -129,7 +129,8 @@ LNbits.api .request( 'GET', - '/copilot/api/v1/copilot/ws/' + self.copilot.id + '/none/' + name) + '/copilot/api/v1/copilot/ws/' + self.copilot.id + '/none/' + name + ) .then(function (response1) { self.$q.notify({ color: 'green', @@ -139,7 +140,7 @@ .catch(err => { LNbits.utils.notifyApiError(err) }) - }, + } }, created: function () { self = this diff --git a/package-lock.json b/package-lock.json index e08f5cc4c..3d0735425 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,11 +1,31 @@ { + "name": "lnbits", + "lockfileVersion": 2, "requires": true, - "lockfileVersion": 1, + "packages": { + "": { + "devDependencies": { + "prettier": "2.1.1" + } + }, + "node_modules/prettier": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.1.tgz", + "integrity": "sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw==", + "dev": true, + "bin": { + "prettier": "bin-prettier.js" + }, + "engines": { + "node": ">=10.13.0" + } + } + }, "dependencies": { "prettier": { - "version": "2.0.5", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.0.5.tgz", - "integrity": "sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg==", + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.1.1.tgz", + "integrity": "sha512-9bY+5ZWCfqj3ghYBLxApy2zf6m+NJo5GzmLTpr9FsApsfjriNnS2dahWReHMi7qNPhhHl9SYHJs2cHZLgexNIw==", "dev": true } }