2009-08-15 10:26:12 -04:00
|
|
|
var zeropad = function (num) {
|
|
|
|
return ((num < 10) ? '0' : '') + num;
|
|
|
|
};
|
|
|
|
var iso8601 = function (date) {
|
|
|
|
return date.getUTCFullYear()
|
|
|
|
+ "-" + zeropad(date.getUTCMonth()+1)
|
|
|
|
+ "-" + zeropad(date.getUTCDate())
|
|
|
|
+ "T" + zeropad(date.getUTCHours())
|
|
|
|
+ ":" + zeropad(date.getUTCMinutes())
|
|
|
|
+ ":" + zeropad(date.getUTCSeconds()) + "Z";
|
|
|
|
};
|
|
|
|
|
2009-10-25 20:22:09 -04:00
|
|
|
function prepareDynamicDates() {
|
2009-08-15 10:26:12 -04:00
|
|
|
$('abbr.loaded').attr("title", iso8601(new Date()));
|
|
|
|
$('abbr.modified').attr("title", iso8601(new Date(document.lastModified)));
|
2009-10-25 20:22:09 -04:00
|
|
|
}
|
2009-08-15 10:26:12 -04:00
|
|
|
|
2010-02-28 14:24:23 -05:00
|
|
|
function loadNumbers() {
|
|
|
|
jQuery.timeago.settings.strings.numbers = ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"];
|
|
|
|
}
|
|
|
|
function unloadNumbers() {
|
|
|
|
jQuery.timeago.settings.strings.numbers = [];
|
|
|
|
}
|
|
|
|
|
2010-10-27 08:29:24 -04:00
|
|
|
function loadCutoffSetting() {
|
|
|
|
jQuery.timeago.settings.cutoff = 7*24*60*60*1000;
|
|
|
|
}
|
|
|
|
|
|
|
|
function unloadCutoffSetting() {
|
|
|
|
jQuery.timeago.settings.cutoff = 0;
|
|
|
|
}
|
|
|
|
|
2013-07-30 12:02:17 -04:00
|
|
|
function setupDisposal() {
|
|
|
|
jQuery.timeago.settings.refreshMillis = 50;
|
|
|
|
$('abbr.disposal').attr("title", iso8601(new Date())).timeago();
|
|
|
|
}
|
|
|
|
|
2009-08-15 10:26:12 -04:00
|
|
|
function loadPigLatin() {
|
|
|
|
jQuery.timeago.settings.strings = {
|
|
|
|
suffixAgo: "ago-hay",
|
|
|
|
suffixFromNow: "omNow-fray",
|
|
|
|
seconds: "ess-lay an-thay a-hay inute-may",
|
|
|
|
minute: "about-hay a-hay inute-may",
|
|
|
|
minutes: "%d inutes-may",
|
|
|
|
hour: "about-hay an-hay hour-hay",
|
|
|
|
hours: "about-hay %d hours-hay",
|
|
|
|
day: "a-hay ay-day",
|
|
|
|
days: "%d ays-day",
|
|
|
|
month: "about-hay a-hay onth-may",
|
|
|
|
months: "%d onths-may",
|
|
|
|
year: "about-hay a-hay ear-yay",
|
2012-03-12 10:12:45 -04:00
|
|
|
years: "%d years-yay"
|
2009-08-15 10:26:12 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadRussian() {
|
|
|
|
(function() {
|
|
|
|
function numpf(n, f, s, t) {
|
|
|
|
// f - 1, 21, 31, ...
|
|
|
|
// s - 2-4, 22-24, 32-34 ...
|
|
|
|
// t - 5-20, 25-30, ...
|
|
|
|
var n10 = n % 10;
|
|
|
|
if ( (n10 == 1) && ( (n == 1) || (n > 20) ) ) {
|
|
|
|
return f;
|
|
|
|
} else if ( (n10 > 1) && (n10 < 5) && ( (n > 20) || (n < 10) ) ) {
|
|
|
|
return s;
|
|
|
|
} else {
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
jQuery.timeago.settings.strings = {
|
|
|
|
prefixAgo: null,
|
|
|
|
prefixFromNow: "через",
|
|
|
|
suffixAgo: "назад",
|
|
|
|
suffixFromNow: null,
|
|
|
|
seconds: "меньше минуты",
|
|
|
|
minute: "минуту",
|
|
|
|
minutes: function(value) { return numpf(value, "%d минута", "%d минуты", "%d минут"); },
|
|
|
|
hour: "час",
|
|
|
|
hours: function(value) { return numpf(value, "%d час", "%d часа", "%d часов"); },
|
|
|
|
day: "день",
|
|
|
|
days: function(value) { return numpf(value, "%d день", "%d дня", "%d дней"); },
|
|
|
|
month: "месяц",
|
|
|
|
months: function(value) { return numpf(value, "%d месяц", "%d месяца", "%d месяцев"); },
|
|
|
|
year: "год",
|
2012-03-12 10:12:45 -04:00
|
|
|
years: function(value) { return numpf(value, "%d год", "%d года", "%d лет"); }
|
2009-08-15 10:26:12 -04:00
|
|
|
};
|
|
|
|
})();
|
|
|
|
}
|
|
|
|
|
2013-07-30 12:02:17 -04:00
|
|
|
function resetRefreshMillis() {
|
|
|
|
jQuery.timeago.settings.refreshMillis = 60000;
|
|
|
|
}
|
|
|
|
|
2010-09-14 21:44:55 -04:00
|
|
|
function loadMillis() {
|
|
|
|
var millisSubstitution = function(number, millis) { return millis + " milliseconds"; };
|
|
|
|
jQuery.timeago.settings.strings = {
|
|
|
|
suffixAgo: "ago",
|
|
|
|
suffixFromNow: "from now",
|
|
|
|
seconds: millisSubstitution,
|
|
|
|
minute: millisSubstitution,
|
|
|
|
minutes: millisSubstitution,
|
|
|
|
hour: millisSubstitution,
|
|
|
|
hours: millisSubstitution,
|
|
|
|
day: millisSubstitution,
|
|
|
|
days: millisSubstitution,
|
|
|
|
month: millisSubstitution,
|
|
|
|
months: millisSubstitution,
|
|
|
|
year: millisSubstitution,
|
|
|
|
years: millisSubstitution
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2012-03-03 15:15:18 -05:00
|
|
|
function loadNoSpaces() {
|
|
|
|
jQuery.extend(jQuery.timeago.settings.strings, {
|
|
|
|
minutes: "%dminutes",
|
|
|
|
wordSeparator: ""
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-12-27 10:37:26 -05:00
|
|
|
function loadNullSpaces() {
|
|
|
|
jQuery.extend(jQuery.timeago.settings.strings, {
|
|
|
|
minutes: "%dminutes",
|
|
|
|
wordSeparator: null
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2009-08-15 10:26:12 -04:00
|
|
|
function loadYoungOldYears() {
|
|
|
|
jQuery.extend(jQuery.timeago.settings.strings, {
|
|
|
|
years: function(value) { return (value < 21) ? "%d young years" : "%d old years"; }
|
|
|
|
});
|
|
|
|
}
|
2014-02-25 11:35:21 -05:00
|
|
|
|
|
|
|
function loadDoNotAllowFuture() {
|
|
|
|
var mockDateToUse = "2010-01-01";
|
|
|
|
$.timeago.settings.allowFuture = false;
|
|
|
|
enableMockedDate(mockDateToUse);
|
|
|
|
}
|
|
|
|
|
|
|
|
function unloadDoNotAllowFuture() {
|
|
|
|
$.timeago.settings.allowFuture = true;
|
|
|
|
disableMockedDate();
|
|
|
|
}
|
|
|
|
|
|
|
|
function enableMockedDate(dateToReturn) {
|
|
|
|
var mockDate = dateToReturn;
|
|
|
|
window.NativeDate = Date;
|
|
|
|
window.Date = function () {
|
|
|
|
if(arguments.length === 0) {
|
|
|
|
return new window.NativeDate(mockDate);
|
|
|
|
} else if(arguments.length === 1) {
|
|
|
|
return new window.NativeDate(arguments[0]);
|
|
|
|
} else if(arguments.length === 7) {
|
|
|
|
return new window.NativeDate(arguments[0], arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6]);
|
|
|
|
} else {
|
|
|
|
throw "Mocking Date with this number of parameters is not implemented.";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function disableMockedDate() {
|
|
|
|
window.Date = window.NativeDate;
|
|
|
|
delete window.NativeDate;
|
|
|
|
}
|