Initial commit: Atomaste website
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,773 @@
|
||||
/**
|
||||
* EventSource
|
||||
* https://github.com/Yaffle/EventSource
|
||||
*
|
||||
* Released under the MIT License (MIT)
|
||||
* https://github.com/Yaffle/EventSource/blob/master/LICENSE.md
|
||||
*/
|
||||
|
||||
/*jslint indent: 2, vars: true, plusplus: true */
|
||||
/*global setTimeout, clearTimeout */
|
||||
|
||||
( function ( global ) {
|
||||
'use strict';
|
||||
|
||||
var setTimeout = global.setTimeout;
|
||||
var clearTimeout = global.clearTimeout;
|
||||
var XMLHttpRequest = global.XMLHttpRequest;
|
||||
var XDomainRequest = global.XDomainRequest;
|
||||
var NativeEventSource = global.EventSource;
|
||||
var document = global.document;
|
||||
|
||||
if ( Object.create == null ) {
|
||||
Object.create = function ( C ) {
|
||||
function F() {}
|
||||
F.prototype = C;
|
||||
return new F();
|
||||
};
|
||||
}
|
||||
|
||||
var k = function () {};
|
||||
|
||||
function XHRWrapper( xhr ) {
|
||||
this.withCredentials = false;
|
||||
this.responseType = '';
|
||||
this.readyState = 0;
|
||||
this.status = 0;
|
||||
this.statusText = '';
|
||||
this.responseText = '';
|
||||
this.onprogress = k;
|
||||
this.onreadystatechange = k;
|
||||
this._contentType = '';
|
||||
this._xhr = xhr;
|
||||
this._sendTimeout = 0;
|
||||
this._abort = k;
|
||||
}
|
||||
|
||||
XHRWrapper.prototype.open = function ( method, url ) {
|
||||
this._abort( true );
|
||||
|
||||
var that = this;
|
||||
var xhr = this._xhr;
|
||||
var state = 1;
|
||||
var timeout = 0;
|
||||
|
||||
this._abort = function ( silent ) {
|
||||
if ( that._sendTimeout !== 0 ) {
|
||||
clearTimeout( that._sendTimeout );
|
||||
that._sendTimeout = 0;
|
||||
}
|
||||
if ( state === 1 || state === 2 || state === 3 ) {
|
||||
state = 4;
|
||||
xhr.onload = k;
|
||||
xhr.onerror = k;
|
||||
xhr.onabort = k;
|
||||
xhr.onprogress = k;
|
||||
xhr.onreadystatechange = k;
|
||||
// IE 8 - 9: XDomainRequest#abort() does not fire any event
|
||||
// Opera < 10: XMLHttpRequest#abort() does not fire any event
|
||||
xhr.abort();
|
||||
if ( timeout !== 0 ) {
|
||||
clearTimeout( timeout );
|
||||
timeout = 0;
|
||||
}
|
||||
if ( ! silent ) {
|
||||
that.readyState = 4;
|
||||
that.onreadystatechange();
|
||||
}
|
||||
}
|
||||
state = 0;
|
||||
};
|
||||
|
||||
var onStart = function () {
|
||||
if ( state === 1 ) {
|
||||
//state = 2;
|
||||
var status = 0;
|
||||
var statusText = '';
|
||||
var contentType = undefined;
|
||||
if ( ! ( 'contentType' in xhr ) ) {
|
||||
try {
|
||||
status = xhr.status;
|
||||
statusText = xhr.statusText;
|
||||
contentType = xhr.getResponseHeader( 'Content-Type' );
|
||||
} catch ( error ) {
|
||||
// IE < 10 throws exception for `xhr.status` when xhr.readyState === 2 || xhr.readyState === 3
|
||||
// Opera < 11 throws exception for `xhr.status` when xhr.readyState === 2
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=29121
|
||||
status = 0;
|
||||
statusText = '';
|
||||
contentType = undefined;
|
||||
// Firefox < 14, Chrome ?, Safari ?
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=29658
|
||||
// https://bugs.webkit.org/show_bug.cgi?id=77854
|
||||
}
|
||||
} else {
|
||||
status = 200;
|
||||
statusText = 'OK';
|
||||
contentType = xhr.contentType;
|
||||
}
|
||||
if ( status !== 0 ) {
|
||||
state = 2;
|
||||
that.readyState = 2;
|
||||
that.status = status;
|
||||
that.statusText = statusText;
|
||||
that._contentType = contentType;
|
||||
that.onreadystatechange();
|
||||
}
|
||||
}
|
||||
};
|
||||
var onProgress = function () {
|
||||
onStart();
|
||||
if ( state === 2 || state === 3 ) {
|
||||
state = 3;
|
||||
var responseText = '';
|
||||
try {
|
||||
responseText = xhr.responseText;
|
||||
} catch ( error ) {
|
||||
// IE 8 - 9 with XMLHttpRequest
|
||||
}
|
||||
that.readyState = 3;
|
||||
that.responseText = responseText;
|
||||
that.onprogress();
|
||||
}
|
||||
};
|
||||
var onFinish = function () {
|
||||
// Firefox 52 fires "readystatechange" (xhr.readyState === 4) without final "readystatechange" (xhr.readyState === 3)
|
||||
// IE 8 fires "onload" without "onprogress"
|
||||
onProgress();
|
||||
if ( state === 1 || state === 2 || state === 3 ) {
|
||||
state = 4;
|
||||
if ( timeout !== 0 ) {
|
||||
clearTimeout( timeout );
|
||||
timeout = 0;
|
||||
}
|
||||
that.readyState = 4;
|
||||
that.onreadystatechange();
|
||||
}
|
||||
};
|
||||
var onReadyStateChange = function () {
|
||||
if ( xhr != undefined ) {
|
||||
// Opera 12
|
||||
if ( xhr.readyState === 4 ) {
|
||||
onFinish();
|
||||
} else if ( xhr.readyState === 3 ) {
|
||||
onProgress();
|
||||
} else if ( xhr.readyState === 2 ) {
|
||||
onStart();
|
||||
}
|
||||
}
|
||||
};
|
||||
var onTimeout = function () {
|
||||
timeout = setTimeout( function () {
|
||||
onTimeout();
|
||||
}, 500 );
|
||||
if ( xhr.readyState === 3 ) {
|
||||
onProgress();
|
||||
}
|
||||
};
|
||||
|
||||
// XDomainRequest#abort removes onprogress, onerror, onload
|
||||
xhr.onload = onFinish;
|
||||
xhr.onerror = onFinish;
|
||||
// improper fix to match Firefox behaviour, but it is better than just ignore abort
|
||||
// see https://bugzilla.mozilla.org/show_bug.cgi?id=768596
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=880200
|
||||
// https://code.google.com/p/chromium/issues/detail?id=153570
|
||||
// IE 8 fires "onload" without "onprogress
|
||||
xhr.onabort = onFinish;
|
||||
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=736723
|
||||
if (
|
||||
! ( 'sendAsBinary' in XMLHttpRequest.prototype ) &&
|
||||
! ( 'mozAnon' in XMLHttpRequest.prototype )
|
||||
) {
|
||||
xhr.onprogress = onProgress;
|
||||
}
|
||||
|
||||
// IE 8 - 9 (XMLHTTPRequest)
|
||||
// Opera < 12
|
||||
// Firefox < 3.5
|
||||
// Firefox 3.5 - 3.6 - ? < 9.0
|
||||
// onprogress is not fired sometimes or delayed
|
||||
// see also #64
|
||||
xhr.onreadystatechange = onReadyStateChange;
|
||||
|
||||
if ( 'contentType' in xhr ) {
|
||||
url +=
|
||||
( url.indexOf( '?', 0 ) === -1 ? '?' : '&' ) + 'padding=true';
|
||||
}
|
||||
xhr.open( method, url, true );
|
||||
|
||||
if ( 'readyState' in xhr ) {
|
||||
// workaround for Opera 12 issue with "progress" events
|
||||
// #91
|
||||
timeout = setTimeout( function () {
|
||||
onTimeout();
|
||||
}, 0 );
|
||||
}
|
||||
};
|
||||
XHRWrapper.prototype.abort = function () {
|
||||
this._abort( false );
|
||||
};
|
||||
XHRWrapper.prototype.getResponseHeader = function ( name ) {
|
||||
return this._contentType;
|
||||
};
|
||||
XHRWrapper.prototype.setRequestHeader = function ( name, value ) {
|
||||
var xhr = this._xhr;
|
||||
if ( 'setRequestHeader' in xhr ) {
|
||||
xhr.setRequestHeader( name, value );
|
||||
}
|
||||
};
|
||||
XHRWrapper.prototype.send = function () {
|
||||
// loading indicator in Safari < ? (6), Chrome < 14, Firefox
|
||||
if (
|
||||
! ( 'ontimeout' in XMLHttpRequest.prototype ) &&
|
||||
document != undefined &&
|
||||
document.readyState != undefined &&
|
||||
document.readyState !== 'complete'
|
||||
) {
|
||||
var that = this;
|
||||
that._sendTimeout = setTimeout( function () {
|
||||
that._sendTimeout = 0;
|
||||
that.send();
|
||||
}, 4 );
|
||||
return;
|
||||
}
|
||||
|
||||
var xhr = this._xhr;
|
||||
// withCredentials should be set after "open" for Safari and Chrome (< 19 ?)
|
||||
xhr.withCredentials = this.withCredentials;
|
||||
xhr.responseType = this.responseType;
|
||||
try {
|
||||
// xhr.send(); throws "Not enough arguments" in Firefox 3.0
|
||||
xhr.send( undefined );
|
||||
} catch ( error1 ) {
|
||||
// Safari 5.1.7, Opera 12
|
||||
throw error1;
|
||||
}
|
||||
};
|
||||
|
||||
function XHRTransport( xhr ) {
|
||||
this._xhr = new XHRWrapper( xhr );
|
||||
}
|
||||
|
||||
XHRTransport.prototype.open = function (
|
||||
onStartCallback,
|
||||
onProgressCallback,
|
||||
onFinishCallback,
|
||||
url,
|
||||
withCredentials,
|
||||
headers
|
||||
) {
|
||||
var xhr = this._xhr;
|
||||
xhr.open( 'GET', url );
|
||||
var offset = 0;
|
||||
xhr.onprogress = function () {
|
||||
var responseText = xhr.responseText;
|
||||
var chunk = responseText.slice( offset );
|
||||
offset += chunk.length;
|
||||
onProgressCallback( chunk );
|
||||
};
|
||||
xhr.onreadystatechange = function () {
|
||||
if ( xhr.readyState === 2 ) {
|
||||
var status = xhr.status;
|
||||
var statusText = xhr.statusText;
|
||||
var contentType = xhr.getResponseHeader( 'Content-Type' );
|
||||
onStartCallback( status, statusText, contentType );
|
||||
} else if ( xhr.readyState === 4 ) {
|
||||
onFinishCallback();
|
||||
}
|
||||
};
|
||||
xhr.withCredentials = withCredentials;
|
||||
xhr.responseType = 'text';
|
||||
for ( var name in headers ) {
|
||||
if ( Object.prototype.hasOwnProperty.call( headers, name ) ) {
|
||||
xhr.setRequestHeader( name, headers[ name ] );
|
||||
}
|
||||
}
|
||||
xhr.send();
|
||||
};
|
||||
|
||||
XHRTransport.prototype.cancel = function () {
|
||||
var xhr = this._xhr;
|
||||
xhr.abort();
|
||||
};
|
||||
|
||||
function EventTarget() {
|
||||
this._listeners = Object.create( null );
|
||||
}
|
||||
|
||||
function throwError( e ) {
|
||||
setTimeout( function () {
|
||||
throw e;
|
||||
}, 0 );
|
||||
}
|
||||
|
||||
EventTarget.prototype.dispatchEvent = function ( event ) {
|
||||
event.target = this;
|
||||
var typeListeners = this._listeners[ event.type ];
|
||||
if ( typeListeners != undefined ) {
|
||||
var length = typeListeners.length;
|
||||
for ( var i = 0; i < length; i += 1 ) {
|
||||
var listener = typeListeners[ i ];
|
||||
try {
|
||||
if ( typeof listener.handleEvent === 'function' ) {
|
||||
listener.handleEvent( event );
|
||||
} else {
|
||||
listener.call( this, event );
|
||||
}
|
||||
} catch ( e ) {
|
||||
throwError( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
EventTarget.prototype.addEventListener = function ( type, listener ) {
|
||||
type = String( type );
|
||||
var listeners = this._listeners;
|
||||
var typeListeners = listeners[ type ];
|
||||
if ( typeListeners == undefined ) {
|
||||
typeListeners = [];
|
||||
listeners[ type ] = typeListeners;
|
||||
}
|
||||
var found = false;
|
||||
for ( var i = 0; i < typeListeners.length; i += 1 ) {
|
||||
if ( typeListeners[ i ] === listener ) {
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
if ( ! found ) {
|
||||
typeListeners.push( listener );
|
||||
}
|
||||
};
|
||||
EventTarget.prototype.removeEventListener = function ( type, listener ) {
|
||||
type = String( type );
|
||||
var listeners = this._listeners;
|
||||
var typeListeners = listeners[ type ];
|
||||
if ( typeListeners != undefined ) {
|
||||
var filtered = [];
|
||||
for ( var i = 0; i < typeListeners.length; i += 1 ) {
|
||||
if ( typeListeners[ i ] !== listener ) {
|
||||
filtered.push( typeListeners[ i ] );
|
||||
}
|
||||
}
|
||||
if ( filtered.length === 0 ) {
|
||||
delete listeners[ type ];
|
||||
} else {
|
||||
listeners[ type ] = filtered;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function Event( type ) {
|
||||
this.type = type;
|
||||
this.target = undefined;
|
||||
}
|
||||
|
||||
function MessageEvent( type, options ) {
|
||||
Event.call( this, type );
|
||||
this.data = options.data;
|
||||
this.lastEventId = options.lastEventId;
|
||||
}
|
||||
|
||||
MessageEvent.prototype = Object.create( Event.prototype );
|
||||
|
||||
var WAITING = -1;
|
||||
var CONNECTING = 0;
|
||||
var OPEN = 1;
|
||||
var CLOSED = 2;
|
||||
|
||||
var AFTER_CR = -1;
|
||||
var FIELD_START = 0;
|
||||
var FIELD = 1;
|
||||
var VALUE_START = 2;
|
||||
var VALUE = 3;
|
||||
|
||||
var contentTypeRegExp = /^text\/event\-stream;?(\s*charset\=utf\-8)?$/i;
|
||||
|
||||
var MINIMUM_DURATION = 1000;
|
||||
var MAXIMUM_DURATION = 18000000;
|
||||
|
||||
var parseDuration = function ( value, def ) {
|
||||
var n = parseInt( value, 10 );
|
||||
if ( n !== n ) {
|
||||
n = def;
|
||||
}
|
||||
return clampDuration( n );
|
||||
};
|
||||
var clampDuration = function ( n ) {
|
||||
return Math.min( Math.max( n, MINIMUM_DURATION ), MAXIMUM_DURATION );
|
||||
};
|
||||
|
||||
var fire = function ( that, f, event ) {
|
||||
try {
|
||||
if ( typeof f === 'function' ) {
|
||||
f.call( that, event );
|
||||
}
|
||||
} catch ( e ) {
|
||||
throwError( e );
|
||||
}
|
||||
};
|
||||
|
||||
function EventSourcePolyfill( url, options ) {
|
||||
EventTarget.call( this );
|
||||
|
||||
this.onopen = undefined;
|
||||
this.onmessage = undefined;
|
||||
this.onerror = undefined;
|
||||
|
||||
this.url = undefined;
|
||||
this.readyState = undefined;
|
||||
this.withCredentials = undefined;
|
||||
|
||||
this._close = undefined;
|
||||
|
||||
start( this, url, options );
|
||||
}
|
||||
|
||||
function start( es, url, options ) {
|
||||
url = String( url );
|
||||
var withCredentials =
|
||||
options != undefined && Boolean( options.withCredentials );
|
||||
|
||||
var initialRetry = clampDuration( 1000 );
|
||||
var heartbeatTimeout = clampDuration( 45000 );
|
||||
|
||||
var lastEventId = '';
|
||||
var retry = initialRetry;
|
||||
var wasActivity = false;
|
||||
var headers =
|
||||
options != undefined && options.headers != undefined
|
||||
? JSON.parse( JSON.stringify( options.headers ) )
|
||||
: undefined;
|
||||
var CurrentTransport =
|
||||
options != undefined && options.Transport != undefined
|
||||
? options.Transport
|
||||
: XDomainRequest != undefined
|
||||
? XDomainRequest
|
||||
: XMLHttpRequest;
|
||||
var transport = new XHRTransport( new CurrentTransport() );
|
||||
var timeout = 0;
|
||||
var currentState = WAITING;
|
||||
var dataBuffer = '';
|
||||
var lastEventIdBuffer = '';
|
||||
var eventTypeBuffer = '';
|
||||
|
||||
var textBuffer = '';
|
||||
var state = FIELD_START;
|
||||
var fieldStart = 0;
|
||||
var valueStart = 0;
|
||||
|
||||
var onStart = function ( status, statusText, contentType ) {
|
||||
if ( currentState === CONNECTING ) {
|
||||
if (
|
||||
status === 200 &&
|
||||
contentType != undefined &&
|
||||
contentTypeRegExp.test( contentType )
|
||||
) {
|
||||
currentState = OPEN;
|
||||
wasActivity = true;
|
||||
retry = initialRetry;
|
||||
es.readyState = OPEN;
|
||||
var event = new Event( 'open' );
|
||||
es.dispatchEvent( event );
|
||||
fire( es, es.onopen, event );
|
||||
} else {
|
||||
var message = '';
|
||||
if ( status !== 200 ) {
|
||||
if ( statusText ) {
|
||||
statusText = statusText.replace( /\s+/g, ' ' );
|
||||
}
|
||||
message =
|
||||
"EventSource's response has a status " +
|
||||
status +
|
||||
' ' +
|
||||
statusText +
|
||||
' that is not 200. Aborting the connection.';
|
||||
} else {
|
||||
message =
|
||||
"EventSource's response has a Content-Type specifying an unsupported type: " +
|
||||
( contentType == undefined
|
||||
? '-'
|
||||
: contentType.replace( /\s+/g, ' ' ) ) +
|
||||
'. Aborting the connection.';
|
||||
}
|
||||
throwError( new Error( message ) );
|
||||
close();
|
||||
var event = new Event( 'error' );
|
||||
es.dispatchEvent( event );
|
||||
fire( es, es.onerror, event );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var onProgress = function ( textChunk ) {
|
||||
if ( currentState === OPEN ) {
|
||||
var n = -1;
|
||||
for ( var i = 0; i < textChunk.length; i += 1 ) {
|
||||
var c = textChunk.charCodeAt( i );
|
||||
if (
|
||||
c === '\n'.charCodeAt( 0 ) ||
|
||||
c === '\r'.charCodeAt( 0 )
|
||||
) {
|
||||
n = i;
|
||||
}
|
||||
}
|
||||
var chunk =
|
||||
( n !== -1 ? textBuffer : '' ) +
|
||||
textChunk.slice( 0, n + 1 );
|
||||
textBuffer =
|
||||
( n === -1 ? textBuffer : '' ) + textChunk.slice( n + 1 );
|
||||
if ( chunk !== '' ) {
|
||||
wasActivity = true;
|
||||
}
|
||||
for (
|
||||
var position = 0;
|
||||
position < chunk.length;
|
||||
position += 1
|
||||
) {
|
||||
var c = chunk.charCodeAt( position );
|
||||
if ( state === AFTER_CR && c === '\n'.charCodeAt( 0 ) ) {
|
||||
state = FIELD_START;
|
||||
} else {
|
||||
if ( state === AFTER_CR ) {
|
||||
state = FIELD_START;
|
||||
}
|
||||
if (
|
||||
c === '\r'.charCodeAt( 0 ) ||
|
||||
c === '\n'.charCodeAt( 0 )
|
||||
) {
|
||||
if ( state !== FIELD_START ) {
|
||||
if ( state === FIELD ) {
|
||||
valueStart = position + 1;
|
||||
}
|
||||
var field = chunk.slice(
|
||||
fieldStart,
|
||||
valueStart - 1
|
||||
);
|
||||
var value = chunk.slice(
|
||||
valueStart +
|
||||
( valueStart < position &&
|
||||
chunk.charCodeAt( valueStart ) ===
|
||||
' '.charCodeAt( 0 )
|
||||
? 1
|
||||
: 0 ),
|
||||
position
|
||||
);
|
||||
if ( field === 'data' ) {
|
||||
dataBuffer += '\n';
|
||||
dataBuffer += value;
|
||||
} else if ( field === 'id' ) {
|
||||
lastEventIdBuffer = value;
|
||||
} else if ( field === 'event' ) {
|
||||
eventTypeBuffer = value;
|
||||
} else if ( field === 'retry' ) {
|
||||
initialRetry = parseDuration(
|
||||
value,
|
||||
initialRetry
|
||||
);
|
||||
retry = initialRetry;
|
||||
} else if ( field === 'heartbeatTimeout' ) {
|
||||
heartbeatTimeout = parseDuration(
|
||||
value,
|
||||
heartbeatTimeout
|
||||
);
|
||||
if ( timeout !== 0 ) {
|
||||
clearTimeout( timeout );
|
||||
timeout = setTimeout( function () {
|
||||
onTimeout();
|
||||
}, heartbeatTimeout );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( state === FIELD_START ) {
|
||||
if ( dataBuffer !== '' ) {
|
||||
lastEventId = lastEventIdBuffer;
|
||||
if ( eventTypeBuffer === '' ) {
|
||||
eventTypeBuffer = 'message';
|
||||
}
|
||||
var event = new MessageEvent(
|
||||
eventTypeBuffer,
|
||||
{
|
||||
data: dataBuffer.slice( 1 ),
|
||||
lastEventId: lastEventIdBuffer,
|
||||
}
|
||||
);
|
||||
es.dispatchEvent( event );
|
||||
if ( eventTypeBuffer === 'message' ) {
|
||||
fire( es, es.onmessage, event );
|
||||
}
|
||||
if ( currentState === CLOSED ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
dataBuffer = '';
|
||||
eventTypeBuffer = '';
|
||||
}
|
||||
state =
|
||||
c === '\r'.charCodeAt( 0 )
|
||||
? AFTER_CR
|
||||
: FIELD_START;
|
||||
} else {
|
||||
if ( state === FIELD_START ) {
|
||||
fieldStart = position;
|
||||
state = FIELD;
|
||||
}
|
||||
if ( state === FIELD ) {
|
||||
if ( c === ':'.charCodeAt( 0 ) ) {
|
||||
valueStart = position + 1;
|
||||
state = VALUE_START;
|
||||
}
|
||||
} else if ( state === VALUE_START ) {
|
||||
state = VALUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var onFinish = function () {
|
||||
if ( currentState === OPEN || currentState === CONNECTING ) {
|
||||
currentState = WAITING;
|
||||
if ( timeout !== 0 ) {
|
||||
clearTimeout( timeout );
|
||||
timeout = 0;
|
||||
}
|
||||
timeout = setTimeout( function () {
|
||||
onTimeout();
|
||||
}, retry );
|
||||
retry = clampDuration(
|
||||
Math.min( initialRetry * 16, retry * 2 )
|
||||
);
|
||||
|
||||
es.readyState = CONNECTING;
|
||||
var event = new Event( 'error' );
|
||||
es.dispatchEvent( event );
|
||||
fire( es, es.onerror, event );
|
||||
}
|
||||
};
|
||||
|
||||
var close = function () {
|
||||
currentState = CLOSED;
|
||||
transport.cancel();
|
||||
if ( timeout !== 0 ) {
|
||||
clearTimeout( timeout );
|
||||
timeout = 0;
|
||||
}
|
||||
es.readyState = CLOSED;
|
||||
};
|
||||
|
||||
var onTimeout = function () {
|
||||
timeout = 0;
|
||||
|
||||
if ( currentState !== WAITING ) {
|
||||
if ( ! wasActivity ) {
|
||||
throwError(
|
||||
new Error(
|
||||
'No activity within ' +
|
||||
heartbeatTimeout +
|
||||
' milliseconds. Reconnecting.'
|
||||
)
|
||||
);
|
||||
transport.cancel();
|
||||
} else {
|
||||
wasActivity = false;
|
||||
timeout = setTimeout( function () {
|
||||
onTimeout();
|
||||
}, heartbeatTimeout );
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
wasActivity = false;
|
||||
timeout = setTimeout( function () {
|
||||
onTimeout();
|
||||
}, heartbeatTimeout );
|
||||
|
||||
currentState = CONNECTING;
|
||||
dataBuffer = '';
|
||||
eventTypeBuffer = '';
|
||||
lastEventIdBuffer = lastEventId;
|
||||
textBuffer = '';
|
||||
fieldStart = 0;
|
||||
valueStart = 0;
|
||||
state = FIELD_START;
|
||||
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=428916
|
||||
// Request header field Last-Event-ID is not allowed by Access-Control-Allow-Headers.
|
||||
var requestURL = url;
|
||||
if (
|
||||
url.slice( 0, 5 ) !== 'data:' &&
|
||||
url.slice( 0, 5 ) !== 'blob:'
|
||||
) {
|
||||
requestURL =
|
||||
url +
|
||||
( url.indexOf( '?', 0 ) === -1 ? '?' : '&' ) +
|
||||
'lastEventId=' +
|
||||
encodeURIComponent( lastEventId );
|
||||
}
|
||||
var requestHeaders = {};
|
||||
requestHeaders[ 'Accept' ] = 'text/event-stream';
|
||||
if ( headers != undefined ) {
|
||||
for ( var name in headers ) {
|
||||
if (
|
||||
Object.prototype.hasOwnProperty.call( headers, name )
|
||||
) {
|
||||
requestHeaders[ name ] = headers[ name ];
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
transport.open(
|
||||
onStart,
|
||||
onProgress,
|
||||
onFinish,
|
||||
requestURL,
|
||||
withCredentials,
|
||||
requestHeaders
|
||||
);
|
||||
} catch ( error ) {
|
||||
close();
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
es.url = url;
|
||||
es.readyState = CONNECTING;
|
||||
es.withCredentials = withCredentials;
|
||||
es._close = close;
|
||||
|
||||
onTimeout();
|
||||
}
|
||||
|
||||
EventSourcePolyfill.prototype = Object.create( EventTarget.prototype );
|
||||
EventSourcePolyfill.prototype.CONNECTING = CONNECTING;
|
||||
EventSourcePolyfill.prototype.OPEN = OPEN;
|
||||
EventSourcePolyfill.prototype.CLOSED = CLOSED;
|
||||
EventSourcePolyfill.prototype.close = function () {
|
||||
this._close();
|
||||
};
|
||||
|
||||
EventSourcePolyfill.CONNECTING = CONNECTING;
|
||||
EventSourcePolyfill.OPEN = OPEN;
|
||||
EventSourcePolyfill.CLOSED = CLOSED;
|
||||
EventSourcePolyfill.prototype.withCredentials = undefined;
|
||||
|
||||
global.EventSourcePolyfill = EventSourcePolyfill;
|
||||
global.NativeEventSource = NativeEventSource;
|
||||
|
||||
if (
|
||||
XMLHttpRequest != undefined &&
|
||||
( NativeEventSource == undefined ||
|
||||
! ( 'withCredentials' in NativeEventSource.prototype ) )
|
||||
) {
|
||||
// Why replace a native EventSource ?
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=444328
|
||||
// https://bugzilla.mozilla.org/show_bug.cgi?id=831392
|
||||
// https://code.google.com/p/chromium/issues/detail?id=260144
|
||||
// https://code.google.com/p/chromium/issues/detail?id=225654
|
||||
// ...
|
||||
global.EventSource = EventSourcePolyfill;
|
||||
}
|
||||
} )( typeof window !== 'undefined' ? window : this );
|
||||
499
Atomaste Reference/public_html/wp-content/plugins/astra-sites/inc/assets/js/eventsource.min.js
vendored
Normal file
499
Atomaste Reference/public_html/wp-content/plugins/astra-sites/inc/assets/js/eventsource.min.js
vendored
Normal file
@@ -0,0 +1,499 @@
|
||||
/**
|
||||
* EventSource
|
||||
* https://github.com/Yaffle/EventSource
|
||||
*
|
||||
* Released under the MIT License (MIT)
|
||||
* https://github.com/Yaffle/EventSource/blob/master/LICENSE.md
|
||||
*/
|
||||
! ( function ( a ) {
|
||||
'use strict';
|
||||
function b( a ) {
|
||||
( this.withCredentials = ! 1 ),
|
||||
( this.responseType = '' ),
|
||||
( this.readyState = 0 ),
|
||||
( this.status = 0 ),
|
||||
( this.statusText = '' ),
|
||||
( this.responseText = '' ),
|
||||
( this.onprogress = p ),
|
||||
( this.onreadystatechange = p ),
|
||||
( this._contentType = '' ),
|
||||
( this._xhr = a ),
|
||||
( this._sendTimeout = 0 ),
|
||||
( this._abort = p );
|
||||
}
|
||||
function c( a ) {
|
||||
this._xhr = new b( a );
|
||||
}
|
||||
function d() {
|
||||
this._listeners = Object.create( null );
|
||||
}
|
||||
function e( a ) {
|
||||
j( function () {
|
||||
throw a;
|
||||
}, 0 );
|
||||
}
|
||||
function f( a ) {
|
||||
( this.type = a ), ( this.target = void 0 );
|
||||
}
|
||||
function g( a, b ) {
|
||||
f.call( this, a ),
|
||||
( this.data = b.data ),
|
||||
( this.lastEventId = b.lastEventId );
|
||||
}
|
||||
function h( a, b ) {
|
||||
d.call( this ),
|
||||
( this.onopen = void 0 ),
|
||||
( this.onmessage = void 0 ),
|
||||
( this.onerror = void 0 ),
|
||||
( this.url = void 0 ),
|
||||
( this.readyState = void 0 ),
|
||||
( this.withCredentials = void 0 ),
|
||||
( this._close = void 0 ),
|
||||
i( this, a, b );
|
||||
}
|
||||
function i( a, b, d ) {
|
||||
b = String( b );
|
||||
var h = void 0 != d && Boolean( d.withCredentials ),
|
||||
i = D( 1e3 ),
|
||||
n = D( 45e3 ),
|
||||
o = '',
|
||||
p = i,
|
||||
A = ! 1,
|
||||
B =
|
||||
void 0 != d && void 0 != d.headers
|
||||
? JSON.parse( JSON.stringify( d.headers ) )
|
||||
: void 0,
|
||||
F =
|
||||
void 0 != d && void 0 != d.Transport
|
||||
? d.Transport
|
||||
: void 0 != m
|
||||
? m
|
||||
: l,
|
||||
G = new c( new F() ),
|
||||
H = 0,
|
||||
I = q,
|
||||
J = '',
|
||||
K = '',
|
||||
L = '',
|
||||
M = '',
|
||||
N = v,
|
||||
O = 0,
|
||||
P = 0,
|
||||
Q = function ( b, c, d ) {
|
||||
if ( I === r )
|
||||
if ( 200 === b && void 0 != d && z.test( d ) ) {
|
||||
( I = s ), ( A = ! 0 ), ( p = i ), ( a.readyState = s );
|
||||
var g = new f( 'open' );
|
||||
a.dispatchEvent( g ), E( a, a.onopen, g );
|
||||
} else {
|
||||
var h = '';
|
||||
200 !== b
|
||||
? ( c && ( c = c.replace( /\s+/g, ' ' ) ),
|
||||
( h =
|
||||
"EventSource's response has a status " +
|
||||
b +
|
||||
' ' +
|
||||
c +
|
||||
' that is not 200. Aborting the connection.' ) )
|
||||
: ( h =
|
||||
"EventSource's response has a Content-Type specifying an unsupported type: " +
|
||||
( void 0 == d
|
||||
? '-'
|
||||
: d.replace( /\s+/g, ' ' ) ) +
|
||||
'. Aborting the connection.' ),
|
||||
e( new Error( h ) ),
|
||||
T();
|
||||
var g = new f( 'error' );
|
||||
a.dispatchEvent( g ), E( a, a.onerror, g );
|
||||
}
|
||||
},
|
||||
R = function ( b ) {
|
||||
if ( I === s ) {
|
||||
for ( var c = -1, d = 0; d < b.length; d += 1 ) {
|
||||
var e = b.charCodeAt( d );
|
||||
( e === '\n'.charCodeAt( 0 ) ||
|
||||
e === '\r'.charCodeAt( 0 ) ) &&
|
||||
( c = d );
|
||||
}
|
||||
var f = ( -1 !== c ? M : '' ) + b.slice( 0, c + 1 );
|
||||
( M = ( -1 === c ? M : '' ) + b.slice( c + 1 ) ),
|
||||
'' !== f && ( A = ! 0 );
|
||||
for ( var h = 0; h < f.length; h += 1 ) {
|
||||
var e = f.charCodeAt( h );
|
||||
if ( N === u && e === '\n'.charCodeAt( 0 ) ) N = v;
|
||||
else if (
|
||||
( N === u && ( N = v ),
|
||||
e === '\r'.charCodeAt( 0 ) ||
|
||||
e === '\n'.charCodeAt( 0 ) )
|
||||
) {
|
||||
if ( N !== v ) {
|
||||
N === w && ( P = h + 1 );
|
||||
var l = f.slice( O, P - 1 ),
|
||||
m = f.slice(
|
||||
P +
|
||||
( h > P &&
|
||||
f.charCodeAt( P ) ===
|
||||
' '.charCodeAt( 0 )
|
||||
? 1
|
||||
: 0 ),
|
||||
h
|
||||
);
|
||||
'data' === l
|
||||
? ( ( J += '\n' ), ( J += m ) )
|
||||
: 'id' === l
|
||||
? ( K = m )
|
||||
: 'event' === l
|
||||
? ( L = m )
|
||||
: 'retry' === l
|
||||
? ( ( i = C( m, i ) ), ( p = i ) )
|
||||
: 'heartbeatTimeout' === l &&
|
||||
( ( n = C( m, n ) ),
|
||||
0 !== H &&
|
||||
( k( H ),
|
||||
( H = j( function () {
|
||||
U();
|
||||
}, n ) ) ) );
|
||||
}
|
||||
if ( N === v ) {
|
||||
if ( '' !== J ) {
|
||||
( o = K ), '' === L && ( L = 'message' );
|
||||
var q = new g( L, {
|
||||
data: J.slice( 1 ),
|
||||
lastEventId: K,
|
||||
} );
|
||||
if (
|
||||
( a.dispatchEvent( q ),
|
||||
'message' === L &&
|
||||
E( a, a.onmessage, q ),
|
||||
I === t )
|
||||
)
|
||||
return;
|
||||
}
|
||||
( J = '' ), ( L = '' );
|
||||
}
|
||||
N = e === '\r'.charCodeAt( 0 ) ? u : v;
|
||||
} else
|
||||
N === v && ( ( O = h ), ( N = w ) ),
|
||||
N === w
|
||||
? e === ':'.charCodeAt( 0 ) &&
|
||||
( ( P = h + 1 ), ( N = x ) )
|
||||
: N === x && ( N = y );
|
||||
}
|
||||
}
|
||||
},
|
||||
S = function () {
|
||||
if ( I === s || I === r ) {
|
||||
( I = q ),
|
||||
0 !== H && ( k( H ), ( H = 0 ) ),
|
||||
( H = j( function () {
|
||||
U();
|
||||
}, p ) ),
|
||||
( p = D( Math.min( 16 * i, 2 * p ) ) ),
|
||||
( a.readyState = r );
|
||||
var b = new f( 'error' );
|
||||
a.dispatchEvent( b ), E( a, a.onerror, b );
|
||||
}
|
||||
},
|
||||
T = function () {
|
||||
( I = t ),
|
||||
G.cancel(),
|
||||
0 !== H && ( k( H ), ( H = 0 ) ),
|
||||
( a.readyState = t );
|
||||
},
|
||||
U = function () {
|
||||
if ( ( ( H = 0 ), I !== q ) )
|
||||
return void ( A
|
||||
? ( ( A = ! 1 ),
|
||||
( H = j( function () {
|
||||
U();
|
||||
}, n ) ) )
|
||||
: ( e(
|
||||
new Error(
|
||||
'No activity within ' +
|
||||
n +
|
||||
' milliseconds. Reconnecting.'
|
||||
)
|
||||
),
|
||||
G.cancel() ) );
|
||||
( A = ! 1 ),
|
||||
( H = j( function () {
|
||||
U();
|
||||
}, n ) ),
|
||||
( I = r ),
|
||||
( J = '' ),
|
||||
( L = '' ),
|
||||
( K = o ),
|
||||
( M = '' ),
|
||||
( O = 0 ),
|
||||
( P = 0 ),
|
||||
( N = v );
|
||||
var a = b;
|
||||
'data:' !== b.slice( 0, 5 ) &&
|
||||
'blob:' !== b.slice( 0, 5 ) &&
|
||||
( a =
|
||||
b +
|
||||
( -1 === b.indexOf( '?', 0 ) ? '?' : '&' ) +
|
||||
'lastEventId=' +
|
||||
encodeURIComponent( o ) );
|
||||
var c = {};
|
||||
if ( ( ( c.Accept = 'text/event-stream' ), void 0 != B ) )
|
||||
for ( var d in B )
|
||||
Object.prototype.hasOwnProperty.call( B, d ) &&
|
||||
( c[ d ] = B[ d ] );
|
||||
try {
|
||||
G.open( Q, R, S, a, h, c );
|
||||
} catch ( f ) {
|
||||
throw ( T(), f );
|
||||
}
|
||||
};
|
||||
( a.url = b ),
|
||||
( a.readyState = r ),
|
||||
( a.withCredentials = h ),
|
||||
( a._close = T ),
|
||||
U();
|
||||
}
|
||||
var j = a.setTimeout,
|
||||
k = a.clearTimeout,
|
||||
l = a.XMLHttpRequest,
|
||||
m = a.XDomainRequest,
|
||||
n = a.EventSource,
|
||||
o = a.document;
|
||||
null == Object.create &&
|
||||
( Object.create = function ( a ) {
|
||||
function b() {}
|
||||
return ( b.prototype = a ), new b();
|
||||
} );
|
||||
var p = function () {};
|
||||
( b.prototype.open = function ( a, b ) {
|
||||
this._abort( ! 0 );
|
||||
var c = this,
|
||||
d = this._xhr,
|
||||
e = 1,
|
||||
f = 0;
|
||||
this._abort = function ( a ) {
|
||||
0 !== c._sendTimeout &&
|
||||
( k( c._sendTimeout ), ( c._sendTimeout = 0 ) ),
|
||||
( 1 === e || 2 === e || 3 === e ) &&
|
||||
( ( e = 4 ),
|
||||
( d.onload = p ),
|
||||
( d.onerror = p ),
|
||||
( d.onabort = p ),
|
||||
( d.onprogress = p ),
|
||||
( d.onreadystatechange = p ),
|
||||
d.abort(),
|
||||
0 !== f && ( k( f ), ( f = 0 ) ),
|
||||
a || ( ( c.readyState = 4 ), c.onreadystatechange() ) ),
|
||||
( e = 0 );
|
||||
};
|
||||
var g = function () {
|
||||
if ( 1 === e ) {
|
||||
var a = 0,
|
||||
b = '',
|
||||
f = void 0;
|
||||
if ( 'contentType' in d )
|
||||
( a = 200 ), ( b = 'OK' ), ( f = d.contentType );
|
||||
else
|
||||
try {
|
||||
( a = d.status ),
|
||||
( b = d.statusText ),
|
||||
( f = d.getResponseHeader( 'Content-Type' ) );
|
||||
} catch ( g ) {
|
||||
( a = 0 ), ( b = '' ), ( f = void 0 );
|
||||
}
|
||||
0 !== a &&
|
||||
( ( e = 2 ),
|
||||
( c.readyState = 2 ),
|
||||
( c.status = a ),
|
||||
( c.statusText = b ),
|
||||
( c._contentType = f ),
|
||||
c.onreadystatechange() );
|
||||
}
|
||||
},
|
||||
h = function () {
|
||||
if ( ( g(), 2 === e || 3 === e ) ) {
|
||||
e = 3;
|
||||
var a = '';
|
||||
try {
|
||||
a = d.responseText;
|
||||
} catch ( b ) {}
|
||||
( c.readyState = 3 ),
|
||||
( c.responseText = a ),
|
||||
c.onprogress();
|
||||
}
|
||||
},
|
||||
i = function () {
|
||||
h(),
|
||||
( 1 === e || 2 === e || 3 === e ) &&
|
||||
( ( e = 4 ),
|
||||
0 !== f && ( k( f ), ( f = 0 ) ),
|
||||
( c.readyState = 4 ),
|
||||
c.onreadystatechange() );
|
||||
},
|
||||
m = function () {
|
||||
void 0 != d &&
|
||||
( 4 === d.readyState
|
||||
? i()
|
||||
: 3 === d.readyState
|
||||
? h()
|
||||
: 2 === d.readyState && g() );
|
||||
},
|
||||
n = function () {
|
||||
( f = j( function () {
|
||||
n();
|
||||
}, 500 ) ),
|
||||
3 === d.readyState && h();
|
||||
};
|
||||
( d.onload = i ),
|
||||
( d.onerror = i ),
|
||||
( d.onabort = i ),
|
||||
'sendAsBinary' in l.prototype ||
|
||||
'mozAnon' in l.prototype ||
|
||||
( d.onprogress = h ),
|
||||
( d.onreadystatechange = m ),
|
||||
'contentType' in d &&
|
||||
( b +=
|
||||
( -1 === b.indexOf( '?', 0 ) ? '?' : '&' ) +
|
||||
'padding=true' ),
|
||||
d.open( a, b, ! 0 ),
|
||||
'readyState' in d &&
|
||||
( f = j( function () {
|
||||
n();
|
||||
}, 0 ) );
|
||||
} ),
|
||||
( b.prototype.abort = function () {
|
||||
this._abort( ! 1 );
|
||||
} ),
|
||||
( b.prototype.getResponseHeader = function ( a ) {
|
||||
return this._contentType;
|
||||
} ),
|
||||
( b.prototype.setRequestHeader = function ( a, b ) {
|
||||
var c = this._xhr;
|
||||
'setRequestHeader' in c && c.setRequestHeader( a, b );
|
||||
} ),
|
||||
( b.prototype.send = function () {
|
||||
if (
|
||||
! ( 'ontimeout' in l.prototype ) &&
|
||||
void 0 != o &&
|
||||
void 0 != o.readyState &&
|
||||
'complete' !== o.readyState
|
||||
) {
|
||||
var a = this;
|
||||
return void ( a._sendTimeout = j( function () {
|
||||
( a._sendTimeout = 0 ), a.send();
|
||||
}, 4 ) );
|
||||
}
|
||||
var b = this._xhr;
|
||||
( b.withCredentials = this.withCredentials ),
|
||||
( b.responseType = this.responseType );
|
||||
try {
|
||||
b.send( void 0 );
|
||||
} catch ( c ) {
|
||||
throw c;
|
||||
}
|
||||
} ),
|
||||
( c.prototype.open = function ( a, b, c, d, e, f ) {
|
||||
var g = this._xhr;
|
||||
g.open( 'GET', d );
|
||||
var h = 0;
|
||||
( g.onprogress = function () {
|
||||
var a = g.responseText,
|
||||
c = a.slice( h );
|
||||
( h += c.length ), b( c );
|
||||
} ),
|
||||
( g.onreadystatechange = function () {
|
||||
if ( 2 === g.readyState ) {
|
||||
var b = g.status,
|
||||
d = g.statusText,
|
||||
e = g.getResponseHeader( 'Content-Type' );
|
||||
a( b, d, e );
|
||||
} else 4 === g.readyState && c();
|
||||
} ),
|
||||
( g.withCredentials = e ),
|
||||
( g.responseType = 'text' );
|
||||
for ( var i in f )
|
||||
Object.prototype.hasOwnProperty.call( f, i ) &&
|
||||
g.setRequestHeader( i, f[ i ] );
|
||||
g.send();
|
||||
} ),
|
||||
( c.prototype.cancel = function () {
|
||||
var a = this._xhr;
|
||||
a.abort();
|
||||
} ),
|
||||
( d.prototype.dispatchEvent = function ( a ) {
|
||||
a.target = this;
|
||||
var b = this._listeners[ a.type ];
|
||||
if ( void 0 != b )
|
||||
for ( var c = b.length, d = 0; c > d; d += 1 ) {
|
||||
var f = b[ d ];
|
||||
try {
|
||||
'function' == typeof f.handleEvent
|
||||
? f.handleEvent( a )
|
||||
: f.call( this, a );
|
||||
} catch ( g ) {
|
||||
e( g );
|
||||
}
|
||||
}
|
||||
} ),
|
||||
( d.prototype.addEventListener = function ( a, b ) {
|
||||
a = String( a );
|
||||
var c = this._listeners,
|
||||
d = c[ a ];
|
||||
void 0 == d && ( ( d = [] ), ( c[ a ] = d ) );
|
||||
for ( var e = ! 1, f = 0; f < d.length; f += 1 )
|
||||
d[ f ] === b && ( e = ! 0 );
|
||||
e || d.push( b );
|
||||
} ),
|
||||
( d.prototype.removeEventListener = function ( a, b ) {
|
||||
a = String( a );
|
||||
var c = this._listeners,
|
||||
d = c[ a ];
|
||||
if ( void 0 != d ) {
|
||||
for ( var e = [], f = 0; f < d.length; f += 1 )
|
||||
d[ f ] !== b && e.push( d[ f ] );
|
||||
0 === e.length ? delete c[ a ] : ( c[ a ] = e );
|
||||
}
|
||||
} ),
|
||||
( g.prototype = Object.create( f.prototype ) );
|
||||
var q = -1,
|
||||
r = 0,
|
||||
s = 1,
|
||||
t = 2,
|
||||
u = -1,
|
||||
v = 0,
|
||||
w = 1,
|
||||
x = 2,
|
||||
y = 3,
|
||||
z = /^text\/event\-stream;?(\s*charset\=utf\-8)?$/i,
|
||||
A = 1e3,
|
||||
B = 18e6,
|
||||
C = function ( a, b ) {
|
||||
var c = parseInt( a, 10 );
|
||||
return c !== c && ( c = b ), D( c );
|
||||
},
|
||||
D = function ( a ) {
|
||||
return Math.min( Math.max( a, A ), B );
|
||||
},
|
||||
E = function ( a, b, c ) {
|
||||
try {
|
||||
'function' == typeof b && b.call( a, c );
|
||||
} catch ( d ) {
|
||||
e( d );
|
||||
}
|
||||
};
|
||||
( h.prototype = Object.create( d.prototype ) ),
|
||||
( h.prototype.CONNECTING = r ),
|
||||
( h.prototype.OPEN = s ),
|
||||
( h.prototype.CLOSED = t ),
|
||||
( h.prototype.close = function () {
|
||||
this._close();
|
||||
} ),
|
||||
( h.CONNECTING = r ),
|
||||
( h.OPEN = s ),
|
||||
( h.CLOSED = t ),
|
||||
( h.prototype.withCredentials = void 0 ),
|
||||
( a.EventSourcePolyfill = h ),
|
||||
( a.NativeEventSource = n ),
|
||||
void 0 == l ||
|
||||
( void 0 != n && 'withCredentials' in n.prototype ) ||
|
||||
( a.EventSource = h );
|
||||
} )( 'undefined' != typeof window ? window : this );
|
||||
@@ -0,0 +1,590 @@
|
||||
/**
|
||||
* Fetch
|
||||
* https://github.com/github/fetch
|
||||
*
|
||||
* Released under the MIT License (MIT)
|
||||
* https://github.com/github/fetch/blob/master/LICENSE
|
||||
*/
|
||||
( function ( global, factory ) {
|
||||
typeof exports === 'object' && typeof module !== 'undefined'
|
||||
? factory( exports )
|
||||
: typeof define === 'function' && define.amd
|
||||
? define( [ 'exports' ], factory )
|
||||
: factory( ( global.WHATWGFetch = {} ) );
|
||||
} )( this, function ( exports ) {
|
||||
'use strict';
|
||||
|
||||
var support = {
|
||||
searchParams: 'URLSearchParams' in self,
|
||||
iterable: 'Symbol' in self && 'iterator' in Symbol,
|
||||
blob:
|
||||
'FileReader' in self &&
|
||||
'Blob' in self &&
|
||||
( function () {
|
||||
try {
|
||||
new Blob();
|
||||
return true;
|
||||
} catch ( e ) {
|
||||
return false;
|
||||
}
|
||||
} )(),
|
||||
formData: 'FormData' in self,
|
||||
arrayBuffer: 'ArrayBuffer' in self,
|
||||
};
|
||||
|
||||
function isDataView( obj ) {
|
||||
return obj && DataView.prototype.isPrototypeOf( obj );
|
||||
}
|
||||
|
||||
if ( support.arrayBuffer ) {
|
||||
var viewClasses = [
|
||||
'[object Int8Array]',
|
||||
'[object Uint8Array]',
|
||||
'[object Uint8ClampedArray]',
|
||||
'[object Int16Array]',
|
||||
'[object Uint16Array]',
|
||||
'[object Int32Array]',
|
||||
'[object Uint32Array]',
|
||||
'[object Float32Array]',
|
||||
'[object Float64Array]',
|
||||
];
|
||||
|
||||
var isArrayBufferView =
|
||||
ArrayBuffer.isView ||
|
||||
function ( obj ) {
|
||||
return (
|
||||
obj &&
|
||||
viewClasses.indexOf(
|
||||
Object.prototype.toString.call( obj )
|
||||
) > -1
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeName( name ) {
|
||||
if ( typeof name !== 'string' ) {
|
||||
name = String( name );
|
||||
}
|
||||
if ( /[^a-z0-9\-#$%&'*+.^_`|~]/i.test( name ) ) {
|
||||
throw new TypeError( 'Invalid character in header field name' );
|
||||
}
|
||||
return name.toLowerCase();
|
||||
}
|
||||
|
||||
function normalizeValue( value ) {
|
||||
if ( typeof value !== 'string' ) {
|
||||
value = String( value );
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
// Build a destructive iterator for the value list
|
||||
function iteratorFor( items ) {
|
||||
var iterator = {
|
||||
next: function () {
|
||||
var value = items.shift();
|
||||
return { done: value === undefined, value: value };
|
||||
},
|
||||
};
|
||||
|
||||
if ( support.iterable ) {
|
||||
iterator[ Symbol.iterator ] = function () {
|
||||
return iterator;
|
||||
};
|
||||
}
|
||||
|
||||
return iterator;
|
||||
}
|
||||
|
||||
function Headers( headers ) {
|
||||
this.map = {};
|
||||
|
||||
if ( headers instanceof Headers ) {
|
||||
headers.forEach( function ( value, name ) {
|
||||
this.append( name, value );
|
||||
}, this );
|
||||
} else if ( Array.isArray( headers ) ) {
|
||||
headers.forEach( function ( header ) {
|
||||
this.append( header[ 0 ], header[ 1 ] );
|
||||
}, this );
|
||||
} else if ( headers ) {
|
||||
Object.getOwnPropertyNames( headers ).forEach( function ( name ) {
|
||||
this.append( name, headers[ name ] );
|
||||
}, this );
|
||||
}
|
||||
}
|
||||
|
||||
Headers.prototype.append = function ( name, value ) {
|
||||
name = normalizeName( name );
|
||||
value = normalizeValue( value );
|
||||
var oldValue = this.map[ name ];
|
||||
this.map[ name ] = oldValue ? oldValue + ', ' + value : value;
|
||||
};
|
||||
|
||||
Headers.prototype[ 'delete' ] = function ( name ) {
|
||||
delete this.map[ normalizeName( name ) ];
|
||||
};
|
||||
|
||||
Headers.prototype.get = function ( name ) {
|
||||
name = normalizeName( name );
|
||||
return this.has( name ) ? this.map[ name ] : null;
|
||||
};
|
||||
|
||||
Headers.prototype.has = function ( name ) {
|
||||
return this.map.hasOwnProperty( normalizeName( name ) );
|
||||
};
|
||||
|
||||
Headers.prototype.set = function ( name, value ) {
|
||||
this.map[ normalizeName( name ) ] = normalizeValue( value );
|
||||
};
|
||||
|
||||
Headers.prototype.forEach = function ( callback, thisArg ) {
|
||||
for ( var name in this.map ) {
|
||||
if ( this.map.hasOwnProperty( name ) ) {
|
||||
callback.call( thisArg, this.map[ name ], name, this );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Headers.prototype.keys = function () {
|
||||
var items = [];
|
||||
this.forEach( function ( value, name ) {
|
||||
items.push( name );
|
||||
} );
|
||||
return iteratorFor( items );
|
||||
};
|
||||
|
||||
Headers.prototype.values = function () {
|
||||
var items = [];
|
||||
this.forEach( function ( value ) {
|
||||
items.push( value );
|
||||
} );
|
||||
return iteratorFor( items );
|
||||
};
|
||||
|
||||
Headers.prototype.entries = function () {
|
||||
var items = [];
|
||||
this.forEach( function ( value, name ) {
|
||||
items.push( [ name, value ] );
|
||||
} );
|
||||
return iteratorFor( items );
|
||||
};
|
||||
|
||||
if ( support.iterable ) {
|
||||
Headers.prototype[ Symbol.iterator ] = Headers.prototype.entries;
|
||||
}
|
||||
|
||||
function consumed( body ) {
|
||||
if ( body.bodyUsed ) {
|
||||
return Promise.reject( new TypeError( 'Already read' ) );
|
||||
}
|
||||
body.bodyUsed = true;
|
||||
}
|
||||
|
||||
function fileReaderReady( reader ) {
|
||||
return new Promise( function ( resolve, reject ) {
|
||||
reader.onload = function () {
|
||||
resolve( reader.result );
|
||||
};
|
||||
reader.onerror = function () {
|
||||
reject( reader.error );
|
||||
};
|
||||
} );
|
||||
}
|
||||
|
||||
function readBlobAsArrayBuffer( blob ) {
|
||||
var reader = new FileReader();
|
||||
var promise = fileReaderReady( reader );
|
||||
reader.readAsArrayBuffer( blob );
|
||||
return promise;
|
||||
}
|
||||
|
||||
function readBlobAsText( blob ) {
|
||||
var reader = new FileReader();
|
||||
var promise = fileReaderReady( reader );
|
||||
reader.readAsText( blob );
|
||||
return promise;
|
||||
}
|
||||
|
||||
function readArrayBufferAsText( buf ) {
|
||||
var view = new Uint8Array( buf );
|
||||
var chars = new Array( view.length );
|
||||
|
||||
for ( var i = 0; i < view.length; i++ ) {
|
||||
chars[ i ] = String.fromCharCode( view[ i ] );
|
||||
}
|
||||
return chars.join( '' );
|
||||
}
|
||||
|
||||
function bufferClone( buf ) {
|
||||
if ( buf.slice ) {
|
||||
return buf.slice( 0 );
|
||||
} else {
|
||||
var view = new Uint8Array( buf.byteLength );
|
||||
view.set( new Uint8Array( buf ) );
|
||||
return view.buffer;
|
||||
}
|
||||
}
|
||||
|
||||
function Body() {
|
||||
this.bodyUsed = false;
|
||||
|
||||
this._initBody = function ( body ) {
|
||||
this._bodyInit = body;
|
||||
if ( ! body ) {
|
||||
this._bodyText = '';
|
||||
} else if ( typeof body === 'string' ) {
|
||||
this._bodyText = body;
|
||||
} else if ( support.blob && Blob.prototype.isPrototypeOf( body ) ) {
|
||||
this._bodyBlob = body;
|
||||
} else if (
|
||||
support.formData &&
|
||||
FormData.prototype.isPrototypeOf( body )
|
||||
) {
|
||||
this._bodyFormData = body;
|
||||
} else if (
|
||||
support.searchParams &&
|
||||
URLSearchParams.prototype.isPrototypeOf( body )
|
||||
) {
|
||||
this._bodyText = body.toString();
|
||||
} else if (
|
||||
support.arrayBuffer &&
|
||||
support.blob &&
|
||||
isDataView( body )
|
||||
) {
|
||||
this._bodyArrayBuffer = bufferClone( body.buffer );
|
||||
// IE 10-11 can't handle a DataView body.
|
||||
this._bodyInit = new Blob( [ this._bodyArrayBuffer ] );
|
||||
} else if (
|
||||
support.arrayBuffer &&
|
||||
( ArrayBuffer.prototype.isPrototypeOf( body ) ||
|
||||
isArrayBufferView( body ) )
|
||||
) {
|
||||
this._bodyArrayBuffer = bufferClone( body );
|
||||
} else {
|
||||
this._bodyText = body = Object.prototype.toString.call( body );
|
||||
}
|
||||
|
||||
if ( ! this.headers.get( 'content-type' ) ) {
|
||||
if ( typeof body === 'string' ) {
|
||||
this.headers.set(
|
||||
'content-type',
|
||||
'text/plain;charset=UTF-8'
|
||||
);
|
||||
} else if ( this._bodyBlob && this._bodyBlob.type ) {
|
||||
this.headers.set( 'content-type', this._bodyBlob.type );
|
||||
} else if (
|
||||
support.searchParams &&
|
||||
URLSearchParams.prototype.isPrototypeOf( body )
|
||||
) {
|
||||
this.headers.set(
|
||||
'content-type',
|
||||
'application/x-www-form-urlencoded;charset=UTF-8'
|
||||
);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
if ( support.blob ) {
|
||||
this.blob = function () {
|
||||
var rejected = consumed( this );
|
||||
if ( rejected ) {
|
||||
return rejected;
|
||||
}
|
||||
|
||||
if ( this._bodyBlob ) {
|
||||
return Promise.resolve( this._bodyBlob );
|
||||
} else if ( this._bodyArrayBuffer ) {
|
||||
return Promise.resolve(
|
||||
new Blob( [ this._bodyArrayBuffer ] )
|
||||
);
|
||||
} else if ( this._bodyFormData ) {
|
||||
throw new Error( 'could not read FormData body as blob' );
|
||||
} else {
|
||||
return Promise.resolve( new Blob( [ this._bodyText ] ) );
|
||||
}
|
||||
};
|
||||
|
||||
this.arrayBuffer = function () {
|
||||
if ( this._bodyArrayBuffer ) {
|
||||
return (
|
||||
consumed( this ) ||
|
||||
Promise.resolve( this._bodyArrayBuffer )
|
||||
);
|
||||
} else {
|
||||
return this.blob().then( readBlobAsArrayBuffer );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
this.text = function () {
|
||||
var rejected = consumed( this );
|
||||
if ( rejected ) {
|
||||
return rejected;
|
||||
}
|
||||
|
||||
if ( this._bodyBlob ) {
|
||||
return readBlobAsText( this._bodyBlob );
|
||||
} else if ( this._bodyArrayBuffer ) {
|
||||
return Promise.resolve(
|
||||
readArrayBufferAsText( this._bodyArrayBuffer )
|
||||
);
|
||||
} else if ( this._bodyFormData ) {
|
||||
throw new Error( 'could not read FormData body as text' );
|
||||
} else {
|
||||
return Promise.resolve( this._bodyText );
|
||||
}
|
||||
};
|
||||
|
||||
if ( support.formData ) {
|
||||
this.formData = function () {
|
||||
return this.text().then( decode );
|
||||
};
|
||||
}
|
||||
|
||||
this.json = function () {
|
||||
return this.text().then( JSON.parse );
|
||||
};
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
// HTTP methods whose capitalization should be normalized
|
||||
var methods = [ 'DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT' ];
|
||||
|
||||
function normalizeMethod( method ) {
|
||||
var upcased = method.toUpperCase();
|
||||
return methods.indexOf( upcased ) > -1 ? upcased : method;
|
||||
}
|
||||
|
||||
function Request( input, options ) {
|
||||
options = options || {};
|
||||
var body = options.body;
|
||||
|
||||
if ( input instanceof Request ) {
|
||||
if ( input.bodyUsed ) {
|
||||
throw new TypeError( 'Already read' );
|
||||
}
|
||||
this.url = input.url;
|
||||
this.credentials = input.credentials;
|
||||
if ( ! options.headers ) {
|
||||
this.headers = new Headers( input.headers );
|
||||
}
|
||||
this.method = input.method;
|
||||
this.mode = input.mode;
|
||||
this.signal = input.signal;
|
||||
if ( ! body && input._bodyInit != null ) {
|
||||
body = input._bodyInit;
|
||||
input.bodyUsed = true;
|
||||
}
|
||||
} else {
|
||||
this.url = String( input );
|
||||
}
|
||||
|
||||
this.credentials =
|
||||
options.credentials || this.credentials || 'same-origin';
|
||||
if ( options.headers || ! this.headers ) {
|
||||
this.headers = new Headers( options.headers );
|
||||
}
|
||||
this.method = normalizeMethod( options.method || this.method || 'GET' );
|
||||
this.mode = options.mode || this.mode || null;
|
||||
this.signal = options.signal || this.signal;
|
||||
this.referrer = null;
|
||||
|
||||
if ( ( this.method === 'GET' || this.method === 'HEAD' ) && body ) {
|
||||
throw new TypeError( 'Body not allowed for GET or HEAD requests' );
|
||||
}
|
||||
this._initBody( body );
|
||||
}
|
||||
|
||||
Request.prototype.clone = function () {
|
||||
return new Request( this, { body: this._bodyInit } );
|
||||
};
|
||||
|
||||
function decode( body ) {
|
||||
var form = new FormData();
|
||||
body.trim()
|
||||
.split( '&' )
|
||||
.forEach( function ( bytes ) {
|
||||
if ( bytes ) {
|
||||
var split = bytes.split( '=' );
|
||||
var name = split.shift().replace( /\+/g, ' ' );
|
||||
var value = split.join( '=' ).replace( /\+/g, ' ' );
|
||||
form.append(
|
||||
decodeURIComponent( name ),
|
||||
decodeURIComponent( value )
|
||||
);
|
||||
}
|
||||
} );
|
||||
return form;
|
||||
}
|
||||
|
||||
function parseHeaders( rawHeaders ) {
|
||||
var headers = new Headers();
|
||||
// Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space
|
||||
// https://tools.ietf.org/html/rfc7230#section-3.2
|
||||
var preProcessedHeaders = rawHeaders.replace( /\r?\n[\t ]+/g, ' ' );
|
||||
preProcessedHeaders.split( /\r?\n/ ).forEach( function ( line ) {
|
||||
var parts = line.split( ':' );
|
||||
var key = parts.shift().trim();
|
||||
if ( key ) {
|
||||
var value = parts.join( ':' ).trim();
|
||||
headers.append( key, value );
|
||||
}
|
||||
} );
|
||||
return headers;
|
||||
}
|
||||
|
||||
Body.call( Request.prototype );
|
||||
|
||||
function Response( bodyInit, options ) {
|
||||
if ( ! options ) {
|
||||
options = {};
|
||||
}
|
||||
|
||||
this.type = 'default';
|
||||
this.status = options.status === undefined ? 200 : options.status;
|
||||
this.ok = this.status >= 200 && this.status < 300;
|
||||
this.statusText = 'statusText' in options ? options.statusText : 'OK';
|
||||
this.headers = new Headers( options.headers );
|
||||
this.url = options.url || '';
|
||||
this._initBody( bodyInit );
|
||||
}
|
||||
|
||||
Body.call( Response.prototype );
|
||||
|
||||
Response.prototype.clone = function () {
|
||||
return new Response( this._bodyInit, {
|
||||
status: this.status,
|
||||
statusText: this.statusText,
|
||||
headers: new Headers( this.headers ),
|
||||
url: this.url,
|
||||
} );
|
||||
};
|
||||
|
||||
Response.error = function () {
|
||||
var response = new Response( null, { status: 0, statusText: '' } );
|
||||
response.type = 'error';
|
||||
return response;
|
||||
};
|
||||
|
||||
var redirectStatuses = [ 301, 302, 303, 307, 308 ];
|
||||
|
||||
Response.redirect = function ( url, status ) {
|
||||
if ( redirectStatuses.indexOf( status ) === -1 ) {
|
||||
throw new RangeError( 'Invalid status code' );
|
||||
}
|
||||
|
||||
return new Response( null, {
|
||||
status: status,
|
||||
headers: { location: url },
|
||||
} );
|
||||
};
|
||||
|
||||
exports.DOMException = self.DOMException;
|
||||
try {
|
||||
new exports.DOMException();
|
||||
} catch ( err ) {
|
||||
exports.DOMException = function ( message, name ) {
|
||||
this.message = message;
|
||||
this.name = name;
|
||||
var error = Error( message );
|
||||
this.stack = error.stack;
|
||||
};
|
||||
exports.DOMException.prototype = Object.create( Error.prototype );
|
||||
exports.DOMException.prototype.constructor = exports.DOMException;
|
||||
}
|
||||
|
||||
function fetch( input, init ) {
|
||||
return new Promise( function ( resolve, reject ) {
|
||||
var request = new Request( input, init );
|
||||
|
||||
if ( request.signal && request.signal.aborted ) {
|
||||
return reject(
|
||||
new exports.DOMException( 'Aborted', 'AbortError' )
|
||||
);
|
||||
}
|
||||
|
||||
var xhr = new XMLHttpRequest();
|
||||
|
||||
function abortXhr() {
|
||||
xhr.abort();
|
||||
}
|
||||
|
||||
xhr.onload = function () {
|
||||
var options = {
|
||||
status: xhr.status,
|
||||
statusText: xhr.statusText,
|
||||
headers: parseHeaders( xhr.getAllResponseHeaders() || '' ),
|
||||
};
|
||||
options.url =
|
||||
'responseURL' in xhr
|
||||
? xhr.responseURL
|
||||
: options.headers.get( 'X-Request-URL' );
|
||||
var body = 'response' in xhr ? xhr.response : xhr.responseText;
|
||||
resolve( new Response( body, options ) );
|
||||
};
|
||||
|
||||
xhr.onerror = function () {
|
||||
reject( new TypeError( 'Network request failed' ) );
|
||||
};
|
||||
|
||||
xhr.ontimeout = function () {
|
||||
reject( new TypeError( 'Network request failed' ) );
|
||||
};
|
||||
|
||||
xhr.onabort = function () {
|
||||
reject( new exports.DOMException( 'Aborted', 'AbortError' ) );
|
||||
};
|
||||
|
||||
xhr.open( request.method, request.url, true );
|
||||
|
||||
if ( request.credentials === 'include' ) {
|
||||
xhr.withCredentials = true;
|
||||
} else if ( request.credentials === 'omit' ) {
|
||||
xhr.withCredentials = false;
|
||||
}
|
||||
|
||||
if ( 'responseType' in xhr && support.blob ) {
|
||||
xhr.responseType = 'blob';
|
||||
}
|
||||
|
||||
request.headers.forEach( function ( value, name ) {
|
||||
xhr.setRequestHeader( name, value );
|
||||
} );
|
||||
|
||||
if ( request.signal ) {
|
||||
request.signal.addEventListener( 'abort', abortXhr );
|
||||
|
||||
xhr.onreadystatechange = function () {
|
||||
// DONE (success or failure)
|
||||
if ( xhr.readyState === 4 ) {
|
||||
request.signal.removeEventListener( 'abort', abortXhr );
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
xhr.send(
|
||||
typeof request._bodyInit === 'undefined'
|
||||
? null
|
||||
: request._bodyInit
|
||||
);
|
||||
} );
|
||||
}
|
||||
|
||||
fetch.polyfill = true;
|
||||
|
||||
if ( ! self.fetch ) {
|
||||
self.fetch = fetch;
|
||||
self.Headers = Headers;
|
||||
self.Request = Request;
|
||||
self.Response = Response;
|
||||
}
|
||||
|
||||
exports.Headers = Headers;
|
||||
exports.Request = Request;
|
||||
exports.Response = Response;
|
||||
exports.fetch = fetch;
|
||||
|
||||
Object.defineProperty( exports, '__esModule', { value: true } );
|
||||
} );
|
||||
@@ -0,0 +1,348 @@
|
||||
'use strict';
|
||||
|
||||
function _defineProperty( obj, key, value ) {
|
||||
if ( key in obj ) {
|
||||
Object.defineProperty( obj, key, {
|
||||
value: value,
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
} );
|
||||
} else {
|
||||
obj[ key ] = value;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
function _slicedToArray( arr, i ) {
|
||||
return (
|
||||
_arrayWithHoles( arr ) ||
|
||||
_iterableToArrayLimit( arr, i ) ||
|
||||
_nonIterableRest()
|
||||
);
|
||||
}
|
||||
|
||||
function _nonIterableRest() {
|
||||
throw new TypeError(
|
||||
'Invalid attempt to destructure non-iterable instance'
|
||||
);
|
||||
}
|
||||
|
||||
function _iterableToArrayLimit( arr, i ) {
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
try {
|
||||
for (
|
||||
var _i = arr[ Symbol.iterator ](), _s;
|
||||
! ( _n = ( _s = _i.next() ).done );
|
||||
_n = true
|
||||
) {
|
||||
_arr.push( _s.value );
|
||||
if ( i && _arr.length === i ) break;
|
||||
}
|
||||
} catch ( err ) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if ( ! _n && _i[ 'return' ] != null ) _i[ 'return' ]();
|
||||
} finally {
|
||||
if ( _d ) throw _e;
|
||||
}
|
||||
}
|
||||
return _arr;
|
||||
}
|
||||
|
||||
function _arrayWithHoles( arr ) {
|
||||
if ( Array.isArray( arr ) ) return arr;
|
||||
}
|
||||
|
||||
var PHP = {
|
||||
stdClass: function stdClass() {},
|
||||
stringify: function stringify( val ) {
|
||||
var hash = new Map( [
|
||||
[ Infinity, 'd:INF;' ],
|
||||
[ -Infinity, 'd:-INF;' ],
|
||||
[ NaN, 'd:NAN;' ],
|
||||
[ null, 'N;' ],
|
||||
[ undefined, 'N;' ],
|
||||
] );
|
||||
|
||||
var utf8length = function utf8length( str ) {
|
||||
return str ? encodeURI( str ).match( /(%.)?./g ).length : 0;
|
||||
};
|
||||
|
||||
var serializeString = function serializeString( s ) {
|
||||
var delim =
|
||||
arguments.length > 1 && arguments[ 1 ] !== undefined
|
||||
? arguments[ 1 ]
|
||||
: '"';
|
||||
return ''
|
||||
.concat( utf8length( s ), ':' )
|
||||
.concat( delim[ 0 ] )
|
||||
.concat( s )
|
||||
.concat( delim[ delim.length - 1 ] );
|
||||
};
|
||||
|
||||
var ref = 0;
|
||||
|
||||
function serialize( val ) {
|
||||
var canReference =
|
||||
arguments.length > 1 && arguments[ 1 ] !== undefined
|
||||
? arguments[ 1 ]
|
||||
: true;
|
||||
if ( hash.has( val ) ) return hash.get( val );
|
||||
ref += canReference;
|
||||
if ( typeof val === 'string' )
|
||||
return 's:'.concat( serializeString( val ), ';' );
|
||||
if ( typeof val === 'number' )
|
||||
return ''
|
||||
.concat( Math.round( val ) === val ? 'i' : 'd', ':' )
|
||||
.concat(
|
||||
( '' + val )
|
||||
.toUpperCase()
|
||||
.replace( /(-?\d)E/, '$1.0E' ),
|
||||
';'
|
||||
);
|
||||
if ( typeof val === 'boolean' ) return 'b:'.concat( +val, ';' );
|
||||
var a = Array.isArray( val ) || val.constructor === Object;
|
||||
hash.set( val, ''.concat( 'rR'[ +a ], ':' ).concat( ref, ';' ) );
|
||||
|
||||
if ( typeof val.serialize === 'function' ) {
|
||||
return 'C:'
|
||||
.concat( serializeString( val.constructor.name ), ':' )
|
||||
.concat( serializeString( val.serialize(), '{}' ) );
|
||||
}
|
||||
|
||||
var vals = Object.entries( val ).filter( function ( _ref ) {
|
||||
var _ref2 = _slicedToArray( _ref, 2 ),
|
||||
k = _ref2[ 0 ],
|
||||
v = _ref2[ 1 ];
|
||||
|
||||
return typeof v !== 'function';
|
||||
} );
|
||||
return (
|
||||
( a
|
||||
? 'a'
|
||||
: 'O:'.concat( serializeString( val.constructor.name ) ) ) +
|
||||
':'.concat( vals.length, ':{' ).concat(
|
||||
vals
|
||||
.map( function ( _ref3 ) {
|
||||
var _ref4 = _slicedToArray( _ref3, 2 ),
|
||||
k = _ref4[ 0 ],
|
||||
v = _ref4[ 1 ];
|
||||
|
||||
return (
|
||||
serialize(
|
||||
a && /^\d{1,16}$/.test( k ) ? +k : k,
|
||||
false
|
||||
) + serialize( v )
|
||||
);
|
||||
} )
|
||||
.join( '' ),
|
||||
'}'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return serialize( val );
|
||||
},
|
||||
// Provide in second argument the classes that may be instantiated
|
||||
// e.g. { MyClass1, MyClass2 }
|
||||
parse: function parse( str ) {
|
||||
var allowedClasses =
|
||||
arguments.length > 1 && arguments[ 1 ] !== undefined
|
||||
? arguments[ 1 ]
|
||||
: {};
|
||||
allowedClasses.stdClass = PHP.stdClass; // Always allowed.
|
||||
|
||||
var offset = 0;
|
||||
var values = [ null ];
|
||||
var specialNums = {
|
||||
INF: Infinity,
|
||||
'-INF': -Infinity,
|
||||
NAN: NaN,
|
||||
};
|
||||
|
||||
var kick = function kick( msg ) {
|
||||
var i =
|
||||
arguments.length > 1 && arguments[ 1 ] !== undefined
|
||||
? arguments[ 1 ]
|
||||
: offset;
|
||||
throw new Error(
|
||||
'Error at '
|
||||
.concat( i, ': ' )
|
||||
.concat( msg, '\n' )
|
||||
.concat( str, '\n' )
|
||||
.concat( ' '.repeat( i ), '^' )
|
||||
);
|
||||
};
|
||||
|
||||
var read = function read( expected, ret ) {
|
||||
return expected ===
|
||||
str.slice( offset, ( offset += expected.length ) )
|
||||
? ret
|
||||
: kick(
|
||||
"Expected '".concat( expected, "'" ),
|
||||
offset - expected.length
|
||||
);
|
||||
};
|
||||
|
||||
function readMatch( regex, msg ) {
|
||||
var terminator =
|
||||
arguments.length > 2 && arguments[ 2 ] !== undefined
|
||||
? arguments[ 2 ]
|
||||
: ';';
|
||||
read( ':' );
|
||||
var match = regex.exec( str.slice( offset ) );
|
||||
if ( ! match )
|
||||
kick(
|
||||
'Exected '
|
||||
.concat( msg, ", but got '" )
|
||||
.concat(
|
||||
str
|
||||
.slice( offset )
|
||||
.match( /^[:;{}]|[^:;{}]*/ )[ 0 ],
|
||||
"'"
|
||||
)
|
||||
);
|
||||
offset += match[ 0 ].length;
|
||||
return read( terminator, match[ 0 ] );
|
||||
}
|
||||
|
||||
function readUtf8chars( numUtf8Bytes ) {
|
||||
var terminator =
|
||||
arguments.length > 1 && arguments[ 1 ] !== undefined
|
||||
? arguments[ 1 ]
|
||||
: '';
|
||||
var i = offset;
|
||||
|
||||
while ( numUtf8Bytes > 0 ) {
|
||||
var code = str.charCodeAt( offset++ );
|
||||
numUtf8Bytes -=
|
||||
code < 0x80
|
||||
? 1
|
||||
: code < 0x800 || code >> 11 === 0x1b
|
||||
? 2
|
||||
: 3;
|
||||
}
|
||||
|
||||
return numUtf8Bytes
|
||||
? kick( 'Invalid string length', i - 2 )
|
||||
: read( terminator, str.slice( i, offset ) );
|
||||
}
|
||||
|
||||
var create = function create( className ) {
|
||||
return ! className
|
||||
? {}
|
||||
: allowedClasses[ className ]
|
||||
? Object.create( allowedClasses[ className ].prototype )
|
||||
: new ( _defineProperty( {}, className, function () {} )[
|
||||
className
|
||||
] )();
|
||||
}; // Create a mock class for this name
|
||||
|
||||
var readBoolean = function readBoolean() {
|
||||
return readMatch( /^[01]/, "a '0' or '1'", ';' );
|
||||
};
|
||||
|
||||
var readInt = function readInt() {
|
||||
return +readMatch( /^-?\d+/, 'an integer', ';' );
|
||||
};
|
||||
|
||||
var readUInt = function readUInt( terminator ) {
|
||||
return +readMatch( /^\d+/, 'an unsigned integer', terminator );
|
||||
};
|
||||
|
||||
var readString = function readString() {
|
||||
var terminator =
|
||||
arguments.length > 0 && arguments[ 0 ] !== undefined
|
||||
? arguments[ 0 ]
|
||||
: '';
|
||||
return readUtf8chars( readUInt( ':"' ), '"' + terminator );
|
||||
};
|
||||
|
||||
function readDecimal() {
|
||||
var num = readMatch(
|
||||
/^-?(\d+(\.\d+)?(E[+-]\d+)?|INF)|NAN/,
|
||||
'a decimal number',
|
||||
';'
|
||||
);
|
||||
return num in specialNums ? specialNums[ num ] : +num;
|
||||
}
|
||||
|
||||
function readKey() {
|
||||
var typ = str[ offset++ ];
|
||||
return typ === 's'
|
||||
? readString( ';' )
|
||||
: typ === 'i'
|
||||
? readUInt( ';' )
|
||||
: kick(
|
||||
"Expected 's' or 'i' as type for a key, but got ${str[offset-1]}",
|
||||
offset - 1
|
||||
);
|
||||
}
|
||||
|
||||
function readObject( obj ) {
|
||||
for ( var i = 0, length = readUInt( ':{' ); i < length; i++ ) {
|
||||
obj[ readKey() ] = readValue();
|
||||
}
|
||||
|
||||
return read( '}', obj );
|
||||
}
|
||||
|
||||
function readArray() {
|
||||
var obj = readObject( {} );
|
||||
return Object.keys( obj ).some( function ( key, i ) {
|
||||
return key != i;
|
||||
} )
|
||||
? obj
|
||||
: Object.values( obj );
|
||||
}
|
||||
|
||||
function readCustomObject( obj ) {
|
||||
if ( typeof obj.unserialize !== 'function' )
|
||||
kick(
|
||||
'Instance of '.concat(
|
||||
obj.constructor.name,
|
||||
' does not have an "unserialize" method'
|
||||
)
|
||||
);
|
||||
obj.unserialize( readUtf8chars( readUInt( ':{' ) ) );
|
||||
return read( '}', obj );
|
||||
}
|
||||
|
||||
function readValue() {
|
||||
var typ = str[ offset++ ].toLowerCase();
|
||||
var ref = values.push( null ) - 1;
|
||||
var val =
|
||||
typ === 'n'
|
||||
? read( ';', null )
|
||||
: typ === 's'
|
||||
? readString( ';' )
|
||||
: typ === 'b'
|
||||
? readBoolean()
|
||||
: typ === 'i'
|
||||
? readInt()
|
||||
: typ === 'd'
|
||||
? readDecimal()
|
||||
: typ === 'a'
|
||||
? readArray() // Associative array
|
||||
: typ === 'o'
|
||||
? readObject( create( readString() ) ) // Object
|
||||
: typ === 'c'
|
||||
? readCustomObject( create( readString() ) ) // Custom serialized object
|
||||
: typ === 'r'
|
||||
? values[ readInt() ] // Backreference
|
||||
: kick( 'Unexpected type '.concat( typ ), offset - 1 );
|
||||
if ( typ !== 'r' ) values[ ref ] = val;
|
||||
return val;
|
||||
}
|
||||
|
||||
var val = readValue();
|
||||
if ( offset !== str.length ) kick( 'Unexpected trailing character' );
|
||||
return val;
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,988 @@
|
||||
/**
|
||||
* History.js
|
||||
* https://github.com/browserstate/history.js
|
||||
*
|
||||
* Copyright © 2014+ Bevry Pty Ltd us@bevry.me (http://bevry.me)
|
||||
* Copyright © 2011-2013 Benjamin Lupton b@lupton.cc (http://balupton.com)
|
||||
* Released under the BSD License
|
||||
* https://github.com/browserstate/history.js/blob/master/LICENSE.md
|
||||
*/
|
||||
( function ( e, t ) {
|
||||
'use strict';
|
||||
var n = ( e.History = e.History || {} ),
|
||||
r = e.jQuery;
|
||||
if ( typeof n.Adapter != 'undefined' )
|
||||
throw new Error( 'History.js Adapter has already been loaded...' );
|
||||
( n.Adapter = {
|
||||
bind: function ( e, t, n ) {
|
||||
r( e ).bind( t, n );
|
||||
},
|
||||
trigger: function ( e, t, n ) {
|
||||
r( e ).trigger( t, n );
|
||||
},
|
||||
extractEventData: function ( e, n, r ) {
|
||||
var i =
|
||||
( n && n.originalEvent && n.originalEvent[ e ] ) ||
|
||||
( r && r[ e ] ) ||
|
||||
t;
|
||||
return i;
|
||||
},
|
||||
onDomLoad: function ( e ) {
|
||||
r( e );
|
||||
},
|
||||
} ),
|
||||
typeof n.init != 'undefined' && n.init();
|
||||
} )( window ),
|
||||
( function ( e, t ) {
|
||||
'use strict';
|
||||
var n = e.console || t,
|
||||
r = e.document,
|
||||
i = e.navigator,
|
||||
s = ! 1,
|
||||
o = e.setTimeout,
|
||||
u = e.clearTimeout,
|
||||
a = e.setInterval,
|
||||
f = e.clearInterval,
|
||||
l = e.JSON,
|
||||
c = e.alert,
|
||||
h = ( e.History = e.History || {} ),
|
||||
p = e.history;
|
||||
try {
|
||||
( s = e.sessionStorage ),
|
||||
s.setItem( 'TEST', '1' ),
|
||||
s.removeItem( 'TEST' );
|
||||
} catch ( d ) {
|
||||
s = ! 1;
|
||||
}
|
||||
( l.stringify = l.stringify || l.encode ),
|
||||
( l.parse = l.parse || l.decode );
|
||||
if ( typeof h.init != 'undefined' )
|
||||
throw new Error( 'History.js Core has already been loaded...' );
|
||||
( h.init = function ( e ) {
|
||||
return typeof h.Adapter == 'undefined'
|
||||
? ! 1
|
||||
: ( typeof h.initCore != 'undefined' && h.initCore(),
|
||||
typeof h.initHtml4 != 'undefined' && h.initHtml4(),
|
||||
! 0 );
|
||||
} ),
|
||||
( h.initCore = function ( d ) {
|
||||
if ( typeof h.initCore.initialized != 'undefined' ) return ! 1;
|
||||
( h.initCore.initialized = ! 0 ),
|
||||
( h.options = h.options || {} ),
|
||||
( h.options.hashChangeInterval =
|
||||
h.options.hashChangeInterval || 100 ),
|
||||
( h.options.safariPollInterval =
|
||||
h.options.safariPollInterval || 500 ),
|
||||
( h.options.doubleCheckInterval =
|
||||
h.options.doubleCheckInterval || 500 ),
|
||||
( h.options.disableSuid = h.options.disableSuid || ! 1 ),
|
||||
( h.options.storeInterval =
|
||||
h.options.storeInterval || 1e3 ),
|
||||
( h.options.busyDelay = h.options.busyDelay || 250 ),
|
||||
( h.options.debug = h.options.debug || ! 1 ),
|
||||
( h.options.initialTitle =
|
||||
h.options.initialTitle || r.title ),
|
||||
( h.options.html4Mode = h.options.html4Mode || ! 1 ),
|
||||
( h.options.delayInit = h.options.delayInit || ! 1 ),
|
||||
( h.intervalList = [] ),
|
||||
( h.clearAllIntervals = function () {
|
||||
var e,
|
||||
t = h.intervalList;
|
||||
if ( typeof t != 'undefined' && t !== null ) {
|
||||
for ( e = 0; e < t.length; e++ ) f( t[ e ] );
|
||||
h.intervalList = null;
|
||||
}
|
||||
} ),
|
||||
( h.debug = function () {
|
||||
( h.options.debug || ! 1 ) &&
|
||||
h.log.apply( h, arguments );
|
||||
} ),
|
||||
( h.log = function () {
|
||||
var e =
|
||||
typeof n != 'undefined' &&
|
||||
typeof n.log != 'undefined' &&
|
||||
typeof n.log.apply != 'undefined',
|
||||
t = r.getElementById( 'log' ),
|
||||
i,
|
||||
s,
|
||||
o,
|
||||
u,
|
||||
a;
|
||||
e
|
||||
? ( ( u = Array.prototype.slice.call( arguments ) ),
|
||||
( i = u.shift() ),
|
||||
typeof n.debug != 'undefined'
|
||||
? n.debug.apply( n, [ i, u ] )
|
||||
: n.log.apply( n, [ i, u ] ) )
|
||||
: ( i = '\n' + arguments[ 0 ] + '\n' );
|
||||
for ( s = 1, o = arguments.length; s < o; ++s ) {
|
||||
a = arguments[ s ];
|
||||
if (
|
||||
typeof a == 'object' &&
|
||||
typeof l != 'undefined'
|
||||
)
|
||||
try {
|
||||
a = l.stringify( a );
|
||||
} catch ( f ) {}
|
||||
i += '\n' + a + '\n';
|
||||
}
|
||||
return (
|
||||
t
|
||||
? ( ( t.value += i + '\n-----\n' ),
|
||||
( t.scrollTop =
|
||||
t.scrollHeight - t.clientHeight ) )
|
||||
: e || c( i ),
|
||||
! 0
|
||||
);
|
||||
} ),
|
||||
( h.getInternetExplorerMajorVersion = function () {
|
||||
var e = ( h.getInternetExplorerMajorVersion.cached =
|
||||
typeof h.getInternetExplorerMajorVersion.cached !=
|
||||
'undefined'
|
||||
? h.getInternetExplorerMajorVersion.cached
|
||||
: ( function () {
|
||||
var e = 3,
|
||||
t = r.createElement( 'div' ),
|
||||
n = t.getElementsByTagName( 'i' );
|
||||
while (
|
||||
( t.innerHTML =
|
||||
'<!--[if gt IE ' +
|
||||
++e +
|
||||
']><i></i><![endif]-->' ) &&
|
||||
n[ 0 ]
|
||||
);
|
||||
return e > 4 ? e : ! 1;
|
||||
} )() );
|
||||
return e;
|
||||
} ),
|
||||
( h.isInternetExplorer = function () {
|
||||
var e = ( h.isInternetExplorer.cached =
|
||||
typeof h.isInternetExplorer.cached != 'undefined'
|
||||
? h.isInternetExplorer.cached
|
||||
: Boolean(
|
||||
h.getInternetExplorerMajorVersion()
|
||||
) );
|
||||
return e;
|
||||
} ),
|
||||
h.options.html4Mode
|
||||
? ( h.emulated = { pushState: ! 0, hashChange: ! 0 } )
|
||||
: ( h.emulated = {
|
||||
pushState: ! Boolean(
|
||||
e.history &&
|
||||
e.history.pushState &&
|
||||
e.history.replaceState &&
|
||||
! / Mobile\/([1-7][a-z]|(8([abcde]|f(1[0-8]))))/i.test(
|
||||
i.userAgent
|
||||
) &&
|
||||
! /AppleWebKit\/5([0-2]|3[0-2])/i.test(
|
||||
i.userAgent
|
||||
)
|
||||
),
|
||||
hashChange: Boolean(
|
||||
! (
|
||||
'onhashchange' in e ||
|
||||
'onhashchange' in r
|
||||
) ||
|
||||
( h.isInternetExplorer() &&
|
||||
h.getInternetExplorerMajorVersion() <
|
||||
8 )
|
||||
),
|
||||
} ),
|
||||
( h.enabled = ! h.emulated.pushState ),
|
||||
( h.bugs = {
|
||||
setHash: Boolean(
|
||||
! h.emulated.pushState &&
|
||||
i.vendor === 'Apple Computer, Inc.' &&
|
||||
/AppleWebKit\/5([0-2]|3[0-3])/.test(
|
||||
i.userAgent
|
||||
)
|
||||
),
|
||||
safariPoll: Boolean(
|
||||
! h.emulated.pushState &&
|
||||
i.vendor === 'Apple Computer, Inc.' &&
|
||||
/AppleWebKit\/5([0-2]|3[0-3])/.test(
|
||||
i.userAgent
|
||||
)
|
||||
),
|
||||
ieDoubleCheck: Boolean(
|
||||
h.isInternetExplorer() &&
|
||||
h.getInternetExplorerMajorVersion() < 8
|
||||
),
|
||||
hashEscape: Boolean(
|
||||
h.isInternetExplorer() &&
|
||||
h.getInternetExplorerMajorVersion() < 7
|
||||
),
|
||||
} ),
|
||||
( h.isEmptyObject = function ( e ) {
|
||||
for ( var t in e )
|
||||
if ( e.hasOwnProperty( t ) ) return ! 1;
|
||||
return ! 0;
|
||||
} ),
|
||||
( h.cloneObject = function ( e ) {
|
||||
var t, n;
|
||||
return (
|
||||
e
|
||||
? ( ( t = l.stringify( e ) ),
|
||||
( n = l.parse( t ) ) )
|
||||
: ( n = {} ),
|
||||
n
|
||||
);
|
||||
} ),
|
||||
( h.getRootUrl = function () {
|
||||
var e =
|
||||
r.location.protocol +
|
||||
'//' +
|
||||
( r.location.hostname || r.location.host );
|
||||
if ( r.location.port || ! 1 )
|
||||
e += ':' + r.location.port;
|
||||
return ( e += '/' ), e;
|
||||
} ),
|
||||
( h.getBaseHref = function () {
|
||||
var e = r.getElementsByTagName( 'base' ),
|
||||
t = null,
|
||||
n = '';
|
||||
return (
|
||||
e.length === 1 &&
|
||||
( ( t = e[ 0 ] ),
|
||||
( n = t.href.replace( /[^\/]+$/, '' ) ) ),
|
||||
( n = n.replace( /\/+$/, '' ) ),
|
||||
n && ( n += '/' ),
|
||||
n
|
||||
);
|
||||
} ),
|
||||
( h.getBaseUrl = function () {
|
||||
var e =
|
||||
h.getBaseHref() ||
|
||||
h.getBasePageUrl() ||
|
||||
h.getRootUrl();
|
||||
return e;
|
||||
} ),
|
||||
( h.getPageUrl = function () {
|
||||
var e = h.getState( ! 1, ! 1 ),
|
||||
t = ( e || {} ).url || h.getLocationHref(),
|
||||
n;
|
||||
return (
|
||||
( n = t
|
||||
.replace( /\/+$/, '' )
|
||||
.replace( /[^\/]+$/, function ( e, t, n ) {
|
||||
return /\./.test( e ) ? e : e + '/';
|
||||
} ) ),
|
||||
n
|
||||
);
|
||||
} ),
|
||||
( h.getBasePageUrl = function () {
|
||||
var e =
|
||||
h
|
||||
.getLocationHref()
|
||||
.replace( /[#\?].*/, '' )
|
||||
.replace( /[^\/]+$/, function ( e, t, n ) {
|
||||
return /[^\/]$/.test( e ) ? '' : e;
|
||||
} )
|
||||
.replace( /\/+$/, '' ) + '/';
|
||||
return e;
|
||||
} ),
|
||||
( h.getFullUrl = function ( e, t ) {
|
||||
var n = e,
|
||||
r = e.substring( 0, 1 );
|
||||
return (
|
||||
( t = typeof t == 'undefined' ? ! 0 : t ),
|
||||
/[a-z]+\:\/\//.test( e ) ||
|
||||
( r === '/'
|
||||
? ( n =
|
||||
h.getRootUrl() +
|
||||
e.replace( /^\/+/, '' ) )
|
||||
: r === '#'
|
||||
? ( n =
|
||||
h
|
||||
.getPageUrl()
|
||||
.replace( /#.*/, '' ) + e )
|
||||
: r === '?'
|
||||
? ( n =
|
||||
h
|
||||
.getPageUrl()
|
||||
.replace( /[\?#].*/, '' ) + e )
|
||||
: t
|
||||
? ( n =
|
||||
h.getBaseUrl() +
|
||||
e.replace( /^(\.\/)+/, '' ) )
|
||||
: ( n =
|
||||
h.getBasePageUrl() +
|
||||
e.replace( /^(\.\/)+/, '' ) ) ),
|
||||
n.replace( /\#$/, '' )
|
||||
);
|
||||
} ),
|
||||
( h.getShortUrl = function ( e ) {
|
||||
var t = e,
|
||||
n = h.getBaseUrl(),
|
||||
r = h.getRootUrl();
|
||||
return (
|
||||
h.emulated.pushState && ( t = t.replace( n, '' ) ),
|
||||
( t = t.replace( r, '/' ) ),
|
||||
h.isTraditionalAnchor( t ) && ( t = './' + t ),
|
||||
( t = t
|
||||
.replace( /^(\.\/)+/g, './' )
|
||||
.replace( /\#$/, '' ) ),
|
||||
t
|
||||
);
|
||||
} ),
|
||||
( h.getLocationHref = function ( e ) {
|
||||
return (
|
||||
( e = e || r ),
|
||||
e.URL === e.location.href
|
||||
? e.location.href
|
||||
: e.location.href ===
|
||||
decodeURIComponent( e.URL )
|
||||
? e.URL
|
||||
: e.location.hash &&
|
||||
decodeURIComponent(
|
||||
e.location.href.replace( /^[^#]+/, '' )
|
||||
) === e.location.hash
|
||||
? e.location.href
|
||||
: e.URL.indexOf( '#' ) == -1 &&
|
||||
e.location.href.indexOf( '#' ) != -1
|
||||
? e.location.href
|
||||
: e.URL || e.location.href
|
||||
);
|
||||
} ),
|
||||
( h.store = {} ),
|
||||
( h.idToState = h.idToState || {} ),
|
||||
( h.stateToId = h.stateToId || {} ),
|
||||
( h.urlToId = h.urlToId || {} ),
|
||||
( h.storedStates = h.storedStates || [] ),
|
||||
( h.savedStates = h.savedStates || [] ),
|
||||
( h.normalizeStore = function () {
|
||||
( h.store.idToState = h.store.idToState || {} ),
|
||||
( h.store.urlToId = h.store.urlToId || {} ),
|
||||
( h.store.stateToId = h.store.stateToId || {} );
|
||||
} ),
|
||||
( h.getState = function ( e, t ) {
|
||||
typeof e == 'undefined' && ( e = ! 0 ),
|
||||
typeof t == 'undefined' && ( t = ! 0 );
|
||||
var n = h.getLastSavedState();
|
||||
return (
|
||||
! n && t && ( n = h.createStateObject() ),
|
||||
e &&
|
||||
( ( n = h.cloneObject( n ) ),
|
||||
( n.url = n.cleanUrl || n.url ) ),
|
||||
n
|
||||
);
|
||||
} ),
|
||||
( h.getIdByState = function ( e ) {
|
||||
var t = h.extractId( e.url ),
|
||||
n;
|
||||
if ( ! t ) {
|
||||
n = h.getStateString( e );
|
||||
if ( typeof h.stateToId[ n ] != 'undefined' )
|
||||
t = h.stateToId[ n ];
|
||||
else if (
|
||||
typeof h.store.stateToId[ n ] != 'undefined'
|
||||
)
|
||||
t = h.store.stateToId[ n ];
|
||||
else {
|
||||
for (;;) {
|
||||
t =
|
||||
new Date().getTime() +
|
||||
String( Math.random() ).replace(
|
||||
/\D/g,
|
||||
''
|
||||
);
|
||||
if (
|
||||
typeof h.idToState[ t ] ==
|
||||
'undefined' &&
|
||||
typeof h.store.idToState[ t ] ==
|
||||
'undefined'
|
||||
)
|
||||
break;
|
||||
}
|
||||
( h.stateToId[ n ] = t ),
|
||||
( h.idToState[ t ] = e );
|
||||
}
|
||||
}
|
||||
return t;
|
||||
} ),
|
||||
( h.normalizeState = function ( e ) {
|
||||
var t, n;
|
||||
if ( ! e || typeof e != 'object' ) e = {};
|
||||
if ( typeof e.normalized != 'undefined' ) return e;
|
||||
if ( ! e.data || typeof e.data != 'object' )
|
||||
e.data = {};
|
||||
return (
|
||||
( t = {} ),
|
||||
( t.normalized = ! 0 ),
|
||||
( t.title = e.title || '' ),
|
||||
( t.url = h.getFullUrl(
|
||||
e.url ? e.url : h.getLocationHref()
|
||||
) ),
|
||||
( t.hash = h.getShortUrl( t.url ) ),
|
||||
( t.data = h.cloneObject( e.data ) ),
|
||||
( t.id = h.getIdByState( t ) ),
|
||||
( t.cleanUrl = t.url.replace(
|
||||
/\??\&_suid.*/,
|
||||
''
|
||||
) ),
|
||||
( t.url = t.cleanUrl ),
|
||||
( n = ! h.isEmptyObject( t.data ) ),
|
||||
( t.title || n ) &&
|
||||
h.options.disableSuid !== ! 0 &&
|
||||
( ( t.hash = h
|
||||
.getShortUrl( t.url )
|
||||
.replace( /\??\&_suid.*/, '' ) ),
|
||||
/\?/.test( t.hash ) || ( t.hash += '?' ),
|
||||
( t.hash += '&_suid=' + t.id ) ),
|
||||
( t.hashedUrl = h.getFullUrl( t.hash ) ),
|
||||
( h.emulated.pushState || h.bugs.safariPoll ) &&
|
||||
h.hasUrlDuplicate( t ) &&
|
||||
( t.url = t.hashedUrl ),
|
||||
t
|
||||
);
|
||||
} ),
|
||||
( h.createStateObject = function ( e, t, n ) {
|
||||
var r = { data: e, title: t, url: n };
|
||||
return ( r = h.normalizeState( r ) ), r;
|
||||
} ),
|
||||
( h.getStateById = function ( e ) {
|
||||
e = String( e );
|
||||
var n = h.idToState[ e ] || h.store.idToState[ e ] || t;
|
||||
return n;
|
||||
} ),
|
||||
( h.getStateString = function ( e ) {
|
||||
var t, n, r;
|
||||
return (
|
||||
( t = h.normalizeState( e ) ),
|
||||
( n = {
|
||||
data: t.data,
|
||||
title: e.title,
|
||||
url: e.url,
|
||||
} ),
|
||||
( r = l.stringify( n ) ),
|
||||
r
|
||||
);
|
||||
} ),
|
||||
( h.getStateId = function ( e ) {
|
||||
var t, n;
|
||||
return ( t = h.normalizeState( e ) ), ( n = t.id ), n;
|
||||
} ),
|
||||
( h.getHashByState = function ( e ) {
|
||||
var t, n;
|
||||
return ( t = h.normalizeState( e ) ), ( n = t.hash ), n;
|
||||
} ),
|
||||
( h.extractId = function ( e ) {
|
||||
var t, n, r, i;
|
||||
return (
|
||||
e.indexOf( '#' ) != -1
|
||||
? ( i = e.split( '#' )[ 0 ] )
|
||||
: ( i = e ),
|
||||
( n = /(.*)\&_suid=([0-9]+)$/.exec( i ) ),
|
||||
( r = n ? n[ 1 ] || e : e ),
|
||||
( t = n ? String( n[ 2 ] || '' ) : '' ),
|
||||
t || ! 1
|
||||
);
|
||||
} ),
|
||||
( h.isTraditionalAnchor = function ( e ) {
|
||||
var t = ! /[\/\?\.]/.test( e );
|
||||
return t;
|
||||
} ),
|
||||
( h.extractState = function ( e, t ) {
|
||||
var n = null,
|
||||
r,
|
||||
i;
|
||||
return (
|
||||
( t = t || ! 1 ),
|
||||
( r = h.extractId( e ) ),
|
||||
r && ( n = h.getStateById( r ) ),
|
||||
n ||
|
||||
( ( i = h.getFullUrl( e ) ),
|
||||
( r = h.getIdByUrl( i ) || ! 1 ),
|
||||
r && ( n = h.getStateById( r ) ),
|
||||
! n &&
|
||||
t &&
|
||||
! h.isTraditionalAnchor( e ) &&
|
||||
( n = h.createStateObject(
|
||||
null,
|
||||
null,
|
||||
i
|
||||
) ) ),
|
||||
n
|
||||
);
|
||||
} ),
|
||||
( h.getIdByUrl = function ( e ) {
|
||||
var n = h.urlToId[ e ] || h.store.urlToId[ e ] || t;
|
||||
return n;
|
||||
} ),
|
||||
( h.getLastSavedState = function () {
|
||||
return h.savedStates[ h.savedStates.length - 1 ] || t;
|
||||
} ),
|
||||
( h.getLastStoredState = function () {
|
||||
return h.storedStates[ h.storedStates.length - 1 ] || t;
|
||||
} ),
|
||||
( h.hasUrlDuplicate = function ( e ) {
|
||||
var t = ! 1,
|
||||
n;
|
||||
return (
|
||||
( n = h.extractState( e.url ) ),
|
||||
( t = n && n.id !== e.id ),
|
||||
t
|
||||
);
|
||||
} ),
|
||||
( h.storeState = function ( e ) {
|
||||
return (
|
||||
( h.urlToId[ e.url ] = e.id ),
|
||||
h.storedStates.push( h.cloneObject( e ) ),
|
||||
e
|
||||
);
|
||||
} ),
|
||||
( h.isLastSavedState = function ( e ) {
|
||||
var t = ! 1,
|
||||
n,
|
||||
r,
|
||||
i;
|
||||
return (
|
||||
h.savedStates.length &&
|
||||
( ( n = e.id ),
|
||||
( r = h.getLastSavedState() ),
|
||||
( i = r.id ),
|
||||
( t = n === i ) ),
|
||||
t
|
||||
);
|
||||
} ),
|
||||
( h.saveState = function ( e ) {
|
||||
return h.isLastSavedState( e )
|
||||
? ! 1
|
||||
: ( h.savedStates.push( h.cloneObject( e ) ), ! 0 );
|
||||
} ),
|
||||
( h.getStateByIndex = function ( e ) {
|
||||
var t = null;
|
||||
return (
|
||||
typeof e == 'undefined'
|
||||
? ( t =
|
||||
h.savedStates[
|
||||
h.savedStates.length - 1
|
||||
] )
|
||||
: e < 0
|
||||
? ( t =
|
||||
h.savedStates[
|
||||
h.savedStates.length + e
|
||||
] )
|
||||
: ( t = h.savedStates[ e ] ),
|
||||
t
|
||||
);
|
||||
} ),
|
||||
( h.getCurrentIndex = function () {
|
||||
var e = null;
|
||||
return (
|
||||
h.savedStates.length < 1
|
||||
? ( e = 0 )
|
||||
: ( e = h.savedStates.length - 1 ),
|
||||
e
|
||||
);
|
||||
} ),
|
||||
( h.getHash = function ( e ) {
|
||||
var t = h.getLocationHref( e ),
|
||||
n;
|
||||
return ( n = h.getHashByUrl( t ) ), n;
|
||||
} ),
|
||||
( h.unescapeHash = function ( e ) {
|
||||
var t = h.normalizeHash( e );
|
||||
return ( t = decodeURIComponent( t ) ), t;
|
||||
} ),
|
||||
( h.normalizeHash = function ( e ) {
|
||||
var t = e.replace( /[^#]*#/, '' ).replace( /#.*/, '' );
|
||||
return t;
|
||||
} ),
|
||||
( h.setHash = function ( e, t ) {
|
||||
var n, i;
|
||||
return t !== ! 1 && h.busy()
|
||||
? ( h.pushQueue( {
|
||||
scope: h,
|
||||
callback: h.setHash,
|
||||
args: arguments,
|
||||
queue: t,
|
||||
} ),
|
||||
! 1 )
|
||||
: ( h.busy( ! 0 ),
|
||||
( n = h.extractState( e, ! 0 ) ),
|
||||
n && ! h.emulated.pushState
|
||||
? h.pushState( n.data, n.title, n.url, ! 1 )
|
||||
: h.getHash() !== e &&
|
||||
( h.bugs.setHash
|
||||
? ( ( i = h.getPageUrl() ),
|
||||
h.pushState(
|
||||
null,
|
||||
null,
|
||||
i + '#' + e,
|
||||
! 1
|
||||
) )
|
||||
: ( r.location.hash = e ) ),
|
||||
h );
|
||||
} ),
|
||||
( h.escapeHash = function ( t ) {
|
||||
var n = h.normalizeHash( t );
|
||||
return (
|
||||
( n = e.encodeURIComponent( n ) ),
|
||||
h.bugs.hashEscape ||
|
||||
( n = n
|
||||
.replace( /\%21/g, '!' )
|
||||
.replace( /\%26/g, '&' )
|
||||
.replace( /\%3D/g, '=' )
|
||||
.replace( /\%3F/g, '?' ) ),
|
||||
n
|
||||
);
|
||||
} ),
|
||||
( h.getHashByUrl = function ( e ) {
|
||||
var t = String( e ).replace(
|
||||
/([^#]*)#?([^#]*)#?(.*)/,
|
||||
'$2'
|
||||
);
|
||||
return ( t = h.unescapeHash( t ) ), t;
|
||||
} ),
|
||||
( h.setTitle = function ( e ) {
|
||||
var t = e.title,
|
||||
n;
|
||||
t ||
|
||||
( ( n = h.getStateByIndex( 0 ) ),
|
||||
n &&
|
||||
n.url === e.url &&
|
||||
( t = n.title || h.options.initialTitle ) );
|
||||
try {
|
||||
r.getElementsByTagName( 'title' )[ 0 ].innerHTML = t
|
||||
.replace( '<', '<' )
|
||||
.replace( '>', '>' )
|
||||
.replace( ' & ', ' & ' );
|
||||
} catch ( i ) {}
|
||||
return ( r.title = t ), h;
|
||||
} ),
|
||||
( h.queues = [] ),
|
||||
( h.busy = function ( e ) {
|
||||
typeof e != 'undefined'
|
||||
? ( h.busy.flag = e )
|
||||
: typeof h.busy.flag == 'undefined' &&
|
||||
( h.busy.flag = ! 1 );
|
||||
if ( ! h.busy.flag ) {
|
||||
u( h.busy.timeout );
|
||||
var t = function () {
|
||||
var e, n, r;
|
||||
if ( h.busy.flag ) return;
|
||||
for ( e = h.queues.length - 1; e >= 0; --e ) {
|
||||
n = h.queues[ e ];
|
||||
if ( n.length === 0 ) continue;
|
||||
( r = n.shift() ),
|
||||
h.fireQueueItem( r ),
|
||||
( h.busy.timeout = o(
|
||||
t,
|
||||
h.options.busyDelay
|
||||
) );
|
||||
}
|
||||
};
|
||||
h.busy.timeout = o( t, h.options.busyDelay );
|
||||
}
|
||||
return h.busy.flag;
|
||||
} ),
|
||||
( h.busy.flag = ! 1 ),
|
||||
( h.fireQueueItem = function ( e ) {
|
||||
return e.callback.apply( e.scope || h, e.args || [] );
|
||||
} ),
|
||||
( h.pushQueue = function ( e ) {
|
||||
return (
|
||||
( h.queues[ e.queue || 0 ] =
|
||||
h.queues[ e.queue || 0 ] || [] ),
|
||||
h.queues[ e.queue || 0 ].push( e ),
|
||||
h
|
||||
);
|
||||
} ),
|
||||
( h.queue = function ( e, t ) {
|
||||
return (
|
||||
typeof e == 'function' && ( e = { callback: e } ),
|
||||
typeof t != 'undefined' && ( e.queue = t ),
|
||||
h.busy() ? h.pushQueue( e ) : h.fireQueueItem( e ),
|
||||
h
|
||||
);
|
||||
} ),
|
||||
( h.clearQueue = function () {
|
||||
return ( h.busy.flag = ! 1 ), ( h.queues = [] ), h;
|
||||
} ),
|
||||
( h.stateChanged = ! 1 ),
|
||||
( h.doubleChecker = ! 1 ),
|
||||
( h.doubleCheckComplete = function () {
|
||||
return (
|
||||
( h.stateChanged = ! 0 ), h.doubleCheckClear(), h
|
||||
);
|
||||
} ),
|
||||
( h.doubleCheckClear = function () {
|
||||
return (
|
||||
h.doubleChecker &&
|
||||
( u( h.doubleChecker ),
|
||||
( h.doubleChecker = ! 1 ) ),
|
||||
h
|
||||
);
|
||||
} ),
|
||||
( h.doubleCheck = function ( e ) {
|
||||
return (
|
||||
( h.stateChanged = ! 1 ),
|
||||
h.doubleCheckClear(),
|
||||
h.bugs.ieDoubleCheck &&
|
||||
( h.doubleChecker = o( function () {
|
||||
return (
|
||||
h.doubleCheckClear(),
|
||||
h.stateChanged || e(),
|
||||
! 0
|
||||
);
|
||||
}, h.options.doubleCheckInterval ) ),
|
||||
h
|
||||
);
|
||||
} ),
|
||||
( h.safariStatePoll = function () {
|
||||
var t = h.extractState( h.getLocationHref() ),
|
||||
n;
|
||||
if ( ! h.isLastSavedState( t ) )
|
||||
return (
|
||||
( n = t ),
|
||||
n || ( n = h.createStateObject() ),
|
||||
h.Adapter.trigger( e, 'popstate' ),
|
||||
h
|
||||
);
|
||||
return;
|
||||
} ),
|
||||
( h.back = function ( e ) {
|
||||
return e !== ! 1 && h.busy()
|
||||
? ( h.pushQueue( {
|
||||
scope: h,
|
||||
callback: h.back,
|
||||
args: arguments,
|
||||
queue: e,
|
||||
} ),
|
||||
! 1 )
|
||||
: ( h.busy( ! 0 ),
|
||||
h.doubleCheck( function () {
|
||||
h.back( ! 1 );
|
||||
} ),
|
||||
p.go( -1 ),
|
||||
! 0 );
|
||||
} ),
|
||||
( h.forward = function ( e ) {
|
||||
return e !== ! 1 && h.busy()
|
||||
? ( h.pushQueue( {
|
||||
scope: h,
|
||||
callback: h.forward,
|
||||
args: arguments,
|
||||
queue: e,
|
||||
} ),
|
||||
! 1 )
|
||||
: ( h.busy( ! 0 ),
|
||||
h.doubleCheck( function () {
|
||||
h.forward( ! 1 );
|
||||
} ),
|
||||
p.go( 1 ),
|
||||
! 0 );
|
||||
} ),
|
||||
( h.go = function ( e, t ) {
|
||||
var n;
|
||||
if ( e > 0 ) for ( n = 1; n <= e; ++n ) h.forward( t );
|
||||
else {
|
||||
if ( ! ( e < 0 ) )
|
||||
throw new Error(
|
||||
'History.go: History.go requires a positive or negative integer passed.'
|
||||
);
|
||||
for ( n = -1; n >= e; --n ) h.back( t );
|
||||
}
|
||||
return h;
|
||||
} );
|
||||
if ( h.emulated.pushState ) {
|
||||
var v = function () {};
|
||||
( h.pushState = h.pushState || v ),
|
||||
( h.replaceState = h.replaceState || v );
|
||||
} else
|
||||
( h.onPopState = function ( t, n ) {
|
||||
var r = ! 1,
|
||||
i = ! 1,
|
||||
s,
|
||||
o;
|
||||
return (
|
||||
h.doubleCheckComplete(),
|
||||
( s = h.getHash() ),
|
||||
s
|
||||
? ( ( o = h.extractState(
|
||||
s || h.getLocationHref(),
|
||||
! 0
|
||||
) ),
|
||||
o
|
||||
? h.replaceState(
|
||||
o.data,
|
||||
o.title,
|
||||
o.url,
|
||||
! 1
|
||||
)
|
||||
: ( h.Adapter.trigger(
|
||||
e,
|
||||
'anchorchange'
|
||||
),
|
||||
h.busy( ! 1 ) ),
|
||||
( h.expectedStateId = ! 1 ),
|
||||
! 1 )
|
||||
: ( ( r =
|
||||
h.Adapter.extractEventData(
|
||||
'state',
|
||||
t,
|
||||
n
|
||||
) || ! 1 ),
|
||||
r
|
||||
? ( i = h.getStateById( r ) )
|
||||
: h.expectedStateId
|
||||
? ( i = h.getStateById(
|
||||
h.expectedStateId
|
||||
) )
|
||||
: ( i = h.extractState(
|
||||
h.getLocationHref()
|
||||
) ),
|
||||
i ||
|
||||
( i = h.createStateObject(
|
||||
null,
|
||||
null,
|
||||
h.getLocationHref()
|
||||
) ),
|
||||
( h.expectedStateId = ! 1 ),
|
||||
h.isLastSavedState( i )
|
||||
? ( h.busy( ! 1 ), ! 1 )
|
||||
: ( h.storeState( i ),
|
||||
h.saveState( i ),
|
||||
h.setTitle( i ),
|
||||
h.Adapter.trigger( e, 'statechange' ),
|
||||
h.busy( ! 1 ),
|
||||
! 0 ) )
|
||||
);
|
||||
} ),
|
||||
h.Adapter.bind( e, 'popstate', h.onPopState ),
|
||||
( h.pushState = function ( t, n, r, i ) {
|
||||
if ( h.getHashByUrl( r ) && h.emulated.pushState )
|
||||
throw new Error(
|
||||
'History.js does not support states with fragement-identifiers (hashes/anchors).'
|
||||
);
|
||||
if ( i !== ! 1 && h.busy() )
|
||||
return (
|
||||
h.pushQueue( {
|
||||
scope: h,
|
||||
callback: h.pushState,
|
||||
args: arguments,
|
||||
queue: i,
|
||||
} ),
|
||||
! 1
|
||||
);
|
||||
h.busy( ! 0 );
|
||||
var s = h.createStateObject( t, n, r );
|
||||
return (
|
||||
h.isLastSavedState( s )
|
||||
? h.busy( ! 1 )
|
||||
: ( h.storeState( s ),
|
||||
( h.expectedStateId = s.id ),
|
||||
p.pushState( s.id, s.title, s.url ),
|
||||
h.Adapter.trigger( e, 'popstate' ) ),
|
||||
! 0
|
||||
);
|
||||
} ),
|
||||
( h.replaceState = function ( t, n, r, i ) {
|
||||
if ( h.getHashByUrl( r ) && h.emulated.pushState )
|
||||
throw new Error(
|
||||
'History.js does not support states with fragement-identifiers (hashes/anchors).'
|
||||
);
|
||||
if ( i !== ! 1 && h.busy() )
|
||||
return (
|
||||
h.pushQueue( {
|
||||
scope: h,
|
||||
callback: h.replaceState,
|
||||
args: arguments,
|
||||
queue: i,
|
||||
} ),
|
||||
! 1
|
||||
);
|
||||
h.busy( ! 0 );
|
||||
var s = h.createStateObject( t, n, r );
|
||||
return (
|
||||
h.isLastSavedState( s )
|
||||
? h.busy( ! 1 )
|
||||
: ( h.storeState( s ),
|
||||
( h.expectedStateId = s.id ),
|
||||
p.replaceState( s.id, s.title, s.url ),
|
||||
h.Adapter.trigger( e, 'popstate' ) ),
|
||||
! 0
|
||||
);
|
||||
} );
|
||||
if ( s ) {
|
||||
try {
|
||||
h.store = l.parse( s.getItem( 'History.store' ) ) || {};
|
||||
} catch ( m ) {
|
||||
h.store = {};
|
||||
}
|
||||
h.normalizeStore();
|
||||
} else ( h.store = {} ), h.normalizeStore();
|
||||
h.Adapter.bind( e, 'unload', h.clearAllIntervals ),
|
||||
h.saveState(
|
||||
h.storeState(
|
||||
h.extractState( h.getLocationHref(), ! 0 )
|
||||
)
|
||||
),
|
||||
s &&
|
||||
( ( h.onUnload = function () {
|
||||
var e, t, n;
|
||||
try {
|
||||
e =
|
||||
l.parse( s.getItem( 'History.store' ) ) ||
|
||||
{};
|
||||
} catch ( r ) {
|
||||
e = {};
|
||||
}
|
||||
( e.idToState = e.idToState || {} ),
|
||||
( e.urlToId = e.urlToId || {} ),
|
||||
( e.stateToId = e.stateToId || {} );
|
||||
for ( t in h.idToState ) {
|
||||
if ( ! h.idToState.hasOwnProperty( t ) )
|
||||
continue;
|
||||
e.idToState[ t ] = h.idToState[ t ];
|
||||
}
|
||||
for ( t in h.urlToId ) {
|
||||
if ( ! h.urlToId.hasOwnProperty( t ) ) continue;
|
||||
e.urlToId[ t ] = h.urlToId[ t ];
|
||||
}
|
||||
for ( t in h.stateToId ) {
|
||||
if ( ! h.stateToId.hasOwnProperty( t ) )
|
||||
continue;
|
||||
e.stateToId[ t ] = h.stateToId[ t ];
|
||||
}
|
||||
( h.store = e ),
|
||||
h.normalizeStore(),
|
||||
( n = l.stringify( e ) );
|
||||
try {
|
||||
s.setItem( 'History.store', n );
|
||||
} catch ( i ) {
|
||||
if (
|
||||
i.code !== DOMException.QUOTA_EXCEEDED_ERR
|
||||
)
|
||||
throw i;
|
||||
s.length &&
|
||||
( s.removeItem( 'History.store' ),
|
||||
s.setItem( 'History.store', n ) );
|
||||
}
|
||||
} ),
|
||||
h.intervalList.push(
|
||||
a( h.onUnload, h.options.storeInterval )
|
||||
),
|
||||
h.Adapter.bind( e, 'beforeunload', h.onUnload ),
|
||||
h.Adapter.bind( e, 'unload', h.onUnload ) );
|
||||
if ( ! h.emulated.pushState ) {
|
||||
h.bugs.safariPoll &&
|
||||
h.intervalList.push(
|
||||
a( h.safariStatePoll, h.options.safariPollInterval )
|
||||
);
|
||||
if (
|
||||
i.vendor === 'Apple Computer, Inc.' ||
|
||||
( i.appCodeName || '' ) === 'Mozilla'
|
||||
)
|
||||
h.Adapter.bind( e, 'hashchange', function () {
|
||||
h.Adapter.trigger( e, 'popstate' );
|
||||
} ),
|
||||
h.getHash() &&
|
||||
h.Adapter.onDomLoad( function () {
|
||||
h.Adapter.trigger( e, 'hashchange' );
|
||||
} );
|
||||
}
|
||||
} ),
|
||||
( ! h.options || ! h.options.delayInit ) && h.init();
|
||||
} )( window );
|
||||
@@ -0,0 +1,126 @@
|
||||
( function ( $ ) {
|
||||
AstraSitesImportStatus = {
|
||||
timer: null,
|
||||
ajax_in_process: false,
|
||||
current_step: null,
|
||||
interval: $( '.astra-sites-import-screen' ).length ? 1000 : 10000,
|
||||
|
||||
/**
|
||||
* Init
|
||||
*/
|
||||
init: function () {
|
||||
this.start();
|
||||
},
|
||||
|
||||
/**
|
||||
* Start
|
||||
*/
|
||||
start: function () {
|
||||
AstraSitesImportStatus.timer = setInterval(
|
||||
AstraSitesImportStatus.check_status,
|
||||
AstraSitesImportStatus.interval
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Check Status
|
||||
*/
|
||||
check_status: function () {
|
||||
if ( false === AstraSitesImportStatus.ajax_in_process ) {
|
||||
AstraSitesImportStatus.ajax_in_process = true;
|
||||
AstraSitesImportStatus._ajax_request();
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Ajax Request
|
||||
*/
|
||||
_ajax_request: function () {
|
||||
$.ajax( {
|
||||
url: AstraSitesImportStatusVars.ajaxurl,
|
||||
type: 'POST',
|
||||
data: {
|
||||
action: 'astra_sites_check_import_status',
|
||||
_ajax_nonce: AstraSitesImportStatusVars._ajax_nonce,
|
||||
},
|
||||
} )
|
||||
.done( function ( result ) {
|
||||
AstraSitesImportStatus.ajax_in_process = false;
|
||||
|
||||
// Admin Bar UI markup.
|
||||
if (
|
||||
'complete' === result.data.response.step ||
|
||||
'fail' === result.data.response.step
|
||||
) {
|
||||
AstraSitesImportStatus.stop();
|
||||
|
||||
var response_message =
|
||||
'<span class="dashicons dashicons-no-alt"></span> Site Import Failed';
|
||||
if ( 'complete' === result.data.response.step ) {
|
||||
response_message =
|
||||
'<span class="dashicons dashicons-yes"></span>' +
|
||||
response_message;
|
||||
}
|
||||
|
||||
$( '#astra-sites-import-status-admin-bar' ).html(
|
||||
response_message
|
||||
);
|
||||
} else {
|
||||
$( '#astra-sites-import-status-admin-bar' ).html(
|
||||
'<span class="loading"></span>' +
|
||||
result.data.response.message
|
||||
);
|
||||
}
|
||||
|
||||
// Admin page UI markup.
|
||||
var currentStep = $(
|
||||
'.import-step[data-step="' +
|
||||
result.data.response.step +
|
||||
'"]'
|
||||
);
|
||||
if ( currentStep.length ) {
|
||||
if (
|
||||
'complete' === result.data.response.step ||
|
||||
'fail' === result.data.response.step
|
||||
) {
|
||||
$( '.import-step' )
|
||||
.removeClass( 'processing' )
|
||||
.addClass( 'success' );
|
||||
} else if (
|
||||
AstraSitesImportStatus.current_step !==
|
||||
result.data.response.step
|
||||
) {
|
||||
AstraSitesImportStatus.current_step =
|
||||
result.data.response.step;
|
||||
|
||||
currentStep
|
||||
.prevAll()
|
||||
.removeClass( 'processing' )
|
||||
.addClass( 'success' );
|
||||
currentStep.addClass( 'processing' );
|
||||
}
|
||||
}
|
||||
} )
|
||||
.fail( function ( err ) {
|
||||
AstraSitesImportStatus.ajax_in_process = false;
|
||||
|
||||
// Stop.
|
||||
AstraSitesImportStatus.stop();
|
||||
} );
|
||||
},
|
||||
|
||||
/**
|
||||
* Step
|
||||
*/
|
||||
stop: function () {
|
||||
clearInterval( AstraSitesImportStatus.timer );
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize AstraSitesImportStatus
|
||||
*/
|
||||
$( function () {
|
||||
AstraSitesImportStatus.init();
|
||||
} );
|
||||
} )( jQuery );
|
||||
Reference in New Issue
Block a user