Range les fichiers statiques K-Fêt

Les fichiers JS et CSS externes sont dans `static/kfet/vendor`, minifiés ; on bump la version de `reconnecting-websocket`.
This commit is contained in:
Ludovic Stephan 2019-02-12 18:30:44 +01:00 committed by Ludovic Stephan
parent 435bb392ea
commit f8e954ff79
17 changed files with 552 additions and 373 deletions

View file

@ -37,8 +37,8 @@ class DateTimeWidget(forms.DateTimeInput):
self.attrs["format"] = "%Y-%m-%d %H:%M" self.attrs["format"] = "%Y-%m-%d %H:%M"
class Media: class Media:
css = {"all": ("kfet/css/bootstrap-datetimepicker.min.css",)} css = {"all": ("kfet/vendor/bootstrap/bootstrap-datetimepicker.min.css",)}
js = ("kfet/js/bootstrap-datetimepicker.min.js",) js = ("kfet/vendor/bootstrap/bootstrap-datetimepicker.min.js",)
# ----- # -----

View file

@ -1,365 +0,0 @@
// MIT License:
//
// Copyright (c) 2010-2012, Joe Walnes
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
/**
* This behaves like a WebSocket in every way, except if it fails to connect,
* or it gets disconnected, it will repeatedly poll until it successfully connects
* again.
*
* It is API compatible, so when you have:
* ws = new WebSocket('ws://....');
* you can replace with:
* ws = new ReconnectingWebSocket('ws://....');
*
* The event stream will typically look like:
* onconnecting
* onopen
* onmessage
* onmessage
* onclose // lost connection
* onconnecting
* onopen // sometime later...
* onmessage
* onmessage
* etc...
*
* It is API compatible with the standard WebSocket API, apart from the following members:
*
* - `bufferedAmount`
* - `extensions`
* - `binaryType`
*
* Latest version: https://github.com/joewalnes/reconnecting-websocket/
* - Joe Walnes
*
* Syntax
* ======
* var socket = new ReconnectingWebSocket(url, protocols, options);
*
* Parameters
* ==========
* url - The url you are connecting to.
* protocols - Optional string or array of protocols.
* options - See below
*
* Options
* =======
* Options can either be passed upon instantiation or set after instantiation:
*
* var socket = new ReconnectingWebSocket(url, null, { debug: true, reconnectInterval: 4000 });
*
* or
*
* var socket = new ReconnectingWebSocket(url);
* socket.debug = true;
* socket.reconnectInterval = 4000;
*
* debug
* - Whether this instance should log debug messages. Accepts true or false. Default: false.
*
* automaticOpen
* - Whether or not the websocket should attempt to connect immediately upon instantiation. The socket can be manually opened or closed at any time using ws.open() and ws.close().
*
* reconnectInterval
* - The number of milliseconds to delay before attempting to reconnect. Accepts integer. Default: 1000.
*
* maxReconnectInterval
* - The maximum number of milliseconds to delay a reconnection attempt. Accepts integer. Default: 30000.
*
* reconnectDecay
* - The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. Accepts integer or float. Default: 1.5.
*
* timeoutInterval
* - The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. Accepts integer. Default: 2000.
*
*/
(function (global, factory) {
if (typeof define === 'function' && define.amd) {
define([], factory);
} else if (typeof module !== 'undefined' && module.exports){
module.exports = factory();
} else {
global.ReconnectingWebSocket = factory();
}
})(this, function () {
if (!('WebSocket' in window)) {
return;
}
function ReconnectingWebSocket(url, protocols, options) {
// Default settings
var settings = {
/** Whether this instance should log debug messages. */
debug: false,
/** Whether or not the websocket should attempt to connect immediately upon instantiation. */
automaticOpen: true,
/** The number of milliseconds to delay before attempting to reconnect. */
reconnectInterval: 1000,
/** The maximum number of milliseconds to delay a reconnection attempt. */
maxReconnectInterval: 30000,
/** The rate of increase of the reconnect delay. Allows reconnect attempts to back off when problems persist. */
reconnectDecay: 1.5,
/** The maximum time in milliseconds to wait for a connection to succeed before closing and retrying. */
timeoutInterval: 2000,
/** The maximum number of reconnection attempts to make. Unlimited if null. */
maxReconnectAttempts: null,
/** The binary type, possible values 'blob' or 'arraybuffer', default 'blob'. */
binaryType: 'blob'
}
if (!options) { options = {}; }
// Overwrite and define settings with options if they exist.
for (var key in settings) {
if (typeof options[key] !== 'undefined') {
this[key] = options[key];
} else {
this[key] = settings[key];
}
}
// These should be treated as read-only properties
/** The URL as resolved by the constructor. This is always an absolute URL. Read only. */
this.url = url;
/** The number of attempted reconnects since starting, or the last successful connection. Read only. */
this.reconnectAttempts = 0;
/**
* The current state of the connection.
* Can be one of: WebSocket.CONNECTING, WebSocket.OPEN, WebSocket.CLOSING, WebSocket.CLOSED
* Read only.
*/
this.readyState = WebSocket.CONNECTING;
/**
* A string indicating the name of the sub-protocol the server selected; this will be one of
* the strings specified in the protocols parameter when creating the WebSocket object.
* Read only.
*/
this.protocol = null;
// Private state variables
var self = this;
var ws;
var forcedClose = false;
var timedOut = false;
var eventTarget = document.createElement('div');
// Wire up "on*" properties as event handlers
eventTarget.addEventListener('open', function(event) { self.onopen(event); });
eventTarget.addEventListener('close', function(event) { self.onclose(event); });
eventTarget.addEventListener('connecting', function(event) { self.onconnecting(event); });
eventTarget.addEventListener('message', function(event) { self.onmessage(event); });
eventTarget.addEventListener('error', function(event) { self.onerror(event); });
// Expose the API required by EventTarget
this.addEventListener = eventTarget.addEventListener.bind(eventTarget);
this.removeEventListener = eventTarget.removeEventListener.bind(eventTarget);
this.dispatchEvent = eventTarget.dispatchEvent.bind(eventTarget);
/**
* This function generates an event that is compatible with standard
* compliant browsers and IE9 - IE11
*
* This will prevent the error:
* Object doesn't support this action
*
* http://stackoverflow.com/questions/19345392/why-arent-my-parameters-getting-passed-through-to-a-dispatched-event/19345563#19345563
* @param s String The name that the event should use
* @param args Object an optional object that the event will use
*/
function generateEvent(s, args) {
var evt = document.createEvent("CustomEvent");
evt.initCustomEvent(s, false, false, args);
return evt;
};
this.open = function (reconnectAttempt) {
ws = new WebSocket(self.url, protocols || []);
ws.binaryType = this.binaryType;
if (reconnectAttempt) {
if (this.maxReconnectAttempts && this.reconnectAttempts > this.maxReconnectAttempts) {
return;
}
} else {
eventTarget.dispatchEvent(generateEvent('connecting'));
this.reconnectAttempts = 0;
}
if (self.debug || ReconnectingWebSocket.debugAll) {
console.debug('ReconnectingWebSocket', 'attempt-connect', self.url);
}
var localWs = ws;
var timeout = setTimeout(function() {
if (self.debug || ReconnectingWebSocket.debugAll) {
console.debug('ReconnectingWebSocket', 'connection-timeout', self.url);
}
timedOut = true;
localWs.close();
timedOut = false;
}, self.timeoutInterval);
ws.onopen = function(event) {
clearTimeout(timeout);
if (self.debug || ReconnectingWebSocket.debugAll) {
console.debug('ReconnectingWebSocket', 'onopen', self.url);
}
self.protocol = ws.protocol;
self.readyState = WebSocket.OPEN;
self.reconnectAttempts = 0;
var e = generateEvent('open');
e.isReconnect = reconnectAttempt;
reconnectAttempt = false;
eventTarget.dispatchEvent(e);
};
ws.onclose = function(event) {
clearTimeout(timeout);
ws = null;
if (forcedClose) {
self.readyState = WebSocket.CLOSED;
eventTarget.dispatchEvent(generateEvent('close'));
} else {
self.readyState = WebSocket.CONNECTING;
var e = generateEvent('connecting');
e.code = event.code;
e.reason = event.reason;
e.wasClean = event.wasClean;
eventTarget.dispatchEvent(e);
if (!reconnectAttempt && !timedOut) {
if (self.debug || ReconnectingWebSocket.debugAll) {
console.debug('ReconnectingWebSocket', 'onclose', self.url);
}
eventTarget.dispatchEvent(generateEvent('close'));
}
var timeout = self.reconnectInterval * Math.pow(self.reconnectDecay, self.reconnectAttempts);
setTimeout(function() {
self.reconnectAttempts++;
self.open(true);
}, timeout > self.maxReconnectInterval ? self.maxReconnectInterval : timeout);
}
};
ws.onmessage = function(event) {
if (self.debug || ReconnectingWebSocket.debugAll) {
console.debug('ReconnectingWebSocket', 'onmessage', self.url, event.data);
}
var e = generateEvent('message');
e.data = event.data;
eventTarget.dispatchEvent(e);
};
ws.onerror = function(event) {
if (self.debug || ReconnectingWebSocket.debugAll) {
console.debug('ReconnectingWebSocket', 'onerror', self.url, event);
}
eventTarget.dispatchEvent(generateEvent('error'));
};
}
// Whether or not to create a websocket upon instantiation
if (this.automaticOpen == true) {
this.open(false);
}
/**
* Transmits data to the server over the WebSocket connection.
*
* @param data a text string, ArrayBuffer or Blob to send to the server.
*/
this.send = function(data) {
if (ws) {
if (self.debug || ReconnectingWebSocket.debugAll) {
console.debug('ReconnectingWebSocket', 'send', self.url, data);
}
return ws.send(data);
} else {
throw 'INVALID_STATE_ERR : Pausing to reconnect websocket';
}
};
/**
* Closes the WebSocket connection or connection attempt, if any.
* If the connection is already CLOSED, this method does nothing.
*/
this.close = function(code, reason) {
// Default CLOSE_NORMAL code
if (typeof code == 'undefined') {
code = 1000;
}
forcedClose = true;
if (ws) {
ws.close(code, reason);
}
};
/**
* Additional public API method to refresh the connection if still open (close, re-open).
* For example, if the app suspects bad data / missed heart beats, it can try to refresh.
*/
this.refresh = function() {
if (ws) {
ws.close();
}
};
}
/**
* An event listener to be called when the WebSocket connection's readyState changes to OPEN;
* this indicates that the connection is ready to send and receive data.
*/
ReconnectingWebSocket.prototype.onopen = function(event) {};
/** An event listener to be called when the WebSocket connection's readyState changes to CLOSED. */
ReconnectingWebSocket.prototype.onclose = function(event) {};
/** An event listener to be called when a connection begins being attempted. */
ReconnectingWebSocket.prototype.onconnecting = function(event) {};
/** An event listener to be called when a message is received from the server. */
ReconnectingWebSocket.prototype.onmessage = function(event) {};
/** An event listener to be called when an error occurs. */
ReconnectingWebSocket.prototype.onerror = function(event) {};
/**
* Whether all instances of ReconnectingWebSocket should log debug messages.
* Setting this to true is the equivalent of setting all instances of ReconnectingWebSocket.debug to true.
*/
ReconnectingWebSocket.debugAll = false;
ReconnectingWebSocket.CONNECTING = WebSocket.CONNECTING;
ReconnectingWebSocket.OPEN = WebSocket.OPEN;
ReconnectingWebSocket.CLOSING = WebSocket.CLOSING;
ReconnectingWebSocket.CLOSED = WebSocket.CLOSED;
return ReconnectingWebSocket;
});

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View file

