wp-go/static/wp-includes/js/heartbeat.min.js

2 lines
5.8 KiB
JavaScript
Raw Normal View History

2022-09-13 03:23:28 +00:00
/*! This file is auto-generated */
!function(f,w){w.wp=w.wp||{},w.wp.heartbeat=new function(){var e,t,n,a,i=f(document),r={suspend:!1,suspendEnabled:!0,screenId:"",url:"",lastTick:0,queue:{},mainInterval:60,tempInterval:0,originalInterval:0,minimalInterval:0,countdown:0,connecting:!1,connectionError:!1,errorcount:0,hasConnected:!1,hasFocus:!0,userActivity:0,userActivityEvents:!1,checkFocusTimer:0,beatTimer:0};function o(){return(new Date).getTime()}function c(e){var t,n=e.src;if(!n||!/^https?:\/\//.test(n)||(t=w.location.origin||w.location.protocol+"//"+w.location.host,0===n.indexOf(t)))try{if(e.contentWindow.document)return 1}catch(e){}}function s(){r.hasFocus&&!document.hasFocus()?d():!r.hasFocus&&document.hasFocus()&&v()}function u(e,t){var n;if(e){switch(e){case"abort":break;case"timeout":n=!0;break;case"error":if(503===t&&r.hasConnected){n=!0;break}case"parsererror":case"empty":case"unknown":r.errorcount++,2<r.errorcount&&r.hasConnected&&(n=!0)}n&&!b()&&(r.connectionError=!0,i.trigger("heartbeat-connection-lost",[e,t]),wp.hooks.doAction("heartbeat.connection-lost",e,t))}}function l(){var e;r.connecting||r.suspend||(r.lastTick=o(),e=f.extend({},r.queue),r.queue={},i.trigger("heartbeat-send",[e]),wp.hooks.doAction("heartbeat.send",e),e={data:e,interval:r.tempInterval?r.tempInterval/1e3:r.mainInterval/1e3,_nonce:"object"==typeof w.heartbeatSettings?w.heartbeatSettings.nonce:"",action:"heartbeat",screen_id:r.screenId,has_focus:r.hasFocus},"customize"===r.screenId&&(e.wp_customize="on"),r.connecting=!0,r.xhr=f.ajax({url:r.url,type:"post",timeout:3e4,data:e,dataType:"json"}).always(function(){r.connecting=!1,m()}).done(function(e,t,n){var a;e?(r.hasConnected=!0,b()&&(r.errorcount=0,r.connectionError=!1,i.trigger("heartbeat-connection-restored"),wp.hooks.doAction("heartbeat.connection-restored")),e.nonces_expired&&(i.trigger("heartbeat-nonces-expired"),wp.hooks.doAction("heartbeat.nonces-expired")),e.heartbeat_interval&&(a=e.heartbeat_interval,delete e.heartbeat_interval),e.heartbeat_nonce&&"object"==typeof w.heartbeatSettings&&(w.heartbeatSettings.nonce=e.heartbeat_nonce,delete e.heartbeat_nonce),e.rest_nonce&&"object"==typeof w.wpApiSettings&&(w.wpApiSettings.nonce=e.rest_nonce),i.trigger("heartbeat-tick",[e,t,n]),wp.hooks.doAction("heartbeat.tick",e,t,n),a&&I(a)):u("empty")}).fail(function(e,t,n){u(t||"unknown",e.status),i.trigger("heartbeat-error",[e,t,n]),wp.hooks.doAction("heartbeat.error",e,t,n)}))}function m(){var e=o()-r.lastTick,t=r.mainInterval;r.suspend||(r.hasFocus?0<r.countdown&&r.tempInterval&&(t=r.tempInterval,r.countdown--,r.countdown<1&&(r.tempInterval=0)):t=12e4,r.minimalInterval&&t<r.minimalInterval&&(t=r.minimalInterval),w.clearTimeout(r.beatTimer),e<t?r.beatTimer=w.setTimeout(function(){l()},t-e):l())}function d(){r.hasFocus=!1}function v(){r.userActivity=o(),r.suspend=!1,r.hasFocus||(r.hasFocus=!0,m())}function h(){r.userActivityEvents=!1,i.off(".wp-heartbeat-active"),f("iframe").each(function(e,t){c(t)&&f(t.contentWindow).off(".wp-heartbeat-active")}),v()}function p(){var e=r.userActivity?o()-r.userActivity:0;3e5<e&&r.hasFocus&&d(),(r.suspendEnabled&&6e5<e||36e5<e)&&(r.suspend=!0),r.userActivityEvents||(i.on("mouseover.wp-heartbeat-active keyup.wp-heartbeat-active touchend.wp-heartbeat-active",function(){h()}),f("iframe").each(function(e,t){c(t)&&f(t.contentWindow).on("mouseover.wp-heartbeat-active keyup.wp-heartbeat-active touchend.wp-heartbeat-active",function(){h()})}),r.userActivityEvents=!0)}function b(){return r.connectionError}function I(e,t){var n,a=r.tempInterval||r.mainInterval;if(e){switch(e){case"fast":case 5:n=5e3;break;case 15:n=15e3;break;case 30:n=3e4;break;case 60:n=6e4;break;case 120:n=12e4;break;case"long-polling":return r.mainInterval=0;default:n=r.originalInterval}5e3===(n=r.minimalInterval&&n<r.minimalInterval?r.minimalInterval:n)?(t=parseInt(t,10)||30,r.countdown=t=t<1||30<t?30:t,r.tempInterval=n):(r.countdown=0,r.tempInterval=0,r.mainInterval=n),n!==a&&m()}return r.tempInterval?r.tempInterval/1e3:r.mainInterval/1e3}return"string"==typeof w.pagenow&&(r.screenId=w.pagenow),"string"==typeof w.ajaxurl&&(r.url=w.a