Artifact
2b8a7803c0eac479d7bf8d95c4fa345a9cf5149b2703c55bf39267e3222286a2:
'use strict';
exports.isObject = (obj) => {
if (typeof obj === 'object' && !Array.isArray(obj) && obj !== null && obj instanceof SVGElement === false && obj instanceof HTMLElement === false ) {
return true;
} else {
return false;
}
};
// Restricts input for the given textbox to the given inputFilter function
// cf https://stackoverflow.com/a/469362
exports.setInputFilter = (textbox, inputFilter) => {
["input", "keydown", "keyup", "mousedown", "mouseup", "select", "contextmenu", "drop"].forEach(function(event) {
textbox.addEventListener(event, function() {
if (inputFilter(this.value)) {
this.oldValue = this.value;
this.oldSelectionStart = this.selectionStart;
this.oldSelectionEnd = this.selectionEnd;
} else if (this.hasOwnProperty("oldValue")) {
this.value = this.oldValue;
this.setSelectionRange(this.oldSelectionStart, this.oldSelectionEnd);
} else {
this.value = "";
}
});
});
};