-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathactivity-monitor.min.js
1 lines (1 loc) · 2.05 KB
/
activity-monitor.min.js
1
"use strict";!function(n,e){"undefined"!=typeof module&&module.exports?(e("undefined"==typeof angular?require("angular"):angular),module.exports="ActivityMonitor"):"function"==typeof define&&define.amd?define(["angular"],e):e(n.angular)}(this,function(n){function e(n){function e(){w.options.enabled=!1,i(),n.off(w.options.DOMevents.join(" "),f)}function i(){clearInterval(A.inactivity),clearInterval(A.keepAlive),delete A.inactivity,delete A.keepAlive}function c(){n.on(w.options.DOMevents.join(" "),f),w.options.enabled=!0,w.user.warning=!1,s()}function s(){A.keepAlive=setInterval(function(){d(o)},w.options.keepAlive*t),A.inactivity=setInterval(function(){var n=Date.now(),o=n-(w.options.inactive-w.options.warning)*t,u=n-w.options.inactive*t;!w.user.warning&&w.user.action<=o&&(w.user.warning=!0,d(r)),w.user.active&&w.user.action<=u&&(w.user.active=!1,d(a),w.options.disableOnInactive?e():(i(),l=v))},w.options.monitor*t)}function l(){p()}function v(){s(),l=p}function f(){l()}function p(){w.user.active=!0,w.user.action=Date.now(),d(u),w.user.warning&&(w.user.warning=!1,d(o))}function d(n){if(w.options.enabled){var e=Object.keys(b[n]);n&&e.length&&e.forEach(function(e){b[n][e]&&b[n][e]()})}}function m(n,e){n&&"function"==typeof e&&(n=y(n,e),b[n.name][n.space]=e,!w.options.enabled&&c())}function g(n,e){return n=y(n,e),n.space?void(b[n.name][n.space]=null):void(b[n.name]={})}function y(n,e){return n=n.split("."),n[1]||"function"!=typeof e||(n[1]=e.toString().substr(0,150).replace(/\r?\n|\r|\s+/gm,"")),{name:n[0],space:n[1]}}var w=this;w.options={enabled:!1,keepAlive:800,inactive:900,warning:60,monitor:3,disableOnInactive:!0,DOMevents:["mousemove","mousedown","mouseup","keypress","wheel","touchstart","scroll"]},w.user={action:Date.now(),active:!0,warning:!1},w.activity=f,w.on=w.bind=m,w.off=w.unbind=g;var b={};b[o]={},b[a]={},b[r]={},b[u]={};var A={inactivity:null,keepAlive:null};return c.timer=A,w.enable=c,w.disable=e,w}var i=n.module("ActivityMonitor",[]).service("ActivityMonitor",e),t=1e3,o="keepAlive",a="inactive",r="warning",u="activity";return e.$inject=["$document"],i});