From d98c272f35a53f41eec911e773495ca8f00a4d8a Mon Sep 17 00:00:00 2001 From: David Horscroft Date: Wed, 19 Oct 2016 13:02:54 +0200 Subject: [PATCH 1/2] added "secondaryFuzzing" support, to allow customized post-processing --- jquery.timeago.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/jquery.timeago.js b/jquery.timeago.js index 264b7317..ed06ac55 100644 --- a/jquery.timeago.js +++ b/jquery.timeago.js @@ -65,6 +65,14 @@ years: "%d years", wordSeparator: " ", numbers: [] + }, + /** + * Secondary Fuzzing routine for post-processing. + * Should take in the element in question, the originally intended TimeAgo text and the distanceMillis between + * now and the given date. + */ + secondaryFuzzing: function(el, originalText, distanceMillis) { + return originalText; } }, @@ -193,7 +201,12 @@ if (!isNaN(data.datetime)) { if ( $s.cutoff === 0 || Math.abs(distance(data.datetime)) < $s.cutoff) { - $(this).text(inWords(data.datetime)); + if ($.timeago.settings.secondaryFuzzing) { + var datetime = data.datetime; + $(this).text($.timeago.settings.secondaryFuzzing(this, inWords(datetime), distance(datetime))); + } else { + $(this).text(inWords(data.datetime)); + } } else { if ($(this).attr('title').length > 0) { $(this).text($(this).attr('title')); From 3c8b91b4068276a72c31c580e56e56fe292f7af2 Mon Sep 17 00:00:00 2001 From: David Horscroft Date: Wed, 19 Oct 2016 13:12:42 +0200 Subject: [PATCH 2/2] changed to default to false --- jquery.timeago.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/jquery.timeago.js b/jquery.timeago.js index ed06ac55..5b0a2b3d 100644 --- a/jquery.timeago.js +++ b/jquery.timeago.js @@ -70,10 +70,12 @@ * Secondary Fuzzing routine for post-processing. * Should take in the element in question, the originally intended TimeAgo text and the distanceMillis between * now and the given date. + * + * function(el, originalText, distanceMillis) { + * return originalText; + * } */ - secondaryFuzzing: function(el, originalText, distanceMillis) { - return originalText; - } + secondaryFuzzing: false }, inWords: function(distanceMillis) {