basic display page

master
Matthew Huntington 2 years ago
parent 262afbec3a
commit 63a649a8a1

@ -14,7 +14,6 @@ app = Flask(__name__)
def show(id): def show(id):
cursor.execute('SELECT * FROM meetings WHERE id=%s', [id]) cursor.execute('SELECT * FROM meetings WHERE id=%s', [id])
result = cursor.fetchone() result = cursor.fetchone()
print(result)
return { return {
"id":result[0], "id":result[0],
"num_participants":result[1], "num_participants":result[1],

@ -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)

@ -3,8 +3,21 @@
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<title></title> <title></title>
<script defer src="{{url_for('static', filename='app.js')}}"></script>
</head> </head>
<body> <body>
<h1>How Much Time Have We Wasted?</h1> <h1>How Much Money Have We Wasted?</h1>
<dl>
<dt>Number of Participants</dt>
<dd></dd>
<dt>Start Time</dt>
<dd></dd>
<dt>End Time</dt>
<dd></dd>
<dt>
Amount of Money Wasted<br/>
(assuming an average salary of 100K)
</dt>
<dd></dd>
</body> </body>
</html> </html>

Loading…
Cancel
Save