Diff options
| -rw-r--r-- | assets/cgit.js | 17 |
1 file changed, 6 insertions, 11 deletions
diff --git a/assets/cgit.js b/assets/cgit.js index dfe4e3d..1937cf2 100644 --- a/assets/cgit.js +++ b/assets/cgit.js @@ -22,19 +22,18 @@ var YEAR = 365 * DAY; var MONTH = YEAR / 12; // The five arrays are indexed together by the bucket an age falls into. -// The search in render_age can stop one place past the last class, so -// age_suffix and age_unit repeat their final entry. Each limit is twice the -// next unit up, matching the thresholds cgit_print_age compares against. +// Each limit is twice the next unit up, matching the thresholds +// cgit_print_age compares against, and an age past the last is in years. var age_classes = [ "age-mins", "age-hours", "age-days", "age-weeks", "age-months", "age-years" ]; -var age_suffix = [ "min.", "hours", "days", "weeks", "months", "years", "years" ]; -var age_unit = [ MINUTE, HOUR, DAY, WEEK, MONTH, YEAR, YEAR ]; -var age_limit = [ 2 * HOUR, 2 * DAY, 2 * WEEK, 2 * MONTH, 2 * YEAR, 2 * YEAR ]; +var age_suffix = [ "min.", "hours", "days", "weeks", "months", "years" ]; +var age_unit = [ MINUTE, HOUR, DAY, WEEK, MONTH, YEAR ]; +var age_limit = [ 2 * HOUR, 2 * DAY, 2 * WEEK, 2 * MONTH, 2 * YEAR ]; var update_delay = [ 10, 5 * MINUTE, 30 * MINUTE, DAY, DAY, DAY ]; function render_age(element, age) { var text, bucket; - for (bucket = 0; bucket < age_classes.length; bucket++) + for (bucket = 0; bucket < age_limit.length; bucket++) if (age < age_limit[bucket]) break; @@ -45,10 +44,6 @@ function render_age(element, age) { // for nothing. if (element.textContent != text) { element.textContent = text; - // An age past the last limit is still counted in years, but there - // is no class beyond age-years to put on it. - if (bucket == age_classes.length) - bucket--; if (element.className != age_classes[bucket]) element.className = age_classes[bucket]; } |
