mirror of
https://github.com/lnbits/lnbits.git
synced 2025-09-28 21:02:31 +02:00
animation queue working
This commit is contained in:
@@ -23,7 +23,7 @@ async def m001_initial(db):
|
|||||||
lnurl_title TEXT,
|
lnurl_title TEXT,
|
||||||
show_message INTEGER,
|
show_message INTEGER,
|
||||||
show_ack INTEGER,
|
show_ack INTEGER,
|
||||||
show_price INTEGER,
|
show_price TEXT,
|
||||||
amount_made INTEGER,
|
amount_made INTEGER,
|
||||||
fullscreen_cam INTEGER,
|
fullscreen_cam INTEGER,
|
||||||
iframe_url TEXT,
|
iframe_url TEXT,
|
||||||
|
@@ -25,7 +25,7 @@ class Copilots(NamedTuple):
|
|||||||
lnurl_title: str
|
lnurl_title: str
|
||||||
show_message: int
|
show_message: int
|
||||||
show_ack: int
|
show_ack: int
|
||||||
show_price: int
|
show_price: str
|
||||||
amount_made: int
|
amount_made: int
|
||||||
timestamp: int
|
timestamp: int
|
||||||
fullscreen_cam: int
|
fullscreen_cam: int
|
||||||
|
@@ -135,6 +135,11 @@
|
|||||||
console.log('Something went wrong!')
|
console.log('Something went wrong!')
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
pushAnim(content){
|
||||||
|
document.getElementById('animations').style.width = content[0]
|
||||||
|
document.getElementById('animations').src = content[1]
|
||||||
|
setTimeout(function(){ document.getElementById('animations').src = '' }, 5000)
|
||||||
|
},
|
||||||
launch(){
|
launch(){
|
||||||
self = this
|
self = this
|
||||||
console.log("poo")
|
console.log("poo")
|
||||||
@@ -152,7 +157,6 @@
|
|||||||
LNbits.utils.notifyApiError(err)
|
LNbits.utils.notifyApiError(err)
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.initCamera()
|
this.initCamera()
|
||||||
@@ -160,6 +164,20 @@
|
|||||||
created: function () {
|
created: function () {
|
||||||
self = this
|
self = this
|
||||||
self.copilot = JSON.parse(localStorage.getItem('copilot'))
|
self.copilot = JSON.parse(localStorage.getItem('copilot'))
|
||||||
|
console.log(localStorage.getItem('inkey'))
|
||||||
|
LNbits.api
|
||||||
|
.request(
|
||||||
|
'GET',
|
||||||
|
'/copilot/api/v1/copilot/' +
|
||||||
|
self.copilot.id,
|
||||||
|
localStorage.getItem('inkey')
|
||||||
|
)
|
||||||
|
.then(function (response) {
|
||||||
|
self.copilot = response.data
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
LNbits.utils.notifyApiError(err)
|
||||||
|
})
|
||||||
|
|
||||||
this.connectionBitStamp = new WebSocket('wss://ws.bitstamp.net')
|
this.connectionBitStamp = new WebSocket('wss://ws.bitstamp.net')
|
||||||
|
|
||||||
@@ -170,6 +188,9 @@
|
|||||||
|
|
||||||
this.connectionBitStamp.onmessage = function (e) {
|
this.connectionBitStamp.onmessage = function (e) {
|
||||||
console.log(JSON.parse(e.data).data.price)
|
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(
|
self.price = String(
|
||||||
new Intl.NumberFormat('en-US', {
|
new Intl.NumberFormat('en-US', {
|
||||||
style: 'currency',
|
style: 'currency',
|
||||||
@@ -177,8 +198,40 @@
|
|||||||
}).format(JSON.parse(e.data).data.price)
|
}).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', {
|
||||||
|
style: 'currency',
|
||||||
|
currency: 'GBP'
|
||||||
|
}).format(JSON.parse(e.data).data.price)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
this.connectionBitStamp.onopen = () => this.connectionBitStamp.send(obj)
|
this.connectionBitStamp.onopen = () => this.connectionBitStamp.send(obj)
|
||||||
|
|
||||||
|
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))
|
||||||
|
})();
|
||||||
|
|
||||||
if (location.protocol !== 'http:') {
|
if (location.protocol !== 'http:') {
|
||||||
localUrl = 'wss://' +
|
localUrl = 'wss://' +
|
||||||
document.domain +
|
document.domain +
|
||||||
@@ -195,58 +248,24 @@
|
|||||||
this.connection = new WebSocket(localUrl)
|
this.connection = new WebSocket(localUrl)
|
||||||
this.connection.onmessage = function (e) {
|
this.connection.onmessage = function (e) {
|
||||||
console.log(e.data)
|
console.log(e.data)
|
||||||
|
|
||||||
res = e.data.split('-')
|
res = e.data.split('-')
|
||||||
if (res[0] != this.oldRes) {
|
|
||||||
this.oldRes = res[0]
|
|
||||||
if (res[0] == 'rocket') {
|
if (res[0] == 'rocket') {
|
||||||
document.getElementById('animations').style.width = '40%'
|
addTask(['40%', '/copilot/static/rocket.gif'])
|
||||||
document.getElementById('animations').src =
|
|
||||||
'/copilot/static/rocket.gif'
|
|
||||||
setTimeout(function () {
|
|
||||||
document.getElementById('animations').src = ''
|
|
||||||
}, 5000)
|
|
||||||
}
|
}
|
||||||
if (res[0] == 'face') {
|
if (res[0] == 'face') {
|
||||||
document.getElementById('animations').style.width = '35%'
|
addTask(['35%', '/copilot/static/face.gif'])
|
||||||
document.getElementById('animations').src =
|
|
||||||
'/copilot/static/face.gif'
|
|
||||||
setTimeout(function () {
|
|
||||||
document.getElementById('animations').src = ''
|
|
||||||
}, 5000)
|
|
||||||
}
|
}
|
||||||
if (res[0] == 'bitcoin') {
|
if (res[0] == 'bitcoin') {
|
||||||
document.getElementById('animations').style.width = '30%'
|
addTask(['30%', '/copilot/static/bitcoin.gif'])
|
||||||
document.getElementById('animations').src =
|
|
||||||
'/copilot/static/bitcoin.gif'
|
|
||||||
setTimeout(function () {
|
|
||||||
document.getElementById('animations').src = ''
|
|
||||||
}, 5000)
|
|
||||||
}
|
}
|
||||||
if (res[0] == 'confetti') {
|
if (res[0] == 'confetti') {
|
||||||
document.getElementById('animations').style.width = '100%'
|
addTask(['100%', '/copilot/static/confetti.gif'])
|
||||||
document.getElementById('animations').style.height = '100%'
|
|
||||||
document.getElementById('animations').src =
|
|
||||||
'/copilot/static/confetti.gif'
|
|
||||||
setTimeout(function () {
|
|
||||||
document.getElementById('animations').src = ''
|
|
||||||
document.getElementById('animations').style.height = ''
|
|
||||||
}, 5000)
|
|
||||||
}
|
}
|
||||||
if (res[0] == 'martijn') {
|
if (res[0] == 'martijn') {
|
||||||
document.getElementById('animations').style.width = '40%'
|
addTask(['40%', '/copilot/static/martijn.gif'])
|
||||||
document.getElementById('animations').src =
|
|
||||||
'/copilot/static/martijn.gif'
|
|
||||||
setTimeout(function () {
|
|
||||||
document.getElementById('animations').src = ''
|
|
||||||
}, 5000)
|
|
||||||
}
|
}
|
||||||
if (res[0] == 'rick') {
|
if (res[0] == 'rick') {
|
||||||
this.animQueue.push({size: '40%', location: '/copilot/static/rick.gif'})
|
addTask(['40%', '/copilot/static/rick.gif'])
|
||||||
}
|
|
||||||
if(self.queue == false){
|
|
||||||
for()
|
|
||||||
|
|
||||||
}
|
}
|
||||||
if (res[0] == 'true') {
|
if (res[0] == 'true') {
|
||||||
document.getElementById('videoCamera').style.width = '20%'
|
document.getElementById('videoCamera').style.width = '20%'
|
||||||
@@ -260,8 +279,6 @@
|
|||||||
if (res[1] != 'none') {
|
if (res[1] != 'none') {
|
||||||
showNotif(res[1])
|
showNotif(res[1])
|
||||||
}
|
}
|
||||||
this.oldRes = ''
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.connection.onopen = () => this.launch
|
this.connection.onopen = () => this.launch
|
||||||
}
|
}
|
||||||
|
@@ -323,13 +323,15 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="q-gutter-sm">
|
<div class="q-gutter-sm">
|
||||||
<div class="row">
|
<q-select
|
||||||
<q-checkbox
|
filled
|
||||||
v-model="formDialogCopilot.data.show_price"
|
dense
|
||||||
left-label
|
style="width:50%"
|
||||||
label="Show bitcoin price"
|
v-model.trim="formDialogCopilot.data.show_price"
|
||||||
></q-checkbox>
|
:options="currencyOptions"
|
||||||
</div>
|
label="Show price"
|
||||||
|
/>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="q-gutter-sm">
|
<div class="q-gutter-sm">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -453,7 +455,8 @@
|
|||||||
show: false,
|
show: false,
|
||||||
data: null
|
data: null
|
||||||
},
|
},
|
||||||
options: ['bitcoin', 'confetti', 'rocket', 'face', 'martijn', 'rick']
|
options: ['bitcoin', 'confetti', 'rocket', 'face', 'martijn', 'rick'],
|
||||||
|
currencyOptions: ['btcusd', 'btceur', 'btcgbp']
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -512,6 +515,7 @@
|
|||||||
)
|
)
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
localStorage.setItem('copilot', JSON.stringify(response.data))
|
localStorage.setItem('copilot', JSON.stringify(response.data))
|
||||||
|
localStorage.setItem('inkey', self.g.user.wallets[0].inkey)
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
LNbits.utils.notifyApiError(error)
|
LNbits.utils.notifyApiError(error)
|
||||||
|
Reference in New Issue
Block a user