From 1d980afb62c5998c9b9e5113cbbedbe15d124cc2 Mon Sep 17 00:00:00 2001 From: ben Date: Tue, 10 Jan 2023 14:29:05 +0000 Subject: [PATCH] format --- .../example/templates/example/index.html | 139 ++++++++++++------ 1 file changed, 93 insertions(+), 46 deletions(-) diff --git a/lnbits/extensions/example/templates/example/index.html b/lnbits/extensions/example/templates/example/index.html index 645e0ce4f..36d325bb8 100644 --- a/lnbits/extensions/example/templates/example/index.html +++ b/lnbits/extensions/example/templates/example/index.html @@ -52,7 +52,14 @@
Extension Development Guide - (also check the docs) + (also check the + docs)
@@ -188,7 +195,8 @@

LNbits uses Vue - for best-in-class, responsive and high-performance components. + for best-in-class, responsive and high-performance + components.

Typical example of Vue components in a frontend script:

@@ -198,8 +206,7 @@ />

- Content can be - conditionally rendered using Vue's + Content can be conditionally rendered using Vue's v-if:

QR Codes
-

For most purposes use Quasar's inbuilt VueQrcode library:

+

+ For most purposes use Quasar's inbuilt VueQrcode library: +

LNbits does also include a handy QR code enpoint + QR code enpoint

- {% raw - %} You can use via {{protocol + location}}{% endraw %}/api/v1/qrcode/some-data-you-want-in-a-qrcode:
-
- -
- - + {% raw %} You can use via + {{protocol + location}}{% endraw + %}/api/v1/qrcode/some-data-you-want-in-a-qrcode:

+ +
+ +
Websockets
-

Fastapi includes a great websocket tool

- {% raw - %}

- A few LNbits extensions also make use of a weird and useful websocket/GET tool built into LNbits, such as extensions Copilot and LNURLDevices
- You can subscribe to websocket with wss:{{location}}/api/v1/ws/{SOME-ID}
- You can post to any clients subscribed to the endpoint with {{protocol + location}}/api/v1/ws/{SOME-ID}/{THE-DATA-YOU-WANT-TO-POST}
-
-

DEMO: Hit {{protocol + location}}/api/v1/ws/32872r23g29/blah%20blah%20blah in a different browser window to change this text to `blah blah blah`.
-
- Function used in this demo:
- -
+ Fastapi includes a great + websocket tool +

+ {% raw %} +

+ A few LNbits extensions also make use of a weird and useful + websocket/GET tool built into LNbits, such as extensions + Copilot and LNURLDevices
+ You can subscribe to websocket with + wss:{{location}}/api/v1/ws/{SOME-ID}
+ You can post to any clients subscribed to the endpoint with + {{protocol + + location}}/api/v1/ws/{SOME-ID}/{THE-DATA-YOU-WANT-TO-POST}
+
+

+ DEMO: Hit + {{protocol + + location}}/api/v1/ws/32872r23g29/blah%20blah%20blah + in a different browser window to change this text to + `blah blah blah`. +
+
+ Function used in this demo:
+

+ {% endraw %} @@ -337,7 +384,7 @@ return { ///// Declare models/variables ///// protocol: window.location.protocol, - location: "//" + window.location.hostname, + location: '//' + window.location.hostname, thingDialog: { show: false, data: {} @@ -352,7 +399,7 @@ }, ///// Where functions live ///// methods: { - exampleFunction: function(data) { + exampleFunction: function (data) { var theData = data LNbits.api .request( @@ -369,26 +416,26 @@ }, initWs: async function () { if (location.protocol !== 'http:') { - localUrl = - 'wss://' + - document.domain + - ':' + - location.port + - '/api/v1/ws/32872r23g29' + localUrl = + 'wss://' + + document.domain + + ':' + + location.port + + '/api/v1/ws/32872r23g29' } else { - localUrl = - 'ws://' + - document.domain + - ':' + - location.port + - '/api/v1/ws/32872r23g29' - } - this.ws = new WebSocket(localUrl) - this.ws.addEventListener('message', async ({data}) => { - const res = data.toString() - document.getElementById("text-to-change").innerHTML = res - }) -}, + localUrl = + 'ws://' + + document.domain + + ':' + + location.port + + '/api/v1/ws/32872r23g29' + } + this.ws = new WebSocket(localUrl) + this.ws.addEventListener('message', async ({data}) => { + const res = data.toString() + document.getElementById('text-to-change').innerHTML = res + }) + }, sendThingDialog() { console.log(this.thingDialog) }