diff options
| author | julian laplace <julescarbon@gmail.com> | 2022-10-25 23:26:31 +0200 |
|---|---|---|
| committer | julian laplace <julescarbon@gmail.com> | 2022-10-25 23:26:31 +0200 |
| commit | 1cfed2612fd1042a15d470a44ec87588c966dc12 (patch) | |
| tree | ba850f589194a21fd1587dd71dfcd056a242e4ac /public/assets/js/util/format.js | |
| parent | ae311b71cccf5df9e0e19e276615cc32426d9de1 (diff) | |
hootstream... dark mode only
Diffstat (limited to 'public/assets/js/util/format.js')
| -rw-r--r-- | public/assets/js/util/format.js | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/public/assets/js/util/format.js b/public/assets/js/util/format.js index 6a23430..e6104e5 100644 --- a/public/assets/js/util/format.js +++ b/public/assets/js/util/format.js @@ -257,6 +257,29 @@ function get_age(t, long) { age /= 12; return r(age) + (long ? " years" : "y"); } +const ages = { + newest: 60 * 10, + newer: 60 * 60, + new: 60 * 60 * 8, + cool: 60 * 60 * 24, + cold: 60 * 60 * 24 * 7, + colder: 60 * 60 * 24 * 7 * 4, + coldest: 60 * 60 * 24 * 7 * 4 * 12, +}; +function get_age_opacity(t) { + var age = Math.abs(Date.now() / 1000 - t); + if (age < ages.newest) return 1; + if (age < ages.newer) + return lerp(norm(age, ages.newest, ages.newer), 1.0, 0.95); + if (age < ages.new) return lerp(norm(age, ages.newer, ages.new), 0.95, 0.9); + if (age < ages.cool) return lerp(norm(age, ages.new, ages.cool), 0.9, 0.85); + if (age < ages.cold) return lerp(norm(age, ages.cool, ages.cold), 0.85, 0.6); + if (age < ages.colder) + return lerp(norm(age, ages.cold, ages.colder), 0.6, 0.5); + if (age < ages.coldest) + return lerp(norm(age, ages.colder, ages.coldest), 0.5, 0.4); + return 0.39; +} function tidy_urls(s, short_urls) { var ret = s |
