mirror of
https://github.com/flarum/framework.git
synced 2025-05-22 14:49:57 +08:00
Massive JavaScript cleanup
- Use JSX for templates - Docblock/comment everything - Mostly passes ESLint (still some work to do) - Lots of renaming, refactoring, etc. CSS hasn't been updated yet.
This commit is contained in:
18
js/lib/initializers/humanTime.js
Normal file
18
js/lib/initializers/humanTime.js
Normal file
@ -0,0 +1,18 @@
|
||||
import humanTimeUtil from 'flarum/utils/humanTime';
|
||||
|
||||
function updateHumanTimes() {
|
||||
$('[data-humantime]').each(function() {
|
||||
const $this = $(this);
|
||||
const ago = humanTimeUtil($this.attr('datetime'));
|
||||
|
||||
$this.html(ago);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* The `humanTime` initializer sets up a loop every 1 second to update
|
||||
* timestamps rendered with the `humanTime` helper.
|
||||
*/
|
||||
export default function humanTime() {
|
||||
setInterval(updateHumanTimes, 1000);
|
||||
}
|
Reference in New Issue
Block a user