From 75450307c0c5a0fdf9826e5b06bdf252cfe22df0 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sun, 6 Sep 2026 20:14:48 -1000 Subject: Trim the comments and dead code across the tree --- assets/cgit.js | 51 ++++++++++++++++++++++++--------------------------- 1 file changed, 24 insertions(+), 27 deletions(-) (limited to 'assets/cgit.js') diff --git a/assets/cgit.js b/assets/cgit.js index c5bdf33..29b9745 100644 --- a/assets/cgit.js +++ b/assets/cgit.js @@ -12,8 +12,7 @@ // Written the way SECONDS_PER_* are derived in source/cgit.h, so that the // bucket a browser picks is the bucket cgit_print_age already picked on the -// server. A month is a twelfth of a year rather than thirty days, which is -// the definition the server uses. +// server. A month is a twelfth of a year rather than thirty days. var MINUTE = 60; var HOUR = 60 * MINUTE; var DAY = 24 * HOUR; @@ -21,15 +20,18 @@ var WEEK = 7 * DAY; 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 the arrays -// it reads there repeat their final entry. Each limit is twice the next unit -// up, matching the thresholds cgit_print_age compares against. -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 update_delay = [ 10, 5 * MINUTE, 30 * MINUTE, DAY, DAY, DAY, DAY ]; +// 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. +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 update_delay = [ 10, 5 * MINUTE, 30 * MINUTE, DAY, DAY, DAY ]; function render_age(element, age) { var text, bucket; @@ -40,13 +42,13 @@ function render_age(element, age) { text = Math.round(age / age_unit[bucket]) + " " + age_suffix[bucket]; - // Every age on the page is measured again on each pass, so most of - // them are already reading correctly and writing to them would cost a - // repaint for nothing. + // Every age on the page is measured again on each pass, so most of them + // are already reading correctly and writing to them would cost a repaint + // 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. + // 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]) @@ -56,7 +58,7 @@ function render_age(element, age) { /* * Measures every age on the page against the clock and books the next pass. - * There is no point coming back before the coarsest unit on the page could + * There is no point coming back before the finest unit on the page could * change, so a page already counted in hours is left alone for minutes and * one counted in years for a day. */ @@ -74,9 +76,8 @@ function refresh_ages() { for (i = 0; i < elements.length; i++) { age = now - elements[i].getAttribute("data-ut"); - // A commit dated ahead of the viewer's clock would - // otherwise show a negative age, and ui-shared.c - // clamps it the same way. + // A commit dated ahead of the viewer's clock would otherwise show + // a negative age, and ui-shared.c clamps it the same way. if (age < 0) age = 0; @@ -87,11 +88,7 @@ function refresh_ages() { window.setTimeout(refresh_ages, delay * 1000); } -document.addEventListener("DOMContentLoaded", function () { - // Nothing here depends on layout, so the first pass can run as soon - // as the document is parsed. - refresh_ages(); -}, false); +document.addEventListener("DOMContentLoaded", refresh_ages, false); })(); @@ -136,8 +133,8 @@ function place_bar() { bar.style.height = (bottom - top) + "px"; table.appendChild(bar); - // A browser only scrolls to a fragment that names a real id, which a - // range never does, so bring the start of one into view here. + // A browser only scrolls to a fragment that names a real id, which a range + // never does, so bring the start of one into view here. if (match[2]) first.scrollIntoView({ block: "center" }); } -- cgit v2.8.0