Draft Forbes Group Website (Build by Nikola). The official site is hosted at:
License: GPL3
ubuntu2004
/**1* Timeago is a jQuery plugin that makes it easy to support automatically2* updating fuzzy timestamps (e.g. "4 minutes ago" or "about 1 day ago").3*4* @name timeago5* @version 1.3.06* @requires jQuery v1.2.3+7* @author Ryan McGeary8* @license MIT License - http://www.opensource.org/licenses/mit-license.php9*10* For usage and examples, visit:11* http://timeago.yarp.com/12*13* Copyright (c) 2008-2013, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)14*/1516(function (factory) {17if (typeof define === 'function' && define.amd) {18// AMD. Register as an anonymous module.19define(['jquery'], factory);20} else {21// Browser globals22factory(jQuery);23}24}(function ($) {25$.timeago = function(timestamp) {26if (timestamp instanceof Date) {27return inWords(timestamp);28} else if (typeof timestamp === "string") {29return inWords($.timeago.parse(timestamp));30} else if (typeof timestamp === "number") {31return inWords(new Date(timestamp));32} else {33return inWords($.timeago.datetime(timestamp));34}35};36var $t = $.timeago;3738$.extend($.timeago, {39settings: {40refreshMillis: 60000,41allowFuture: false,42localeTitle: false,43cutoff: 0,44strings: {45prefixAgo: null,46prefixFromNow: null,47suffixAgo: "ago",48suffixFromNow: "from now",49seconds: "less than a minute",50minute: "about a minute",51minutes: "%d minutes",52hour: "about an hour",53hours: "about %d hours",54day: "a day",55days: "%d days",56month: "about a month",57months: "%d months",58year: "about a year",59years: "%d years",60wordSeparator: " ",61numbers: []62}63},64inWords: function(distanceMillis) {65var $l = this.settings.strings;66var prefix = $l.prefixAgo;67var suffix = $l.suffixAgo;68if (this.settings.allowFuture) {69if (distanceMillis < 0) {70prefix = $l.prefixFromNow;71suffix = $l.suffixFromNow;72}73}7475var seconds = Math.abs(distanceMillis) / 1000;76var minutes = seconds / 60;77var hours = minutes / 60;78var days = hours / 24;79var years = days / 365;8081function substitute(stringOrFunction, number) {82var string = $.isFunction(stringOrFunction) ? stringOrFunction(number, distanceMillis) : stringOrFunction;83var value = ($l.numbers && $l.numbers[number]) || number;84return string.replace(/%d/i, value);85}8687var words = seconds < 45 && substitute($l.seconds, Math.round(seconds)) ||88seconds < 90 && substitute($l.minute, 1) ||89minutes < 45 && substitute($l.minutes, Math.round(minutes)) ||90minutes < 90 && substitute($l.hour, 1) ||91hours < 24 && substitute($l.hours, Math.round(hours)) ||92hours < 42 && substitute($l.day, 1) ||93days < 30 && substitute($l.days, Math.round(days)) ||94days < 45 && substitute($l.month, 1) ||95days < 365 && substitute($l.months, Math.round(days / 30)) ||96years < 1.5 && substitute($l.year, 1) ||97substitute($l.years, Math.round(years));9899var separator = $l.wordSeparator || "";100if ($l.wordSeparator === undefined) { separator = " "; }101return $.trim([prefix, words, suffix].join(separator));102},103parse: function(iso8601) {104var s = $.trim(iso8601);105s = s.replace(/\.\d+/,""); // remove milliseconds106s = s.replace(/-/,"/").replace(/-/,"/");107s = s.replace(/T/," ").replace(/Z/," UTC");108s = s.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2"); // -04:00 -> -0400109return new Date(s);110},111datetime: function(elem) {112var iso8601 = $t.isTime(elem) ? $(elem).attr("datetime") : $(elem).attr("title");113return $t.parse(iso8601);114},115isTime: function(elem) {116// jQuery's `is()` doesn't play well with HTML5 in IE117return $(elem).get(0).tagName.toLowerCase() === "time"; // $(elem).is("time");118}119});120121// functions that can be called via $(el).timeago('action')122// init is default when no action is given123// functions are called with context of a single element124var functions = {125init: function(){126var refresh_el = $.proxy(refresh, this);127refresh_el();128var $s = $t.settings;129if ($s.refreshMillis > 0) {130setInterval(refresh_el, $s.refreshMillis);131}132},133update: function(time){134$(this).data('timeago', { datetime: $t.parse(time) });135refresh.apply(this);136},137updateFromDOM: function(){138$(this).data('timeago', { datetime: $t.parse( $t.isTime(this) ? $(this).attr("datetime") : $(this).attr("title") ) });139refresh.apply(this);140}141};142143$.fn.timeago = function(action, options) {144var fn = action ? functions[action] : functions.init;145if(!fn){146throw new Error("Unknown function name '"+ action +"' for timeago");147}148// each over objects here and call the requested function149this.each(function(){150fn.call(this, options);151});152return this;153};154155function refresh() {156var data = prepareData(this);157var $s = $t.settings;158159if (!isNaN(data.datetime)) {160if ( $s.cutoff == 0 || distance(data.datetime) < $s.cutoff) {161$(this).text(inWords(data.datetime));162}163}164return this;165}166167function prepareData(element) {168element = $(element);169if (!element.data("timeago")) {170element.data("timeago", { datetime: $t.datetime(element) });171var text = $.trim(element.text());172if ($t.settings.localeTitle) {173element.attr("title", element.data('timeago').datetime.toLocaleString());174} else if (text.length > 0 && !($t.isTime(element) && element.attr("title"))) {175element.attr("title", text);176}177}178return element.data("timeago");179}180181function inWords(date) {182return $t.inWords(distance(date));183}184185function distance(date) {186return (new Date().getTime() - date.getTime());187}188189// fix for IE6 suckage190document.createElement("abbr");191document.createElement("time");192}));193194195