parent
262afbec3a
commit
63a649a8a1
@ -0,0 +1,25 @@
|
|||||||
|
const calculateMoneyLost = (data) => {
|
||||||
|
const start_seconds = new Date(data.start_time).getTime();
|
||||||
|
const end_seconds = new Date().getTime();
|
||||||
|
const difference = end_seconds-start_seconds;
|
||||||
|
|
||||||
|
const microSecondlyPay = 100000/50/40/60/60/1000
|
||||||
|
return microSecondlyPay*difference*data.num_participants;
|
||||||
|
}
|
||||||
|
|
||||||
|
const getData = async () => {
|
||||||
|
const id = parseInt(window.location.pathname.split('/')[1])
|
||||||
|
const response = await fetch('/meetings/'+id)
|
||||||
|
const data = await response.json();
|
||||||
|
return data
|
||||||
|
}
|
||||||
|
|
||||||
|
const main = async () => {
|
||||||
|
const data = await getData();
|
||||||
|
const moneyLost = calculateMoneyLost(data)
|
||||||
|
document.querySelector('dd:nth-of-type(1)').innerHTML = data.num_participants
|
||||||
|
document.querySelector('dd:nth-of-type(2)').innerHTML = data.start_time
|
||||||
|
document.querySelector('dd:nth-of-type(3)').innerHTML = data.end_time ? data.end_time : 'Still losing money...'
|
||||||
|
document.querySelector('dd:nth-of-type(4)').innerHTML = moneyLost
|
||||||
|
}
|
||||||
|
setInterval(main,1000)
|
||||||
Loading…
Reference in new issue