moloch-- / RootTheBox

A Game of Hackers (CTF Scoreboard & Game Manager)
http://root-the-box.com/
Apache License 2.0
908 stars 292 forks source link

[Request] - Scoreboard Timer #581

Closed PJNorrisS1 closed 5 months ago

PJNorrisS1 commented 1 year ago

Is it possible to define the time in to days, hours and minutes, instead of just minutes? We have scenarios where we like to leave the game running for a couple of days and then stop.

eljeffeg commented 5 months ago

From what I can tell, the current code should already do that. Did we add it and not close this request? The timer seems to be set for timercount, which runs in a few javascript files home.js, history.js, summary.js, and teams.js. Aside from good practice being we should not be duplicating that code, it does appear they're all implementing something this:

var days = Math.max(0,Math.floor((distance) / (1000 * 60 * 60 * 24)));
var hours = Math.max(0,Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)));
var minutes = Math.max(0,Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)));
var seconds = Math.max(0,Math.floor((distance % (1000 * 60)) / 1000));

// Display the result in the element with id="timercount"
var timercount = padDigits(minutes,2) + "m " + padDigits(seconds,2) + "s ";
if (hours > 0) {
    timercount = hours + "h " + timercount;
}
if (days > 0) {
    timercount = days + "d " + timercount;
}
$("#timercount" + id).text(timercount);
eljeffeg commented 5 months ago

Yeah, looks like @sdoliner got it in https://github.com/moloch--/RootTheBox/commit/41b921e855cfb827db23c9151e3f7b82fa78ea40