diff --git a/client/html/home.hbs b/client/html/home.hbs index fc476b50..3c7bcf93 100644 --- a/client/html/home.hbs +++ b/client/html/home.hbs @@ -1,5 +1,5 @@

{{name}}

- +
diff --git a/client/js/main.js b/client/js/main.js index c031edf8..6f386ffd 100644 --- a/client/js/main.js +++ b/client/js/main.js @@ -1,5 +1,7 @@ 'use strict'; +require('./util/handlebars-helpers.js'); + // ---------------------- // - import controllers - // ---------------------- diff --git a/client/js/util/handlebars-helpers.js b/client/js/util/handlebars-helpers.js new file mode 100644 index 00000000..8d121d51 --- /dev/null +++ b/client/js/util/handlebars-helpers.js @@ -0,0 +1,15 @@ +'use strict'; + +const handlebars = require('handlebars'); +const misc = require('./misc.js'); + +handlebars.registerHelper('reltime', function(options) { + return new handlebars.SafeString( + ''); +}); diff --git a/client/js/util.js b/client/js/util/misc.js similarity index 52% rename from client/js/util.js rename to client/js/util/misc.js index 0933410c..39e90dbb 100644 --- a/client/js/util.js +++ b/client/js/util/misc.js @@ -11,17 +11,17 @@ function formatRelativeTime(timeString) { const future = now < then; const descriptions = [ - [60, 'a few seconds', null], - [60*2, 'a minute', null], - [60*60, '% minutes', 60], - [60*60*2, 'an hour', null], - [60*60*24, '% hours', 60*60], - [60*60*24*2, 'a day', null], - [60*60*24*30.42, '% days', 60*60*24], - [60*60*24*30.42*2, 'a month', null], - [60*60*24*30.42*12, '% months', 60*60*24*30.42], - [60*60*24*30.42*12*2, 'a year', null], - [8640000000000000/*max*/, '% years', 60*60*24*30.42*12], + [60, 'a few seconds', null], + [60 * 2, 'a minute', null], + [60 * 60, '% minutes', 60], + [60 * 60 * 2, 'an hour', null], + [60 * 60 * 24, '% hours', 60 * 60], + [60 * 60 * 24 * 2, 'a day', null], + [60 * 60 * 24 * 30.42, '% days', 60 * 60 * 24], + [60 * 60 * 24 * 30.42 * 2, 'a month', null], + [60 * 60 * 24 * 30.42 * 12, '% months', 60 * 60 * 24 * 30.42], + [60 * 60 * 24 * 30.42 * 12 * 2, 'a year', null], + [8640000000000000 /*max*/, '% years', 60 * 60 * 24 * 30.42 * 12], ]; let text = null; diff --git a/client/js/views/home_view.js b/client/js/views/home_view.js index 4beca603..1f1f0f47 100644 --- a/client/js/views/home_view.js +++ b/client/js/views/home_view.js @@ -1,6 +1,5 @@ 'use strict'; -const util = require('../util.js'); const config = require('../config.js'); const BaseView = require('./base_view.js'); @@ -14,7 +13,7 @@ class HomeView extends BaseView { this.showView(this.template({ name: config.basic.name, version: config.meta.version, - buildDate: util.formatRelativeTime(config.meta.buildDate), + buildDate: config.meta.buildDate, })); } }