- var self = this,
- running,
- beat,
- screenId = typeof pagenow != 'undefined' ? pagenow : '',
- url = typeof ajaxurl != 'undefined' ? ajaxurl : '',
- settings,
- tick = 0,
- queue = {},
- interval,
- connecting,
- countdown = 0,
- errorcount = 0,
- tempInterval,
- hasFocus = true,
- isUserActive,
- userActiveEvents,
- winBlurTimeout,
- frameBlurTimeout = -1,
- hasConnectionError = false;
+ var $document = $(document),
+ settings = {
+ // Suspend/resume
+ suspend: false,
+
+ // Whether suspending is enabled
+ suspendEnabled: true,
+
+ // Current screen id, defaults to the JS global 'pagenow' when present (in the admin) or 'front'
+ screenId: '',
+
+ // XHR request URL, defaults to the JS global 'ajaxurl' when present
+ url: '',
+
+ // Timestamp, start of the last connection request
+ lastTick: 0,
+
+ // Container for the enqueued items
+ queue: {},
+
+ // Connect interval (in seconds)
+ mainInterval: 60,
+
+ // Used when the interval is set to 5 sec. temporarily
+ tempInterval: 0,
+
+ // Used when the interval is reset
+ originalInterval: 0,
+
+ // Used to limit the number of AJAX requests.
+ minimalInterval: 0,
+
+ // Used together with tempInterval
+ countdown: 0,
+
+ // Whether a connection is currently in progress
+ connecting: false,
+
+ // Whether a connection error occurred
+ connectionError: false,
+
+ // Used to track non-critical errors
+ errorcount: 0,
+
+ // Whether at least one connection has completed successfully
+ hasConnected: false,
+
+ // Whether the current browser window is in focus and the user is active
+ hasFocus: true,
+
+ // Timestamp, last time the user was active. Checked every 30 sec.
+ userActivity: 0,
+
+ // Flags whether events tracking user activity were set
+ userActivityEvents: false,
+
+ checkFocusTimer: 0,
+ beatTimer: 0
+ };