!function(t){"function"==typeof define&&define.amd?define(["jquery","moment"],t):t(jQuery,moment)}(function(o,m){function a(t,e){var a=t.data("livestampdata");"number"==typeof e&&(e*=1e3),t.removeAttr("data-livestamp").removeData("livestamp"),e=m(e),m.isMoment(e)&&!isNaN(+e)&&((a=o.extend({},{original:t.contents()},a)).moment=m(e),t.data("livestampdata",a).empty(),u.push(t[0]))}function t(){n||(i.update(),setTimeout(t,e))}var e=1e3,n=!1,u=o([]),i={update:function(){o("[data-livestamp]").each(function(){var t=o(this);a(t,t.data("livestamp"))});var i=[];u.each(function(){var t,e,a=o(this),n=a.data("livestampdata");void 0===n?i.push(this):m.isMoment(n.moment)&&(t=a.html())!=(n=n.moment.fromNow())&&(e=o.Event("change.livestamp"),a.trigger(e,[t,n]),e.isDefaultPrevented()||a.html(n))}),delete(u=u.not(i)).prevObject},pause:function(){n=!0},resume:function(){n=!1,t()},interval:function(t){if(void 0===t)return e;e=t}},r={add:function(t,e){return"number"==typeof e&&(e*=1e3),e=m(e),m.isMoment(e)&&!isNaN(+e)&&(t.each(function(){a(o(this),e)}),i.update()),t},destroy:function(a){return u=u.not(a),a.each(function(){var t=o(this),e=t.data("livestampdata");if(void 0===e)return a;t.html(e.original||"").removeData("livestampdata")}),a},isLivestamp:function(t){return void 0!==t.data("livestampdata")}};o.livestamp=i,o(function(){i.resume()}),o.fn.livestamp=function(t,e){return r[t]||(e=t,t="add"),r[t](this,e)}});