[IMP] continue refactoring timeago.js, following the conversation on this pull request: https://github.com/rmm5t/jquery-timeago/pull/83
- remove bad usage of global variable stringAndNumber - use a consistent name for the substitute() function which was actully not substituing anything anymore bzr revid: abo@openerp.com-20120625172055-5njlig9lukjuf8yd
This commit is contained in:
parent
cc2d116e47
commit
9112bc7db1
|
@ -3,7 +3,6 @@
|
|||
* updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").
|
||||
*
|
||||
* Please note that the library has been slightly modified for i18n's sake.
|
||||
*
|
||||
*
|
||||
* @name timeago
|
||||
* @version 0.11.3
|
||||
|
@ -72,24 +71,24 @@
|
|||
var days = hours / 24;
|
||||
var years = days / 365;
|
||||
|
||||
function substitute(stringOrFunction, number) {
|
||||
function convert(stringOrFunction, number) {
|
||||
var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction;
|
||||
|
||||
// return the proper string and the numeric value that goes in it
|
||||
return stringAndNumber = {'string': string, 'value': ($l.numbers && $l.numbers[number]) || number};
|
||||
return {'string': string, 'value': ($l.numbers && $l.numbers[number]) || number};
|
||||
}
|
||||
|
||||
var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||
|
||||
seconds < 90 && substitute($l.minute, 1) ||
|
||||
minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||
|
||||
minutes < 90 && substitute($l.hour, 1) ||
|
||||
hours < 24 && substitute($l.hours, Math.round(hours)) ||
|
||||
hours < 42 && substitute($l.day, 1) ||
|
||||
days < 30 && substitute($l.days, Math.round(days)) ||
|
||||
days < 45 && substitute($l.month, 1) ||
|
||||
days < 365 && substitute($l.months, Math.round(days / 30)) ||
|
||||
years < 1.5 && substitute($l.year, 1) ||
|
||||
substitute($l.years, Math.round(years));
|
||||
var stringAndNumber = seconds < 45 && convert($l.seconds, Math.round(seconds)) ||
|
||||
seconds < 90 && convert($l.minute, 1) ||
|
||||
minutes < 45 && convert($l.minutes, Math.round(minutes)) ||
|
||||
minutes < 90 && convert($l.hour, 1) ||
|
||||
hours < 24 && convert($l.hours, Math.round(hours)) ||
|
||||
hours < 42 && convert($l.day, 1) ||
|
||||
days < 30 && convert($l.days, Math.round(days)) ||
|
||||
days < 45 && convert($l.month, 1) ||
|
||||
days < 365 && convert($l.months, Math.round(days / 30)) ||
|
||||
years < 1.5 && convert($l.year, 1) ||
|
||||
convert($l.years, Math.round(years));
|
||||
|
||||
var string = stringAndNumber.string;
|
||||
var value = stringAndNumber.value;
|
||||
|
|
Loading…
Reference in New Issue