Edit File by line
/home/barbar84/public_h.../wp-inclu.../js
File: heartbeat.js
/**
[0] Fix | Delete
* Heartbeat API
[1] Fix | Delete
*
[2] Fix | Delete
* Heartbeat is a simple server polling API that sends XHR requests to
[3] Fix | Delete
* the server every 15 - 60 seconds and triggers events (or callbacks) upon
[4] Fix | Delete
* receiving data. Currently these 'ticks' handle transports for post locking,
[5] Fix | Delete
* login-expiration warnings, autosave, and related tasks while a user is logged in.
[6] Fix | Delete
*
[7] Fix | Delete
* Available PHP filters (in ajax-actions.php):
[8] Fix | Delete
* - heartbeat_received
[9] Fix | Delete
* - heartbeat_send
[10] Fix | Delete
* - heartbeat_tick
[11] Fix | Delete
* - heartbeat_nopriv_received
[12] Fix | Delete
* - heartbeat_nopriv_send
[13] Fix | Delete
* - heartbeat_nopriv_tick
[14] Fix | Delete
* @see wp_ajax_nopriv_heartbeat(), wp_ajax_heartbeat()
[15] Fix | Delete
*
[16] Fix | Delete
* Custom jQuery events:
[17] Fix | Delete
* - heartbeat-send
[18] Fix | Delete
* - heartbeat-tick
[19] Fix | Delete
* - heartbeat-error
[20] Fix | Delete
* - heartbeat-connection-lost
[21] Fix | Delete
* - heartbeat-connection-restored
[22] Fix | Delete
* - heartbeat-nonces-expired
[23] Fix | Delete
*
[24] Fix | Delete
* @since 3.6.0
[25] Fix | Delete
* @output wp-includes/js/heartbeat.js
[26] Fix | Delete
*/
[27] Fix | Delete
[28] Fix | Delete
( function( $, window, undefined ) {
[29] Fix | Delete
[30] Fix | Delete
/**
[31] Fix | Delete
* Constructs the Heartbeat API.
[32] Fix | Delete
*
[33] Fix | Delete
* @since 3.6.0
[34] Fix | Delete
*
[35] Fix | Delete
* @return {Object} An instance of the Heartbeat class.
[36] Fix | Delete
* @constructor
[37] Fix | Delete
*/
[38] Fix | Delete
var Heartbeat = function() {
[39] Fix | Delete
var $document = $(document),
[40] Fix | Delete
settings = {
[41] Fix | Delete
// Suspend/resume.
[42] Fix | Delete
suspend: false,
[43] Fix | Delete
[44] Fix | Delete
// Whether suspending is enabled.
[45] Fix | Delete
suspendEnabled: true,
[46] Fix | Delete
[47] Fix | Delete
// Current screen id, defaults to the JS global 'pagenow' when present
[48] Fix | Delete
// (in the admin) or 'front'.
[49] Fix | Delete
screenId: '',
[50] Fix | Delete
[51] Fix | Delete
// XHR request URL, defaults to the JS global 'ajaxurl' when present.
[52] Fix | Delete
url: '',
[53] Fix | Delete
[54] Fix | Delete
// Timestamp, start of the last connection request.
[55] Fix | Delete
lastTick: 0,
[56] Fix | Delete
[57] Fix | Delete
// Container for the enqueued items.
[58] Fix | Delete
queue: {},
[59] Fix | Delete
[60] Fix | Delete
// Connect interval (in seconds).
[61] Fix | Delete
mainInterval: 60,
[62] Fix | Delete
[63] Fix | Delete
// Used when the interval is set to 5 seconds temporarily.
[64] Fix | Delete
tempInterval: 0,
[65] Fix | Delete
[66] Fix | Delete
// Used when the interval is reset.
[67] Fix | Delete
originalInterval: 0,
[68] Fix | Delete
[69] Fix | Delete
// Used to limit the number of Ajax requests.
[70] Fix | Delete
minimalInterval: 0,
[71] Fix | Delete
[72] Fix | Delete
// Used together with tempInterval.
[73] Fix | Delete
countdown: 0,
[74] Fix | Delete
[75] Fix | Delete
// Whether a connection is currently in progress.
[76] Fix | Delete
connecting: false,
[77] Fix | Delete
[78] Fix | Delete
// Whether a connection error occurred.
[79] Fix | Delete
connectionError: false,
[80] Fix | Delete
[81] Fix | Delete
// Used to track non-critical errors.
[82] Fix | Delete
errorcount: 0,
[83] Fix | Delete
[84] Fix | Delete
// Whether at least one connection has been completed successfully.
[85] Fix | Delete
hasConnected: false,
[86] Fix | Delete
[87] Fix | Delete
// Whether the current browser window is in focus and the user is active.
[88] Fix | Delete
hasFocus: true,
[89] Fix | Delete
[90] Fix | Delete
// Timestamp, last time the user was active. Checked every 30 seconds.
[91] Fix | Delete
userActivity: 0,
[92] Fix | Delete
[93] Fix | Delete
// Flag whether events tracking user activity were set.
[94] Fix | Delete
userActivityEvents: false,
[95] Fix | Delete
[96] Fix | Delete
// Timer that keeps track of how long a user has focus.
[97] Fix | Delete
checkFocusTimer: 0,
[98] Fix | Delete
[99] Fix | Delete
// Timer that keeps track of how long needs to be waited before connecting to
[100] Fix | Delete
// the server again.
[101] Fix | Delete
beatTimer: 0
[102] Fix | Delete
};
[103] Fix | Delete
[104] Fix | Delete
/**
[105] Fix | Delete
* Sets local variables and events, then starts the heartbeat.
[106] Fix | Delete
*
[107] Fix | Delete
* @since 3.8.0
[108] Fix | Delete
* @access private
[109] Fix | Delete
*
[110] Fix | Delete
* @return {void}
[111] Fix | Delete
*/
[112] Fix | Delete
function initialize() {
[113] Fix | Delete
var options, hidden, visibilityState, visibilitychange;
[114] Fix | Delete
[115] Fix | Delete
if ( typeof window.pagenow === 'string' ) {
[116] Fix | Delete
settings.screenId = window.pagenow;
[117] Fix | Delete
}
[118] Fix | Delete
[119] Fix | Delete
if ( typeof window.ajaxurl === 'string' ) {
[120] Fix | Delete
settings.url = window.ajaxurl;
[121] Fix | Delete
}
[122] Fix | Delete
[123] Fix | Delete
// Pull in options passed from PHP.
[124] Fix | Delete
if ( typeof window.heartbeatSettings === 'object' ) {
[125] Fix | Delete
options = window.heartbeatSettings;
[126] Fix | Delete
[127] Fix | Delete
// The XHR URL can be passed as option when window.ajaxurl is not set.
[128] Fix | Delete
if ( ! settings.url && options.ajaxurl ) {
[129] Fix | Delete
settings.url = options.ajaxurl;
[130] Fix | Delete
}
[131] Fix | Delete
[132] Fix | Delete
/*
[133] Fix | Delete
* The interval can be from 15 to 120 seconds and can be set temporarily to 5 seconds.
[134] Fix | Delete
* It can be set in the initial options or changed later through JS and/or through PHP.
[135] Fix | Delete
*/
[136] Fix | Delete
if ( options.interval ) {
[137] Fix | Delete
settings.mainInterval = options.interval;
[138] Fix | Delete
[139] Fix | Delete
if ( settings.mainInterval < 15 ) {
[140] Fix | Delete
settings.mainInterval = 15;
[141] Fix | Delete
} else if ( settings.mainInterval > 120 ) {
[142] Fix | Delete
settings.mainInterval = 120;
[143] Fix | Delete
}
[144] Fix | Delete
}
[145] Fix | Delete
[146] Fix | Delete
/*
[147] Fix | Delete
* Used to limit the number of Ajax requests. Overrides all other intervals
[148] Fix | Delete
* if they are shorter. Needed for some hosts that cannot handle frequent requests
[149] Fix | Delete
* and the user may exceed the allocated server CPU time, etc. The minimal interval
[150] Fix | Delete
* can be up to 600 seconds, however setting it to longer than 120 seconds
[151] Fix | Delete
* will limit or disable some of the functionality (like post locks).
[152] Fix | Delete
* Once set at initialization, minimalInterval cannot be changed/overridden.
[153] Fix | Delete
*/
[154] Fix | Delete
if ( options.minimalInterval ) {
[155] Fix | Delete
options.minimalInterval = parseInt( options.minimalInterval, 10 );
[156] Fix | Delete
settings.minimalInterval = options.minimalInterval > 0 && options.minimalInterval <= 600 ? options.minimalInterval * 1000 : 0;
[157] Fix | Delete
}
[158] Fix | Delete
[159] Fix | Delete
if ( settings.minimalInterval && settings.mainInterval < settings.minimalInterval ) {
[160] Fix | Delete
settings.mainInterval = settings.minimalInterval;
[161] Fix | Delete
}
[162] Fix | Delete
[163] Fix | Delete
// 'screenId' can be added from settings on the front end where the JS global
[164] Fix | Delete
// 'pagenow' is not set.
[165] Fix | Delete
if ( ! settings.screenId ) {
[166] Fix | Delete
settings.screenId = options.screenId || 'front';
[167] Fix | Delete
}
[168] Fix | Delete
[169] Fix | Delete
if ( options.suspension === 'disable' ) {
[170] Fix | Delete
settings.suspendEnabled = false;
[171] Fix | Delete
}
[172] Fix | Delete
}
[173] Fix | Delete
[174] Fix | Delete
// Convert to milliseconds.
[175] Fix | Delete
settings.mainInterval = settings.mainInterval * 1000;
[176] Fix | Delete
settings.originalInterval = settings.mainInterval;
[177] Fix | Delete
[178] Fix | Delete
/*
[179] Fix | Delete
* Switch the interval to 120 seconds by using the Page Visibility API.
[180] Fix | Delete
* If the browser doesn't support it (Safari < 7, Android < 4.4, IE < 10), the
[181] Fix | Delete
* interval will be increased to 120 seconds after 5 minutes of mouse and keyboard
[182] Fix | Delete
* inactivity.
[183] Fix | Delete
*/
[184] Fix | Delete
if ( typeof document.hidden !== 'undefined' ) {
[185] Fix | Delete
hidden = 'hidden';
[186] Fix | Delete
visibilitychange = 'visibilitychange';
[187] Fix | Delete
visibilityState = 'visibilityState';
[188] Fix | Delete
} else if ( typeof document.msHidden !== 'undefined' ) { // IE10.
[189] Fix | Delete
hidden = 'msHidden';
[190] Fix | Delete
visibilitychange = 'msvisibilitychange';
[191] Fix | Delete
visibilityState = 'msVisibilityState';
[192] Fix | Delete
} else if ( typeof document.webkitHidden !== 'undefined' ) { // Android.
[193] Fix | Delete
hidden = 'webkitHidden';
[194] Fix | Delete
visibilitychange = 'webkitvisibilitychange';
[195] Fix | Delete
visibilityState = 'webkitVisibilityState';
[196] Fix | Delete
}
[197] Fix | Delete
[198] Fix | Delete
if ( hidden ) {
[199] Fix | Delete
if ( document[hidden] ) {
[200] Fix | Delete
settings.hasFocus = false;
[201] Fix | Delete
}
[202] Fix | Delete
[203] Fix | Delete
$document.on( visibilitychange + '.wp-heartbeat', function() {
[204] Fix | Delete
if ( document[visibilityState] === 'hidden' ) {
[205] Fix | Delete
blurred();
[206] Fix | Delete
window.clearInterval( settings.checkFocusTimer );
[207] Fix | Delete
} else {
[208] Fix | Delete
focused();
[209] Fix | Delete
if ( document.hasFocus ) {
[210] Fix | Delete
settings.checkFocusTimer = window.setInterval( checkFocus, 10000 );
[211] Fix | Delete
}
[212] Fix | Delete
}
[213] Fix | Delete
});
[214] Fix | Delete
}
[215] Fix | Delete
[216] Fix | Delete
// Use document.hasFocus() if available.
[217] Fix | Delete
if ( document.hasFocus ) {
[218] Fix | Delete
settings.checkFocusTimer = window.setInterval( checkFocus, 10000 );
[219] Fix | Delete
}
[220] Fix | Delete
[221] Fix | Delete
$(window).on( 'unload.wp-heartbeat', function() {
[222] Fix | Delete
// Don't connect anymore.
[223] Fix | Delete
settings.suspend = true;
[224] Fix | Delete
[225] Fix | Delete
// Abort the last request if not completed.
[226] Fix | Delete
if ( settings.xhr && settings.xhr.readyState !== 4 ) {
[227] Fix | Delete
settings.xhr.abort();
[228] Fix | Delete
}
[229] Fix | Delete
});
[230] Fix | Delete
[231] Fix | Delete
// Check for user activity every 30 seconds.
[232] Fix | Delete
window.setInterval( checkUserActivity, 30000 );
[233] Fix | Delete
[234] Fix | Delete
// Start one tick after DOM ready.
[235] Fix | Delete
$document.ready( function() {
[236] Fix | Delete
settings.lastTick = time();
[237] Fix | Delete
scheduleNextTick();
[238] Fix | Delete
});
[239] Fix | Delete
}
[240] Fix | Delete
[241] Fix | Delete
/**
[242] Fix | Delete
* Returns the current time according to the browser.
[243] Fix | Delete
*
[244] Fix | Delete
* @since 3.6.0
[245] Fix | Delete
* @access private
[246] Fix | Delete
*
[247] Fix | Delete
* @return {number} Returns the current time.
[248] Fix | Delete
*/
[249] Fix | Delete
function time() {
[250] Fix | Delete
return (new Date()).getTime();
[251] Fix | Delete
}
[252] Fix | Delete
[253] Fix | Delete
/**
[254] Fix | Delete
* Checks if the iframe is from the same origin.
[255] Fix | Delete
*
[256] Fix | Delete
* @since 3.6.0
[257] Fix | Delete
* @access private
[258] Fix | Delete
*
[259] Fix | Delete
* @return {boolean} Returns whether or not the iframe is from the same origin.
[260] Fix | Delete
*/
[261] Fix | Delete
function isLocalFrame( frame ) {
[262] Fix | Delete
var origin, src = frame.src;
[263] Fix | Delete
[264] Fix | Delete
/*
[265] Fix | Delete
* Need to compare strings as WebKit doesn't throw JS errors when iframes have
[266] Fix | Delete
* different origin. It throws uncatchable exceptions.
[267] Fix | Delete
*/
[268] Fix | Delete
if ( src && /^https?:\/\//.test( src ) ) {
[269] Fix | Delete
origin = window.location.origin ? window.location.origin : window.location.protocol + '//' + window.location.host;
[270] Fix | Delete
[271] Fix | Delete
if ( src.indexOf( origin ) !== 0 ) {
[272] Fix | Delete
return false;
[273] Fix | Delete
}
[274] Fix | Delete
}
[275] Fix | Delete
[276] Fix | Delete
try {
[277] Fix | Delete
if ( frame.contentWindow.document ) {
[278] Fix | Delete
return true;
[279] Fix | Delete
}
[280] Fix | Delete
} catch(e) {}
[281] Fix | Delete
[282] Fix | Delete
return false;
[283] Fix | Delete
}
[284] Fix | Delete
[285] Fix | Delete
/**
[286] Fix | Delete
* Checks if the document's focus has changed.
[287] Fix | Delete
*
[288] Fix | Delete
* @since 4.1.0
[289] Fix | Delete
* @access private
[290] Fix | Delete
*
[291] Fix | Delete
* @return {void}
[292] Fix | Delete
*/
[293] Fix | Delete
function checkFocus() {
[294] Fix | Delete
if ( settings.hasFocus && ! document.hasFocus() ) {
[295] Fix | Delete
blurred();
[296] Fix | Delete
} else if ( ! settings.hasFocus && document.hasFocus() ) {
[297] Fix | Delete
focused();
[298] Fix | Delete
}
[299] Fix | Delete
}
[300] Fix | Delete
[301] Fix | Delete
/**
[302] Fix | Delete
* Sets error state and fires an event on XHR errors or timeout.
[303] Fix | Delete
*
[304] Fix | Delete
* @since 3.8.0
[305] Fix | Delete
* @access private
[306] Fix | Delete
*
[307] Fix | Delete
* @param {string} error The error type passed from the XHR.
[308] Fix | Delete
* @param {number} status The HTTP status code passed from jqXHR
[309] Fix | Delete
* (200, 404, 500, etc.).
[310] Fix | Delete
*
[311] Fix | Delete
* @return {void}
[312] Fix | Delete
*/
[313] Fix | Delete
function setErrorState( error, status ) {
[314] Fix | Delete
var trigger;
[315] Fix | Delete
[316] Fix | Delete
if ( error ) {
[317] Fix | Delete
switch ( error ) {
[318] Fix | Delete
case 'abort':
[319] Fix | Delete
// Do nothing.
[320] Fix | Delete
break;
[321] Fix | Delete
case 'timeout':
[322] Fix | Delete
// No response for 30 seconds.
[323] Fix | Delete
trigger = true;
[324] Fix | Delete
break;
[325] Fix | Delete
case 'error':
[326] Fix | Delete
if ( 503 === status && settings.hasConnected ) {
[327] Fix | Delete
trigger = true;
[328] Fix | Delete
break;
[329] Fix | Delete
}
[330] Fix | Delete
/* falls through */
[331] Fix | Delete
case 'parsererror':
[332] Fix | Delete
case 'empty':
[333] Fix | Delete
case 'unknown':
[334] Fix | Delete
settings.errorcount++;
[335] Fix | Delete
[336] Fix | Delete
if ( settings.errorcount > 2 && settings.hasConnected ) {
[337] Fix | Delete
trigger = true;
[338] Fix | Delete
}
[339] Fix | Delete
[340] Fix | Delete
break;
[341] Fix | Delete
}
[342] Fix | Delete
[343] Fix | Delete
if ( trigger && ! hasConnectionError() ) {
[344] Fix | Delete
settings.connectionError = true;
[345] Fix | Delete
$document.trigger( 'heartbeat-connection-lost', [error, status] );
[346] Fix | Delete
wp.hooks.doAction( 'heartbeat.connection-lost', error, status );
[347] Fix | Delete
}
[348] Fix | Delete
}
[349] Fix | Delete
}
[350] Fix | Delete
[351] Fix | Delete
/**
[352] Fix | Delete
* Clears the error state and fires an event if there is a connection error.
[353] Fix | Delete
*
[354] Fix | Delete
* @since 3.8.0
[355] Fix | Delete
* @access private
[356] Fix | Delete
*
[357] Fix | Delete
* @return {void}
[358] Fix | Delete
*/
[359] Fix | Delete
function clearErrorState() {
[360] Fix | Delete
// Has connected successfully.
[361] Fix | Delete
settings.hasConnected = true;
[362] Fix | Delete
[363] Fix | Delete
if ( hasConnectionError() ) {
[364] Fix | Delete
settings.errorcount = 0;
[365] Fix | Delete
settings.connectionError = false;
[366] Fix | Delete
$document.trigger( 'heartbeat-connection-restored' );
[367] Fix | Delete
wp.hooks.doAction( 'heartbeat.connection-restored' );
[368] Fix | Delete
}
[369] Fix | Delete
}
[370] Fix | Delete
[371] Fix | Delete
/**
[372] Fix | Delete
* Gathers the data and connects to the server.
[373] Fix | Delete
*
[374] Fix | Delete
* @since 3.6.0
[375] Fix | Delete
* @access private
[376] Fix | Delete
*
[377] Fix | Delete
* @return {void}
[378] Fix | Delete
*/
[379] Fix | Delete
function connect() {
[380] Fix | Delete
var ajaxData, heartbeatData;
[381] Fix | Delete
[382] Fix | Delete
// If the connection to the server is slower than the interval,
[383] Fix | Delete
// heartbeat connects as soon as the previous connection's response is received.
[384] Fix | Delete
if ( settings.connecting || settings.suspend ) {
[385] Fix | Delete
return;
[386] Fix | Delete
}
[387] Fix | Delete
[388] Fix | Delete
settings.lastTick = time();
[389] Fix | Delete
[390] Fix | Delete
heartbeatData = $.extend( {}, settings.queue );
[391] Fix | Delete
// Clear the data queue. Anything added after this point will be sent on the next tick.
[392] Fix | Delete
settings.queue = {};
[393] Fix | Delete
[394] Fix | Delete
$document.trigger( 'heartbeat-send', [ heartbeatData ] );
[395] Fix | Delete
wp.hooks.doAction( 'heartbeat.send', heartbeatData );
[396] Fix | Delete
[397] Fix | Delete
ajaxData = {
[398] Fix | Delete
data: heartbeatData,
[399] Fix | Delete
interval: settings.tempInterval ? settings.tempInterval / 1000 : settings.mainInterval / 1000,
[400] Fix | Delete
_nonce: typeof window.heartbeatSettings === 'object' ? window.heartbeatSettings.nonce : '',
[401] Fix | Delete
action: 'heartbeat',
[402] Fix | Delete
screen_id: settings.screenId,
[403] Fix | Delete
has_focus: settings.hasFocus
[404] Fix | Delete
};
[405] Fix | Delete
[406] Fix | Delete
if ( 'customize' === settings.screenId ) {
[407] Fix | Delete
ajaxData.wp_customize = 'on';
[408] Fix | Delete
}
[409] Fix | Delete
[410] Fix | Delete
settings.connecting = true;
[411] Fix | Delete
settings.xhr = $.ajax({
[412] Fix | Delete
url: settings.url,
[413] Fix | Delete
type: 'post',
[414] Fix | Delete
timeout: 30000, // Throw an error if not completed after 30 seconds.
[415] Fix | Delete
data: ajaxData,
[416] Fix | Delete
dataType: 'json'
[417] Fix | Delete
}).always( function() {
[418] Fix | Delete
settings.connecting = false;
[419] Fix | Delete
scheduleNextTick();
[420] Fix | Delete
}).done( function( response, textStatus, jqXHR ) {
[421] Fix | Delete
var newInterval;
[422] Fix | Delete
[423] Fix | Delete
if ( ! response ) {
[424] Fix | Delete
setErrorState( 'empty' );
[425] Fix | Delete
return;
[426] Fix | Delete
}
[427] Fix | Delete
[428] Fix | Delete
clearErrorState();
[429] Fix | Delete
[430] Fix | Delete
if ( response.nonces_expired ) {
[431] Fix | Delete
$document.trigger( 'heartbeat-nonces-expired' );
[432] Fix | Delete
wp.hooks.doAction( 'heartbeat.nonces-expired' );
[433] Fix | Delete
}
[434] Fix | Delete
[435] Fix | Delete
// Change the interval from PHP.
[436] Fix | Delete
if ( response.heartbeat_interval ) {
[437] Fix | Delete
newInterval = response.heartbeat_interval;
[438] Fix | Delete
delete response.heartbeat_interval;
[439] Fix | Delete
}
[440] Fix | Delete
[441] Fix | Delete
// Update the heartbeat nonce if set.
[442] Fix | Delete
if ( response.heartbeat_nonce && typeof window.heartbeatSettings === 'object' ) {
[443] Fix | Delete
window.heartbeatSettings.nonce = response.heartbeat_nonce;
[444] Fix | Delete
delete response.heartbeat_nonce;
[445] Fix | Delete
}
[446] Fix | Delete
[447] Fix | Delete
// Update the Rest API nonce if set and wp-api loaded.
[448] Fix | Delete
if ( response.rest_nonce && typeof window.wpApiSettings === 'object' ) {
[449] Fix | Delete
window.wpApiSettings.nonce = response.rest_nonce;
[450] Fix | Delete
// This nonce is required for api-fetch through heartbeat.tick.
[451] Fix | Delete
// delete response.rest_nonce;
[452] Fix | Delete
}
[453] Fix | Delete
[454] Fix | Delete
$document.trigger( 'heartbeat-tick', [response, textStatus, jqXHR] );
[455] Fix | Delete
wp.hooks.doAction( 'heartbeat.tick', response, textStatus, jqXHR );
[456] Fix | Delete
[457] Fix | Delete
// Do this last. Can trigger the next XHR if connection time > 5 seconds and newInterval == 'fast'.
[458] Fix | Delete
if ( newInterval ) {
[459] Fix | Delete
interval( newInterval );
[460] Fix | Delete
}
[461] Fix | Delete
}).fail( function( jqXHR, textStatus, error ) {
[462] Fix | Delete
setErrorState( textStatus || 'unknown', jqXHR.status );
[463] Fix | Delete
$document.trigger( 'heartbeat-error', [jqXHR, textStatus, error] );
[464] Fix | Delete
wp.hooks.doAction( 'heartbeat.error', jqXHR, textStatus, error );
[465] Fix | Delete
});
[466] Fix | Delete
}
[467] Fix | Delete
[468] Fix | Delete
/**
[469] Fix | Delete
* Schedules the next connection.
[470] Fix | Delete
*
[471] Fix | Delete
* Fires immediately if the connection time is longer than the interval.
[472] Fix | Delete
*
[473] Fix | Delete
* @since 3.8.0
[474] Fix | Delete
* @access private
[475] Fix | Delete
*
[476] Fix | Delete
* @return {void}
[477] Fix | Delete
*/
[478] Fix | Delete
function scheduleNextTick() {
[479] Fix | Delete
var delta = time() - settings.lastTick,
[480] Fix | Delete
interval = settings.mainInterval;
[481] Fix | Delete
[482] Fix | Delete
if ( settings.suspend ) {
[483] Fix | Delete
return;
[484] Fix | Delete
}
[485] Fix | Delete
[486] Fix | Delete
if ( ! settings.hasFocus ) {
[487] Fix | Delete
interval = 120000; // 120 seconds. Post locks expire after 150 seconds.
[488] Fix | Delete
} else if ( settings.countdown > 0 && settings.tempInterval ) {
[489] Fix | Delete
interval = settings.tempInterval;
[490] Fix | Delete
settings.countdown--;
[491] Fix | Delete
[492] Fix | Delete
if ( settings.countdown < 1 ) {
[493] Fix | Delete
settings.tempInterval = 0;
[494] Fix | Delete
}
[495] Fix | Delete
}
[496] Fix | Delete
[497] Fix | Delete
if ( settings.minimalInterval && interval < settings.minimalInterval ) {
[498] Fix | Delete
interval = settings.minimalInterval;
[499] Fix | Delete
12
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function