Mercurial Hosting > chat
comparison src/site.js @ 88:7b339b1ccd11
add tools/users.html
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Thu, 13 Mar 2025 16:18:39 -0600 |
| parents | dade6a560494 |
| children |
comparison
equal
deleted
inserted
replaced
| 87:246a792adedf | 88:7b339b1ccd11 |
|---|---|
| 88 } | 88 } |
| 89 | 89 |
| 90 function closeModal(el) { | 90 function closeModal(el) { |
| 91 getEnclosingDialog(el).close(); | 91 getEnclosingDialog(el).close(); |
| 92 } | 92 } |
| 93 | |
| 94 let times = [ | |
| 95 { | |
| 96 time: 1000*60*60*24, | |
| 97 unit: 'day' | |
| 98 }, | |
| 99 { | |
| 100 time: 1000*60*60, | |
| 101 unit: 'hour' | |
| 102 }, | |
| 103 { | |
| 104 time: 1000*60, | |
| 105 unit: 'minute' | |
| 106 }, | |
| 107 { | |
| 108 time: 1000, | |
| 109 unit: 'second' | |
| 110 } | |
| 111 ]; | |
| 112 | |
| 113 function ago(time) { | |
| 114 for( let t of times ) { | |
| 115 let n = Math.floor(time / t.time); | |
| 116 if( n > 0 ) { | |
| 117 let s = `${n} ${t.unit}`; | |
| 118 if( n > 1 ) | |
| 119 s = s + 's'; | |
| 120 return s + ' ago'; | |
| 121 } | |
| 122 } | |
| 123 return 'just now'; | |
| 124 } |
