2018-08-14 12:11:49 +00:00
|
|
|
/*
|
|
|
|
* noVNC: HTML5 VNC client
|
2020-08-11 12:05:09 +00:00
|
|
|
* Copyright (C) 2020 The noVNC Authors
|
2018-08-14 12:11:49 +00:00
|
|
|
* Licensed under MPL 2.0 or any later version (see LICENSE.txt)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Polyfills to provide new APIs in old browsers */
|
|
|
|
|
|
|
|
/* Object.assign() (taken from MDN) */
|
|
|
|
if (typeof Object.assign != 'function') {
|
|
|
|
// Must be writable: true, enumerable: false, configurable: true
|
|
|
|
Object.defineProperty(Object, "assign", {
|
2018-08-27 12:30:50 +00:00
|
|
|
value: function assign(target, varArgs) { // .length of function is 2
|
2018-08-14 12:11:49 +00:00
|
|
|
'use strict';
|
2018-08-27 12:30:50 +00:00
|
|
|
if (target == null) { // TypeError if undefined or null
|
2018-08-14 12:11:49 +00:00
|
|
|
throw new TypeError('Cannot convert undefined or null to object');
|
|
|
|
}
|
|
|
|
|
2019-06-24 11:26:25 +00:00
|
|
|
const to = Object(target);
|
2018-08-14 12:11:49 +00:00
|
|
|
|
2019-06-24 11:26:25 +00:00
|
|
|
for (let index = 1; index < arguments.length; index++) {
|
|
|
|
const nextSource = arguments[index];
|
2018-08-14 12:11:49 +00:00
|
|
|
|
2018-08-27 12:30:50 +00:00
|
|
|
if (nextSource != null) { // Skip over if undefined or null
|
2019-06-24 11:26:25 +00:00
|
|
|
for (let nextKey in nextSource) {
|
2018-08-14 12:11:49 +00:00
|
|
|
// Avoid bugs when hasOwnProperty is shadowed
|
|
|
|
if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
|
|
|
|
to[nextKey] = nextSource[nextKey];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return to;
|
|
|
|
},
|
|
|
|
writable: true,
|
|
|
|
configurable: true
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/* CustomEvent constructor (taken from MDN) */
|
2019-06-24 11:26:25 +00:00
|
|
|
(() => {
|
|
|
|
function CustomEvent(event, params) {
|
2018-08-14 12:11:49 +00:00
|
|
|
params = params || { bubbles: false, cancelable: false, detail: undefined };
|
2019-06-24 11:26:25 +00:00
|
|
|
const evt = document.createEvent( 'CustomEvent' );
|
2018-08-27 12:30:50 +00:00
|
|
|
evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );
|
2018-08-14 12:11:49 +00:00
|
|
|
return evt;
|
|
|
|
}
|
|
|
|
|
|
|
|
CustomEvent.prototype = window.Event.prototype;
|
|
|
|
|
|
|
|
if (typeof window.CustomEvent !== "function") {
|
|
|
|
window.CustomEvent = CustomEvent;
|
|
|
|
}
|
2018-08-27 12:30:50 +00:00
|
|
|
})();
|
2020-08-11 12:05:09 +00:00
|
|
|
|
|
|
|
/* Number.isInteger() (taken from MDN) */
|
|
|
|
Number.isInteger = Number.isInteger || function isInteger(value) {
|
|
|
|
return typeof value === 'number' &&
|
|
|
|
isFinite(value) &&
|
|
|
|
Math.floor(value) === value;
|
|
|
|
};
|