]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-includes/js/heartbeat.min.js
WordPress 4.4
[autoinstalls/wordpress.git] / wp-includes / js / heartbeat.min.js
index 81039d4f9f8b01e1f1531f1d36e825c473ef83a7..a4e25a4c1db73509d5fdcae84e8c79edc3472a8a 100644 (file)
@@ -1 +1 @@
-window.wp=window.wp||{},function(a){var b=function(){function b(a){return a?parseInt((new Date).getTime()/1e3):(new Date).getTime()}function c(a){var b,c=a.src;if(c&&/^https?:\/\//.test(c)&&(b=window.location.origin?window.location.origin:window.location.protocol+"//"+window.location.host,0!==c.indexOf(b)))return!1;try{if(a.contentWindow.document)return!0}catch(d){}return!1}function d(b,c){var d;if(b){switch(b){case"abort":break;case"timeout":d=!0;break;case"parsererror":case"error":case"empty":case"unknown":A++,A>2&&(d=!0)}503==c&&!1===D&&(d=!0),d&&!u.hasConnectionError()&&(D=!0,a(document).trigger("heartbeat-connection-lost",[b,c]))}else u.hasConnectionError()?(A=0,D=!1,a(document).trigger("heartbeat-connection-restored")):null===D&&(D=!1)}function e(){var c,e,g={},h=!0,i="object"==typeof window.heartbeatSettings?window.heartbeatSettings.nonce:"";x=b(),c=a.extend({},y),y={},a(document).trigger("heartbeat-send",[c]);for(e in c)if(c.hasOwnProperty(e)){h=!1;break}return h&&!u.hasConnectionError()?(p=!1,f(),void 0):(g.data=c,g.interval=o/1e3,g._nonce=i,g.action="heartbeat",g.screen_id=v,g.has_focus=B,p=!0,u.xhr=a.ajax({url:w,type:"post",timeout:3e4,data:g,dataType:"json"}).done(function(b,c,e){var f;return b?(u.hasConnectionError()&&d(),b.nonces_expired?(a(document).trigger("heartbeat-nonces-expired"),void 0):(b.heartbeat_interval&&(f=b.heartbeat_interval,delete b.heartbeat_interval),u.tick(b,c,e),f&&u.interval.call(u,f),void 0)):d("empty")}).always(function(){p=!1,f()}).fail(function(a,b,c){d(b||"unknown",a.status),u.error(a,b,c)}),void 0)}function f(){var a=b()-x,c=o;l&&(B?z>0&&q&&(c=q,z--):c=1e5,window.clearTimeout(m),c>a?m=window.setTimeout(function(){l&&e()},c-a):e())}function g(){window.clearTimeout(t),window.clearTimeout(C),t=C=0,B=!1}function h(){window.clearTimeout(t),window.clearTimeout(C),t=C=0,r=b(),B||(B=!0,window.clearTimeout(m),p||f())}function i(){a("iframe").each(function(b,d){c(d)&&(a.data(d,"wp-heartbeat-focus")||(a.data(d,"wp-heartbeat-focus",1),a(d.contentWindow).on("focus.wp-heartbeat-focus",function(){h()}).on("blur.wp-heartbeat-focus",function(){i(),C=window.setTimeout(function(){g()},500)})))})}function j(){s=!1,a(document).off(".wp-heartbeat-active"),a("iframe").each(function(b,d){c(d)&&a(d.contentWindow).off(".wp-heartbeat-active")}),h()}function k(){var d=r?b()-r:0;d>3e5&&B&&g(),s||(a(document).on("mouseover.wp-heartbeat-active keyup.wp-heartbeat-active",function(){j()}),a("iframe").each(function(b,d){c(d)&&a(d.contentWindow).on("mouseover.wp-heartbeat-active keyup.wp-heartbeat-active",function(){j()})}),s=!0)}var l,m,n,o,p,q,r,s,t,u=this,v="undefined"!=typeof pagenow?pagenow:"",w="undefined"!=typeof ajaxurl?ajaxurl:"",x=0,y={},z=0,A=0,B=!0,C=-1,D=null;this.hasConnectionError=function(){return!!D},"object"==typeof window.heartbeatSettings&&(n=a.extend({},window.heartbeatSettings),w=n.ajaxurl||w,delete n.ajaxurl,delete n.nonce,o=n.interval||15,delete n.interval,15>o?o=15:o>60&&(o=60),o=1e3*o,v=v||n.screenId||"front",delete n.screenId,a.extend(this,n)),a(window).on("blur.wp-heartbeat-focus",function(){i(),t=window.setTimeout(function(){g()},500)}).on("focus.wp-heartbeat-focus",function(){a("iframe").each(function(b,d){c(d)&&(a.removeData(d,"wp-heartbeat-focus"),a(d.contentWindow).off(".wp-heartbeat-focus"))}),h()}),window.setInterval(function(){k()},3e4),a(document).ready(function(){l=!0,x=b(),f()}),this.hasFocus=function(){return B},this.interval=function(a,b){var c,d;if(b=parseInt(b,10)||30,b=1>b||b>30?30:b,a){switch(a){case"fast":d=5,z=b;break;case"slow":d=60,z=0;break;case"long-polling":return o=0,0;default:d=15,z=0}c=o>1e3*d,z>0?q=1e3*d:(o=1e3*d,q=0),c&&f()}return B?q?q/1e3:o/1e3:120},this.enqueue=function(a,b,c){return a?c&&this.isQueued(a)?!1:(y[a]=b,!0):!1},this.isQueued=function(a){return a?y.hasOwnProperty(a):void 0},this.dequeue=function(a){a&&delete y[a]},this.getQueuedItem=function(a){return a?this.isQueued(a)?y[a]:void 0:void 0}};a.extend(b.prototype,{tick:function(b,c,d){a(document).trigger("heartbeat-tick",[b,c,d])},error:function(b,c,d){a(document).trigger("heartbeat-error",[b,c,d])}}),wp.heartbeat=new b}(jQuery);
\ No newline at end of file
+!function(a,b,c){var d=function(){function d(){var c,d,f,h;"string"==typeof b.pagenow&&(z.screenId=b.pagenow),"string"==typeof b.ajaxurl&&(z.url=b.ajaxurl),"object"==typeof b.heartbeatSettings&&(c=b.heartbeatSettings,!z.url&&c.ajaxurl&&(z.url=c.ajaxurl),c.interval&&(z.mainInterval=c.interval,z.mainInterval<15?z.mainInterval=15:z.mainInterval>120&&(z.mainInterval=120)),c.minimalInterval&&(c.minimalInterval=parseInt(c.minimalInterval,10),z.minimalInterval=c.minimalInterval>0&&c.minimalInterval<=600?1e3*c.minimalInterval:0),z.minimalInterval&&z.mainInterval<z.minimalInterval&&(z.mainInterval=z.minimalInterval),z.screenId||(z.screenId=c.screenId||"front"),"disable"===c.suspension&&(z.suspendEnabled=!1)),z.mainInterval=1e3*z.mainInterval,z.originalInterval=z.mainInterval,"undefined"!=typeof document.hidden?(d="hidden",h="visibilitychange",f="visibilityState"):"undefined"!=typeof document.msHidden?(d="msHidden",h="msvisibilitychange",f="msVisibilityState"):"undefined"!=typeof document.webkitHidden&&(d="webkitHidden",h="webkitvisibilitychange",f="webkitVisibilityState"),d&&(document[d]&&(z.hasFocus=!1),y.on(h+".wp-heartbeat",function(){"hidden"===document[f]?(l(),b.clearInterval(z.checkFocusTimer)):(m(),document.hasFocus&&(z.checkFocusTimer=b.setInterval(g,1e4)))})),document.hasFocus&&(z.checkFocusTimer=b.setInterval(g,1e4)),a(b).on("unload.wp-heartbeat",function(){z.suspend=!0,z.xhr&&4!==z.xhr.readyState&&z.xhr.abort()}),b.setInterval(o,3e4),y.ready(function(){z.lastTick=e(),k()})}function e(){return(new Date).getTime()}function f(a){var c,d=a.src;if(d&&/^https?:\/\//.test(d)&&(c=b.location.origin?b.location.origin:b.location.protocol+"//"+b.location.host,0!==d.indexOf(c)))return!1;try{if(a.contentWindow.document)return!0}catch(e){}return!1}function g(){z.hasFocus&&!document.hasFocus()?l():!z.hasFocus&&document.hasFocus()&&m()}function h(a,b){var c;if(a){switch(a){case"abort":break;case"timeout":c=!0;break;case"error":if(503===b&&z.hasConnected){c=!0;break}case"parsererror":case"empty":case"unknown":z.errorcount++,z.errorcount>2&&z.hasConnected&&(c=!0)}c&&!q()&&(z.connectionError=!0,y.trigger("heartbeat-connection-lost",[a,b]))}}function i(){z.hasConnected=!0,q()&&(z.errorcount=0,z.connectionError=!1,y.trigger("heartbeat-connection-restored"))}function j(){var c,d;z.connecting||z.suspend||(z.lastTick=e(),d=a.extend({},z.queue),z.queue={},y.trigger("heartbeat-send",[d]),c={data:d,interval:z.tempInterval?z.tempInterval/1e3:z.mainInterval/1e3,_nonce:"object"==typeof b.heartbeatSettings?b.heartbeatSettings.nonce:"",action:"heartbeat",screen_id:z.screenId,has_focus:z.hasFocus},z.connecting=!0,z.xhr=a.ajax({url:z.url,type:"post",timeout:3e4,data:c,dataType:"json"}).always(function(){z.connecting=!1,k()}).done(function(a,b,c){var d;return a?(i(),a.nonces_expired&&y.trigger("heartbeat-nonces-expired"),a.heartbeat_interval&&(d=a.heartbeat_interval,delete a.heartbeat_interval),y.trigger("heartbeat-tick",[a,b,c]),void(d&&t(d))):void h("empty")}).fail(function(a,b,c){h(b||"unknown",a.status),y.trigger("heartbeat-error",[a,b,c])}))}function k(){var a=e()-z.lastTick,c=z.mainInterval;z.suspend||(z.hasFocus?z.countdown>0&&z.tempInterval&&(c=z.tempInterval,z.countdown--,z.countdown<1&&(z.tempInterval=0)):c=12e4,z.minimalInterval&&c<z.minimalInterval&&(c=z.minimalInterval),b.clearTimeout(z.beatTimer),c>a?z.beatTimer=b.setTimeout(function(){j()},c-a):j())}function l(){z.hasFocus=!1}function m(){z.userActivity=e(),z.suspend=!1,z.hasFocus||(z.hasFocus=!0,k())}function n(){z.userActivityEvents=!1,y.off(".wp-heartbeat-active"),a("iframe").each(function(b,c){f(c)&&a(c.contentWindow).off(".wp-heartbeat-active")}),m()}function o(){var b=z.userActivity?e()-z.userActivity:0;b>3e5&&z.hasFocus&&l(),(z.suspendEnabled&&b>6e5||b>36e5)&&(z.suspend=!0),z.userActivityEvents||(y.on("mouseover.wp-heartbeat-active keyup.wp-heartbeat-active touchend.wp-heartbeat-active",function(){n()}),a("iframe").each(function(b,c){f(c)&&a(c.contentWindow).on("mouseover.wp-heartbeat-active keyup.wp-heartbeat-active touchend.wp-heartbeat-active",function(){n()})}),z.userActivityEvents=!0)}function p(){return z.hasFocus}function q(){return z.connectionError}function r(){z.lastTick=0,k()}function s(){z.suspendEnabled=!1}function t(a,b){var c,d=z.tempInterval?z.tempInterval:z.mainInterval;if(a){switch(a){case"fast":case 5:c=5e3;break;case 15:c=15e3;break;case 30:c=3e4;break;case 60:c=6e4;break;case 120:c=12e4;break;case"long-polling":return z.mainInterval=0,0;default:c=z.originalInterval}z.minimalInterval&&c<z.minimalInterval&&(c=z.minimalInterval),5e3===c?(b=parseInt(b,10)||30,b=1>b||b>30?30:b,z.countdown=b,z.tempInterval=c):(z.countdown=0,z.tempInterval=0,z.mainInterval=c),c!==d&&k()}return z.tempInterval?z.tempInterval/1e3:z.mainInterval/1e3}function u(a,b,c){return a?c&&this.isQueued(a)?!1:(z.queue[a]=b,!0):!1}function v(a){return a?z.queue.hasOwnProperty(a):void 0}function w(a){a&&delete z.queue[a]}function x(a){return a?this.isQueued(a)?z.queue[a]:c:void 0}var y=a(document),z={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};return d(),{hasFocus:p,connectNow:r,disableSuspend:s,interval:t,hasConnectionError:q,enqueue:u,dequeue:w,isQueued:v,getQueuedItem:x}};b.wp=b.wp||{},b.wp.heartbeat=new d}(jQuery,window);
\ No newline at end of file