Файловый менеджер - Редактировать - /home/patasalvajes/public_html/wp-includes/IXR/782563/heartbeat.js.tar
Назад
home/patasalvajes/public_html/wp-includes/js/heartbeat.js 0000644 00000056764 15014653434 0017646 0 ustar 00 /** * Heartbeat API * * Heartbeat is a simple server polling API that sends XHR requests to * the server every 15 - 60 seconds and triggers events (or callbacks) upon * receiving data. Currently these 'ticks' handle transports for post locking, * login-expiration warnings, autosave, and related tasks while a user is logged in. * * Available PHP filters (in ajax-actions.php): * - heartbeat_received * - heartbeat_send * - heartbeat_tick * - heartbeat_nopriv_received * - heartbeat_nopriv_send * - heartbeat_nopriv_tick * @see wp_ajax_nopriv_heartbeat(), wp_ajax_heartbeat() * * Custom jQuery events: * - heartbeat-send * - heartbeat-tick * - heartbeat-error * - heartbeat-connection-lost * - heartbeat-connection-restored * - heartbeat-nonces-expired * * @since 3.6.0 * @output wp-includes/js/heartbeat.js */ ( function( $, window, undefined ) { /** * Constructs the Heartbeat API. * * @since 3.6.0 * * @return {Object} An instance of the Heartbeat class. * @constructor */ var Heartbeat = function() { 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 seconds 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 been 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 seconds. userActivity: 0, // Flag whether events tracking user activity were set. userActivityEvents: false, // Timer that keeps track of how long a user has focus. checkFocusTimer: 0, // Timer that keeps track of how long needs to be waited before connecting to // the server again. beatTimer: 0 }; /** * Sets local variables and events, then starts the heartbeat. * * @since 3.8.0 * @access private * * @return {void} */ function initialize() { var options, hidden, visibilityState, visibilitychange; if ( typeof window.pagenow === 'string' ) { settings.screenId = window.pagenow; } if ( typeof window.ajaxurl === 'string' ) { settings.url = window.ajaxurl; } // Pull in options passed from PHP. if ( typeof window.heartbeatSettings === 'object' ) { options = window.heartbeatSettings; // The XHR URL can be passed as option when window.ajaxurl is not set. if ( ! settings.url && options.ajaxurl ) { settings.url = options.ajaxurl; } /* * Logic check: the interval can be from 1 to 3600 seconds and can be set temporarily * to 5 seconds. It can be set in the initial options or changed later from JS * or from PHP through the AJAX responses. */ if ( options.interval ) { settings.mainInterval = options.interval; if ( settings.mainInterval < 1 ) { settings.mainInterval = 1; } else if ( settings.mainInterval > 3600 ) { settings.mainInterval = 3600; } } /* * Used to limit the number of Ajax requests. Overrides all other intervals * if they are shorter. Needed for some hosts that cannot handle frequent requests * and the user may exceed the allocated server CPU time, etc. The minimal interval * can be up to 600 seconds, however setting it to longer than 120 seconds * will limit or disable some of the functionality (like post locks). * Once set at initialization, minimalInterval cannot be changed/overridden. */ if ( options.minimalInterval ) { options.minimalInterval = parseInt( options.minimalInterval, 10 ); settings.minimalInterval = options.minimalInterval > 0 && options.minimalInterval <= 600 ? options.minimalInterval : 0; } if ( settings.minimalInterval && settings.mainInterval < settings.minimalInterval ) { settings.mainInterval = settings.minimalInterval; } // 'screenId' can be added from settings on the front end where the JS global // 'pagenow' is not set. if ( ! settings.screenId ) { settings.screenId = options.screenId || 'front'; } if ( options.suspension === 'disable' ) { settings.suspendEnabled = false; } } // Convert to milliseconds. settings.mainInterval = settings.mainInterval * 1000; settings.originalInterval = settings.mainInterval; if ( settings.minimalInterval ) { settings.minimalInterval = settings.minimalInterval * 1000; } /* * Switch the interval to 120 seconds by using the Page Visibility API. * If the browser doesn't support it (Safari < 7, Android < 4.4, IE < 10), the * interval will be increased to 120 seconds after 5 minutes of mouse and keyboard * inactivity. */ if ( typeof document.hidden !== 'undefined' ) { hidden = 'hidden'; visibilitychange = 'visibilitychange'; visibilityState = 'visibilityState'; } else if ( typeof document.msHidden !== 'undefined' ) { // IE10. hidden = 'msHidden'; visibilitychange = 'msvisibilitychange'; visibilityState = 'msVisibilityState'; } else if ( typeof document.webkitHidden !== 'undefined' ) { // Android. hidden = 'webkitHidden'; visibilitychange = 'webkitvisibilitychange'; visibilityState = 'webkitVisibilityState'; } if ( hidden ) { if ( document[hidden] ) { settings.hasFocus = false; } $document.on( visibilitychange + '.wp-heartbeat', function() { if ( document[visibilityState] === 'hidden' ) { blurred(); window.clearInterval( settings.checkFocusTimer ); } else { focused(); if ( document.hasFocus ) { settings.checkFocusTimer = window.setInterval( checkFocus, 10000 ); } } }); } // Use document.hasFocus() if available. if ( document.hasFocus ) { settings.checkFocusTimer = window.setInterval( checkFocus, 10000 ); } $(window).on( 'pagehide.wp-heartbeat', function() { // Don't connect anymore. suspend(); // Abort the last request if not completed. if ( settings.xhr && settings.xhr.readyState !== 4 ) { settings.xhr.abort(); } }); $(window).on( 'pageshow.wp-heartbeat', /** * Handles pageshow event, specifically when page navigation is restored from back/forward cache. * * @param {jQuery.Event} event * @param {PageTransitionEvent} event.originalEvent */ function ( event ) { if ( event.originalEvent.persisted ) { /* * When page navigation is stored via bfcache (Back/Forward Cache), consider this the same as * if the user had just switched to the tab since the behavior is similar. */ focused(); } } ); // Check for user activity every 30 seconds. window.setInterval( checkUs
| ver. 1.4 |
Github
|
.
| PHP 7.4.33 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка