Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Brelee2222 committed Jun 26, 2024
1 parent 6f1474c commit d04eee2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 27 deletions.
52 changes: 32 additions & 20 deletions src/frontend/dash/circlePacker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,26 +141,38 @@ export class ClockCircle extends Circle{
let timeElemsWest = document.querySelectorAll('.bustime.west')
let timeElemsEast = document.querySelectorAll('.bustime.east')

arrivals[busSigns[0]].forEach((v,i)=>{
if(i>=2) {return} // only set first 2 arrivals
let minutesTill = Math.max(0,Math.round((v - Date.now())/1000/60));
timeElemsEast[i].innerHTML = minutesTill + ' min'
if(minutesTill <= 5) {
timeElemsEast[i].classList.add('soonish')
} else {
timeElemsEast[i].classList.remove('soonish')
}
})
arrivals[busSigns[1]].forEach((v,i)=>{
if(i>=2) {return} // only set first 2 arrivals
let minutesTill = Math.max(0,Math.round((v - Date.now())/1000/60));
timeElemsWest[i].innerHTML = minutesTill + '&nbsp;min'
if(minutesTill <= 5) {
timeElemsWest[i].classList.add('soonish')
} else {
timeElemsWest[i].classList.remove('soonish')
}
})
let minutesTillEastFirst = Math.max(0,Math.round((arrivals[busSigns[0]][0] - Date.now())/1000/60));
timeElemsEast[0].innerHTML = minutesTillEastFirst + '&nbsp;min'
if(minutesTillEastFirst <= 5) {
timeElemsEast[0].classList.add('soonish')
} else {
timeElemsEast[0].classList.remove('soonish')
}

let minutesTillEastSecond = Math.max(0,Math.round((arrivals[busSigns[0]][1] - Date.now())/1000/60));
timeElemsEast[1].innerHTML = minutesTillEastSecond + '&nbsp;min'
if(minutesTillEastSecond <= 5) {
timeElemsEast[1].classList.add('soonish')
} else {
timeElemsEast[1].classList.remove('soonish')
}

let minutesTillWestFirst = Math.max(0,Math.round((arrivals[busSigns[1]][0] - Date.now())/1000/60));
timeElemsWest[0].innerHTML = minutesTillWestFirst + '&nbsp;min'
if(minutesTillEastFirst <= 5) {
timeElemsWest[0].classList.add('soonish')
} else {
timeElemsWest[0].classList.remove('soonish')
}

let minutesTillWestSecond = Math.max(0,Math.round((arrivals[busSigns[1]][1] - Date.now())/1000/60));
timeElemsWest[1].innerHTML = minutesTillWestSecond + '&nbsp;min'
if(minutesTillWestSecond <= 5) {
timeElemsWest[1].classList.add('soonish')
} else {
timeElemsWest[1].classList.remove('soonish')
}

})();
},
15000);
Expand Down
9 changes: 2 additions & 7 deletions src/frontend/dash/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,11 @@ setInterval(regenCircles, 10) // chnage panel every 1 minutes

let prevTime = Date.now();

function regenCircles(loggedin?: LoggedIn) {
if(loggedin===undefined) {loggedin = loggedInCache}
function regenCircles() {

const now = Date.now()

const loginEntries = Object.entries(loggedin)
const loginEntries = Object.entries(loggedInCache)
.filter(entry => members.find(member => member.name == entry[0]))
;

Expand Down Expand Up @@ -51,7 +50,6 @@ function update() {
// return if there's no change
if (JSON.stringify(loggedInCache) == JSON.stringify(loggedin)) { return }
loggedInCache = loggedin
regenCircles(loggedin)
}));
}

Expand All @@ -61,9 +59,6 @@ async function start() {
placedCircles.push(new ClockCircle());
update()

setInterval(() => {
regenCircles(loggedInCache)
}, 1000 * 60);
setInterval(() => {
update()
}, 1000 * 3);
Expand Down

0 comments on commit d04eee2

Please sign in to comment.