You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
952 B
26 lines
952 B
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)
|