framework/js/old/common/utils/liveHumanTimes.js

19 lines
439 B
JavaScript
Raw Normal View History

import humanTimeUtil from './humanTime';
function updateHumanTimes() {
2020-04-17 11:57:55 +02:00
$('[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, 10000);
}