|
1 | 1 | {% extends "base.html" %} {% from "macros.jinja" import window_vars with context |
2 | | -%} {% block page %} |
3 | | - |
| 2 | +%} {% block scripts %} {{ window_vars(user) }} |
| 3 | +<script src="{{ static_url_for('example/static', path='js/index.js') }}"></script> |
| 4 | +<!-- Do not remove. Test install extension version: 2 --> |
| 5 | +{% endblock %} {% block page %} |
4 | 6 | <q-dialog v-model="thingDialog.show" position="top"> |
5 | 7 | <q-card class="q-pa-lg q-pt-xl lnbits__dialog-card"> |
6 | 8 | <q-form @submit="sendThingDialog" class="q-gutter-md"> |
|
371 | 373 | </q-card> |
372 | 374 | </q-card-section> |
373 | 375 | </q-card> |
374 | | -{% endblock %} {% block scripts %} {{ window_vars(user) }} |
375 | | - |
376 | | -<script> |
377 | | - var someMapObject = obj => { |
378 | | - obj._data = _.clone(obj) |
379 | | - obj.date = Quasar.utils.date.formatDate( |
380 | | - new Date(obj.time * 1000), |
381 | | - 'YYYY-MM-DD HH:mm' |
382 | | - ) |
383 | | - // here you can do something with the mapped data |
384 | | - return obj |
385 | | - } |
386 | | - new Vue({ |
387 | | - el: '#vue', |
388 | | - mixins: [windowMixin], |
389 | | - data: function () { |
390 | | - return { |
391 | | - ///// Declare models/variables ///// |
392 | | - protocol: window.location.protocol, |
393 | | - location: '//' + window.location.hostname, |
394 | | - thingDialog: { |
395 | | - show: false, |
396 | | - data: {} |
397 | | - }, |
398 | | - someBool: true, |
399 | | - splitterModel: 20, |
400 | | - exampleData: [], |
401 | | - tab: 'frameworks', |
402 | | - framworktab: 'fastapi', |
403 | | - usefultab: 'magicalg', |
404 | | - vettedData: '' |
405 | | - } |
406 | | - }, |
407 | | - ///// Where functions live ///// |
408 | | - methods: { |
409 | | - exampleFunction: function (data) { |
410 | | - var theData = data |
411 | | - LNbits.api |
412 | | - .request( |
413 | | - 'GET', // Type of request |
414 | | - '/example/api/v1/test/' + theData, // URL of the endpoint |
415 | | - this.g.user.wallets[0].inkey // Often endpoints require a key |
416 | | - ) |
417 | | - .then(response => { |
418 | | - this.exampleData = response.data.map(someMapObject) // Often whats returned is mapped onto some model |
419 | | - }) |
420 | | - .catch(error => { |
421 | | - LNbits.utils.notifyApiError(error) // Error will be passed to the frontend |
422 | | - }) |
423 | | - }, |
424 | | - getVettedReadme: function () { |
425 | | - // This is a function that gets the vetted readme from the LNbits repo and converts it from makrdown to html. |
426 | | - LNbits.api |
427 | | - .request( |
428 | | - 'GET', |
429 | | - '/example/api/v1/vetted', |
430 | | - this.g.user.wallets[0].inkey |
431 | | - ) |
432 | | - .then(response => { |
433 | | - this.vettedData = LNbits.utils.convertMarkdown(response.data) |
434 | | - }) |
435 | | - .catch(error => { |
436 | | - LNbits.utils.notifyApiError(error) |
437 | | - }) |
438 | | - }, |
439 | | - initWs: async function () { |
440 | | - if (location.protocol !== 'http:') { |
441 | | - localUrl = |
442 | | - 'wss://' + |
443 | | - document.domain + |
444 | | - ':' + |
445 | | - location.port + |
446 | | - '/api/v1/ws/32872r23g29' |
447 | | - } else { |
448 | | - localUrl = |
449 | | - 'ws://' + |
450 | | - document.domain + |
451 | | - ':' + |
452 | | - location.port + |
453 | | - '/api/v1/ws/32872r23g29' |
454 | | - } |
455 | | - this.ws = new WebSocket(localUrl) |
456 | | - this.ws.addEventListener('message', async ({data}) => { |
457 | | - const res = data.toString() |
458 | | - document.getElementById('text-to-change').innerHTML = res |
459 | | - }) |
460 | | - }, |
461 | | - sendThingDialog() { |
462 | | - console.log(this.thingDialog) |
463 | | - } |
464 | | - }, |
465 | | - ///// To run on startup ///// |
466 | | - created: function () { |
467 | | - self = this // Often used to run a real object, rather than the event (all a bit confusing really) |
468 | | - self.exampleFunction('lorum') |
469 | | - self.initWs() |
470 | | - self.getVettedReadme() |
471 | | - } |
472 | | - }) |
473 | | -</script> |
474 | | -<!-- Do not remove. Test install extension version: 2 --> |
475 | 376 | {% endblock %} |
0 commit comments