@ -0,0 +1,529 @@
var ReconnectingWebSocket = (function () {
'use strict';
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of the
License at http://www.apache.org/licenses/LICENSE-2.0
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = function(d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
return extendStatics(d, b);
};
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
var Event = /** @class */ (function () {
function Event(type, target) {
this.target = target;
this.type = type;
}
return Event;
}());
var ErrorEvent = /** @class */ (function (_super) {
__extends(ErrorEvent, _super);
function ErrorEvent(error, target) {
var _this = _super.call(this, 'error', target) || this;
_this.message = error.message;
_this.error = error;
return _this;
}
return ErrorEvent;
}(Event));
var CloseEvent = /** @class */ (function (_super) {
__extends(CloseEvent, _super);
function CloseEvent(code, reason, target) {
if (code === void 0) { code = 1000; }
if (reason === void 0) { reason = ''; }
var _this = _super.call(this, 'close', target) || this;
_this.wasClean = true;
_this.code = code;
_this.reason = reason;
return _this;
}
return CloseEvent;
}(Event));
/*!
* Reconnecting WebSocket
* by Pedro Ladaria <pedro.ladaria@gmail.com>
* https://github.com/pladaria/reconnecting-websocket
* License MIT
*/
var getGlobalWebSocket = function () {
if (typeof WebSocket !== 'undefined') {
// @ts-ignore
return WebSocket;
}
};
/**
* Returns true if given argument looks like a WebSocket class
*/
var isWebSocket = function (w) { return typeof w === 'function' && w.CLOSING === 2; };
var DEFAULT = {
maxReconnectionDelay: 10000,
minReconnectionDelay: 1000 + Math.random() * 4000,
minUptime: 5000,
reconnectionDelayGrowFactor: 1.3,
connectionTimeout: 4000,
maxRetries: Infinity,
debug: false,
};
var ReconnectingWebSocket = /** @class */ (function () {
function ReconnectingWebSocket(url, protocols, options) {
if (options === void 0) { options = {}; }
var _this = this;
this._listeners = {
error: [],
message: [],
open: [],
close: [],
};
this._retryCount = -1;
this._shouldReconnect = true;
this._connectLock = false;
this._binaryType = 'blob';
this._closeCalled = false;
this._messageQueue = [];
/**
* An event listener to be called when the WebSocket connection's readyState changes to CLOSED
*/
this.onclose = undefined;
/**
* An event listener to be called when an error occurs
*/
this.onerror = undefined;
/**
* An event listener to be called when a message is received from the server
*/
this.onmessage = undefined;
/**
* An event listener to be called when the WebSocket connection's readyState changes to OPEN;
* this indicates that the connection is ready to send and receive data
*/
this.onopen = undefined;
this._handleOpen = function (event) {
_this._debug('open event');
var _a = _this._options.minUptime, minUptime = _a === void 0 ? DEFAULT.minUptime : _a;
clearTimeout(_this._connectTimeout);
_this._uptimeTimeout = setTimeout(function () { return _this._acceptOpen(); }, minUptime);
// @ts-ignore
_this._ws.binaryType = _this._binaryType;
// send enqueued messages (messages sent before websocket open event)
_this._messageQueue.forEach(function (message) { return _this._ws.send(message); });
_this._messageQueue = [];
if (_this.onopen) {
_this.onopen(event);
}
_this._listeners.open.forEach(function (listener) { return _this._callEventListener(event, listener); });
};
this._handleMessage = function (event) {
_this._debug('message event');
if (_this.onmessage) {
_this.onmessage(event);
}
_this._listeners.message.forEach(function (listener) { return _this._callEventListener(event, listener); });
};
this._handleError = function (event) {
_this._debug('error event', event.message);
_this._disconnect(undefined, event.message === 'TIMEOUT' ? 'timeout' : undefined);
if (_this.onerror) {
_this.onerror(event);
}
_this._debug('exec error listeners');
_this._listeners.error.forEach(function (listener) { return _this._callEventListener(event, listener); });
_this._connect();
};
this._handleClose = function (event) {
_this._debug('close event');
_this._clearTimeouts();
if (_this._shouldReconnect) {
_this._connect();
}
if (_this.onclose) {
_this.onclose(event);
}
_this._listeners.close.forEach(function (listener) { return _this._callEventListener(event, listener); });
};
this._url = url;
this._protocols = protocols;
this._options = options;
this._connect();
}
Object.defineProperty(ReconnectingWebSocket, "CONNECTING", {
get: function () {
return 0;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReconnectingWebSocket, "OPEN", {
get: function () {
return 1;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReconnectingWebSocket, "CLOSING", {
get: function () {
return 2;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReconnectingWebSocket, "CLOSED", {
get: function () {
return 3;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReconnectingWebSocket.prototype, "CONNECTING", {
get: function () {
return ReconnectingWebSocket.CONNECTING;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReconnectingWebSocket.prototype, "OPEN", {
get: function () {
return ReconnectingWebSocket.OPEN;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReconnectingWebSocket.prototype, "CLOSING", {
get: function () {
return ReconnectingWebSocket.CLOSING;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReconnectingWebSocket.prototype, "CLOSED", {
get: function () {
return ReconnectingWebSocket.CLOSED;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReconnectingWebSocket.prototype, "binaryType", {
get: function () {
return this._ws ? this._ws.binaryType : this._binaryType;
},
set: function (value) {
this._binaryType = value;
if (this._ws) {
// @ts-ignore
this._ws.binaryType = value;
}
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReconnectingWebSocket.prototype, "retryCount", {
/**
* Returns the number or connection retries
*/
get: function () {
return Math.max(this._retryCount, 0);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReconnectingWebSocket.prototype, "bufferedAmount", {
/**
* The number of bytes of data that have been queued using calls to send() but not yet
* transmitted to the network. This value resets to zero once all queued data has been sent.
* This value does not reset to zero when the connection is closed; if you keep calling send(),
* this will continue to climb. Read only
*/
get: function () {
var bytes = this._messageQueue.reduce(function (acc, message) {
if (typeof message === 'string') {
acc += message.length; // not byte size
}
else if (message instanceof Blob) {
acc += message.size;
}
else {
acc += message.byteLength;
}
return acc;
}, 0);
return bytes + (this._ws ? this._ws.bufferedAmount : 0);
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReconnectingWebSocket.prototype, "extensions", {
/**
* The extensions selected by the server. This is currently only the empty string or a list of
* extensions as negotiated by the connection
*/
get: function () {
return this._ws ? this._ws.extensions : '';
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReconnectingWebSocket.prototype, "protocol", {
/**
* A string indicating the name of the sub-protocol the server selected;
* this will be one of the strings specified in the protocols parameter when creating the
* WebSocket object
*/
get: function () {
return this._ws ? this._ws.protocol : '';
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReconnectingWebSocket.prototype, "readyState", {
/**
* The current state of the connection; this is one of the Ready state constants
*/
get: function () {
return this._ws ? this._ws.readyState : ReconnectingWebSocket.CONNECTING;
},
enumerable: true,
configurable: true
});
Object.defineProperty(ReconnectingWebSocket.prototype, "url", {
/**
* The URL as resolved by the constructor
*/
get: function () {
return this._ws ? this._ws.url : '';
},
enumerable: true,
configurable: true
});
/**
* Closes the WebSocket connection or connection attempt, if any. If the connection is already
* CLOSED, this method does nothing
*/
ReconnectingWebSocket.prototype.close = function (code, reason) {
if (code === void 0) { code = 1000; }
this._closeCalled = true;
this._shouldReconnect = false;
this._clearTimeouts();
if (!this._ws) {
this._debug('close enqueued: no ws instance');
return;
}
if (this._ws.readyState === this.CLOSED) {
this._debug('close: already closed');
return;
}
this._ws.close(code, reason);
};
/**
* Closes the WebSocket connection or connection attempt and connects again.
* Resets retry counter;
*/
ReconnectingWebSocket.prototype.reconnect = function (code, reason) {
this._shouldReconnect = true;
this._closeCalled = false;
this._retryCount = -1;
if (!this._ws || this._ws.readyState === this.CLOSED) {
this._connect();
}
else {
this._disconnect(code, reason);
this._connect();
}
};
/**
* Enqueue specified data to be transmitted to the server over the WebSocket connection
*/
ReconnectingWebSocket.prototype.send = function (data) {
if (this._ws && this._ws.readyState === this.OPEN) {
this._debug('send', data);
this._ws.send(data);
}
else {
this._debug('enqueue', data);
this._messageQueue.push(data);
}
};
/**
* Register an event handler of a specific event type
*/
ReconnectingWebSocket.prototype.addEventListener = function (type, listener) {
if (this._listeners[type]) {
// @ts-ignore
this._listeners[type].push(listener);
}
};
/**
* Removes an event listener
*/
ReconnectingWebSocket.prototype.removeEventListener = function (type, listener) {
if (this._listeners[type]) {
// @ts-ignore
this._listeners[type] = this._listeners[type].filter(function (l) { return l !== listener; });
}
};
ReconnectingWebSocket.prototype._debug = function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (this._options.debug) {
// not using spread because compiled version uses Symbols
// tslint:disable-next-line
console.log.apply(console, ['RWS>'].concat(args));
}
};
ReconnectingWebSocket.prototype._getNextDelay = function () {
var _a = this._options, _b = _a.reconnectionDelayGrowFactor, reconnectionDelayGrowFactor = _b === void 0 ? DEFAULT.reconnectionDelayGrowFactor : _b, _c = _a.minReconnectionDelay, minReconnectionDelay = _c === void 0 ? DEFAULT.minReconnectionDelay : _c, _d = _a.maxReconnectionDelay, maxReconnectionDelay = _d === void 0 ? DEFAULT.maxReconnectionDelay : _d;
var delay = minReconnectionDelay;
if (this._retryCount > 0) {
delay =
minReconnectionDelay * Math.pow(reconnectionDelayGrowFactor, this._retryCount - 1);
if (delay > maxReconnectionDelay) {
delay = maxReconnectionDelay;
}
}
this._debug('next delay', delay);
return delay;
};
ReconnectingWebSocket.prototype._wait = function () {
var _this = this;
return new Promise(function (resolve) {
setTimeout(resolve, _this._getNextDelay());
});
};
ReconnectingWebSocket.prototype._getNextUrl = function (urlProvider) {
if (typeof urlProvider === 'string') {
return Promise.resolve(urlProvider);
}
if (typeof urlProvider === 'function') {
var url = urlProvider();
if (typeof url === 'string') {
return Promise.resolve(url);
}
if (url.then) {
return url;
}
}
throw Error('Invalid URL');
};
ReconnectingWebSocket.prototype._connect = function () {
var _this = this;
if (this._connectLock || !this._shouldReconnect) {
return;
}
this._connectLock = true;
var _a = this._options, _b = _a.maxRetries, maxRetries = _b === void 0 ? DEFAULT.maxRetries : _b, _c = _a.connectionTimeout, connectionTimeout = _c === void 0 ? DEFAULT.connectionTimeout : _c, _d = _a.WebSocket, WebSocket = _d === void 0 ? getGlobalWebSocket() : _d;
if (this._retryCount >= maxRetries) {
this._debug('max retries reached', this._retryCount, '>=', maxRetries);
return;
}
this._retryCount++;
this._debug('connect', this._retryCount);
this._removeListeners();
if (!isWebSocket(WebSocket)) {
throw Error('No valid WebSocket class provided');
}
this._wait()
.then(function () { return _this._getNextUrl(_this._url); })
.then(function (url) {
// close could be called before creating the ws
if (_this._closeCalled) {
_this._connectLock = false;
return;
}
_this._debug('connect', { url: url, protocols: _this._protocols });
_this._ws = _this._protocols
? new WebSocket(url, _this._protocols)
: new WebSocket(url);
// @ts-ignore
_this._ws.binaryType = _this._binaryType;
_this._connectLock = false;
_this._addListeners();
_this._connectTimeout = setTimeout(function () { return _this._handleTimeout(); }, connectionTimeout);
});
};
ReconnectingWebSocket.prototype._handleTimeout = function () {
this._debug('timeout event');
this._handleError(new ErrorEvent(Error('TIMEOUT'), this));
};
ReconnectingWebSocket.prototype._disconnect = function (code, reason) {
if (code === void 0) { code = 1000; }
this._clearTimeouts();
if (!this._ws) {
return;
}
this._removeListeners();
try {
this._ws.close(code, reason);
this._handleClose(new CloseEvent(code, reason, this));
}
catch (error) {
// ignore
}
};
ReconnectingWebSocket.prototype._acceptOpen = function () {
this._debug('accept open');
this._retryCount = 0;
};
ReconnectingWebSocket.prototype._callEventListener = function (event, listener) {
if ('handleEvent' in listener) {
// @ts-ignore
listener.handleEvent(event);
}
else {
// @ts-ignore
listener(event);
}
};
ReconnectingWebSocket.prototype._removeListeners = function () {
if (!this._ws) {
return;
}
this._debug('removeListeners');
this._ws.removeEventListener('open', this._handleOpen);
this._ws.removeEventListener('close', this._handleClose);
this._ws.removeEventListener('message', this._handleMessage);
// @ts-ignore
this._ws.removeEventListener('error', this._handleError);
};
ReconnectingWebSocket.prototype._addListeners = function () {
if (!this._ws) {
return;
}
this._debug('addListeners');
this._ws.addEventListener('open', this._handleOpen);
this._ws.addEventListener('close', this._handleClose);
this._ws.addEventListener('message', this._handleMessage);
// @ts-ignore
this._ws.addEventListener('error', this._handleError);
};
ReconnectingWebSocket.prototype._clearTimeouts = function () {
clearTimeout(this._connectTimeout);
clearTimeout(this._uptimeTimeout);
};
return ReconnectingWebSocket;
}());
return ReconnectingWebSocket;
}());

File diff suppressed because one or more lines are too long

View file

@ -9,23 +9,23 @@
<meta name="theme-color" content="#a00e26"> <meta name="theme-color" content="#a00e26">
<meta name="apple-mobile-web-app-status-bar-style" content="black"> <meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="icon" sizes="96x96" href="{% static "kfet/img/favicon.png" %}"> <link rel="icon" sizes="96x96" href="{% static 'kfet/img/favicon.png' %}">
{# CSS #} {# CSS #}
<link type="text/css" rel="stylesheet" href="{% static 'fonts/Roboto/roboto.css' %}" /> <link type="text/css" rel="stylesheet" href="{% static 'fonts/Roboto/roboto.css' %}" />
<link rel="stylesheet" type="text/css" href="{% static 'vendor/bootstrap/css/bootstrap.min.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'vendor/bootstrap/css/bootstrap.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'vendor/jquery/jquery-ui.min.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'vendor/jquery/jquery-ui.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'kfet/css/jquery-confirm.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'kfet/vendor/jquery/jquery-confirm.min.css' %}">
<link rel="stylesheet" type="text/css" href="{% static 'kfet/css/index.css' %}"> <link rel="stylesheet" type="text/css" href="{% static 'kfet/css/index.css' %}">
{# JS #} {# JS #}
<script type="text/javascript" src="{% static "kfet/js/js.cookie.js" %}"></script> <script type="text/javascript" src="{% static 'kfet/vendor/js.cookie.js' %}"></script>
<script type="text/javascript" src="{% static 'vendor/jquery/jquery-3.3.1.min.js' %}"></script> <script type="text/javascript" src="{% static 'vendor/jquery/jquery-3.3.1.min.js' %}"></script>
<script type="text/javascript" src="{% static 'vendor/bootstrap/js/bootstrap.min.js' %}"></script> <script type="text/javascript" src="{% static 'vendor/bootstrap/js/bootstrap.min.js' %}"></script>
<script type="text/javascript" src="{% static 'vendor/jquery/jquery-ui.min.js' %}"></script> <script type="text/javascript" src="{% static 'vendor/jquery/jquery-ui.min.js' %}"></script>
<script type="text/javascript" src="{% static 'kfet/js/jquery-confirm.js' %}"></script> <script type="text/javascript" src="{% static 'kfet/vendor/jquery/jquery-confirm.min.js' %}"></script>
<script type="text/javascript" src="{% static 'kfet/vendor/jquery-tablesorter/jquery.tablesorter.combined.js' %}"></script> <script type="text/javascript" src="{% static 'kfet/vendor/jquery/jquery.tablesorter.combined.min.js' %}"></script>
<script type="text/javascript" src="{% static 'kfet/js/reconnecting-websocket.js' %}"></script> <script type="text/javascript" src="{% static 'kfet/vendor/reconnecting-websocket.min.js' %}"></script>
<script type="text/javascript" src="{% static 'kfet/vendor/moment/moment.min.js' %}"></script> <script type="text/javascript" src="{% static 'kfet/vendor/moment/moment.min.js' %}"></script>
<script type="text/javascript" src="{% static 'kfet/vendor/moment/fr.js' %}"></script> <script type="text/javascript" src="{% static 'kfet/vendor/moment/fr.js' %}"></script>
<script type="text/javascript" src="{% static 'kfet/js/kfet.js' %}"></script> <script type="text/javascript" src="{% static 'kfet/js/kfet.js' %}"></script>