diff --git a/js/lib.board.js b/js/lib.board.js index ac70362..6cccbed 100644 --- a/js/lib.board.js +++ b/js/lib.board.js @@ -1,3 +1,4 @@ +/* eslint-disable no-unused-vars */ /* Fetch Functions */ async function publicLdb(stn) { var url = `${window.location.origin}/api/v1/ldb/${stn}` @@ -25,15 +26,16 @@ async function displayNoTrains() { /* Parse the value of `platform` to account for unknown platforms */ async function parsePlatform(svc){ + let platform, changed if (svc.platform != undefined) { - var platform = svc.platform + platform = svc.platform } else { - var platform = '-' + platform = '-' } if (svc.platformChanged) { // Not present in public API, ready for staff version. - var changed = 'changed' + changed = 'changed' } else { - var changed = '' + changed = '' } return {num: platform, change: changed} } @@ -41,38 +43,40 @@ async function parsePlatform(svc){ /* Change value of time strings to fit well on small screens */ async function parseTime(string){ + let output + let change switch (string) { case 'Delayed': - var output = 'LATE' - var change = 'changed' + output = 'LATE' + change = 'changed' break case 'Cancelled': - var output = 'CANC' - var change = 'cancelled' + output = 'CANC' + change = 'cancelled' break case 'On time': - var output = 'RT' - var change = 'righttime' + output = 'RT' + change = 'righttime' break case '': - var output = '-' - var change = '' + output = '-' + change = '' break case undefined: - var output = '-' - var change = '' + output = '-' + change = '' break case 'No report': - var output = '-' - var change = '' + output = '-' + change = '' break case 'undefined': - var output = false - var change = '' + output = false + change = '' break default: - var output = string - var change = 'changed' + output = string + change = 'changed' } return {data: output, changed: change} } @@ -174,15 +178,18 @@ async function showCalls(id) { var thisSta = await parseTime(svcDetail.sta) var thisEta = await parseTime(svcDetail.eta) /* Prepare data for this station */ + let sTime + let eTime + let change if (thisStd.data != '-') { - var sTime = `${thisStd.data}` - var eTime = `${thisEtd.data}` - var change = thisEtd.changed + sTime = `${thisStd.data}` + eTime = `${thisEtd.data}` + change = thisEtd.changed } else { - var sTime = `${thisSta.data}` - var eTime = `${thisEta.data}` - var change = thisEta.changed - }; + sTime = `${thisSta.data}` + eTime = `${thisEta.data}` + change = thisEta.changed + } let here = `