code cleanup

This commit is contained in:
Maxime Bloch 2019-09-22 03:16:48 +02:00
parent e74c2f4634
commit c7490f78c8
No known key found for this signature in database
GPG key ID: CE32A7D95B7D6418

View file

@ -6,8 +6,6 @@ requirejs.config({
waitSeconds: 3 waitSeconds: 3
}); });
require(['jquery', 'socket.io'], function(jq, io) { require(['jquery', 'socket.io'], function(jq, io) {
function getDurationString(link_data) { function getDurationString(link_data) {
@ -48,21 +46,17 @@ require(['jquery', 'socket.io'], function(jq, io) {
}); });
function addLink(link_id, link_data) { function addLink(link_id, link_data) {
let start = new Date(link_data["start"] * 1000); let stop = "handoff" in link_data;
let datestring = start.getHours() + ":" + start.getMinutes();
let stop = undefined;
let stopString = undefined;
if (link_data["handoff"]) {
stop = new Date(link_data["handoff"] * 1000);
stopString = stop.getHours() + ":" + stop.getMinutes();
} let time = (stop ? "Time: " + getDurationString(link_data) : "Running");
let icon = (stop ? "check" : "question");
let style = (stop ? "style=\"color:green\"" : "");
let html = ` let html = `
<div id='link-${link_id}' class="item"> <div id='link-${link_id}' class="item">
<div>${link_id}</div> <div>${link_id}</div>
<div class="link-time">${stop !== undefined ? "Time: " + getDurationString(link_data) : "Running"}</div> <div class="link-time">${time}</div>
<div> <div>
<i class="link-status fas fa-${stop !== undefined ? "check" : "question"}" ${stop !== undefined ? "style=\"color:green\"" : ""}></i> <i class="link-status fas fa-${icon}" ${style}></i>
</div> </div>
</div> </div>
`; `;