This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * | |
| * @param {String} title | |
| * @param {String} description | |
| * @returns | |
| */ | |
| function ThrowError(title, description) { | |
| let error; | |
| try { throw new Error(); } catch (e) { error = e; } | |
| const stack = error.stack.split('\n').slice(2).join('\n'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Converts an HTML table into a downloadable .xls file. | |
| * Generates an HTML file with Microsoft Excel metadata and encodes it in Base64. | |
| * | |
| * @param {string|HTMLTableElement} tableSelector - CSS selector (ID/class) or the DOM element of the table. | |
| * @param {string} [filename='Table'] - The desired filename for the download (without extension). | |
| * @returns {void} | |
| */ | |
| function HTMLTable2XLS(tableSelector, filename = 'Table') { | |
| // 1. Resolve the table element |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Calculates the estimated weight in bytes of a Base64 string. | |
| * @param {String} base64 - Base64 string (may include data: prefix) | |
| * @returns {Object} - { Bytes, KBytes, MBytes } | |
| */ | |
| function Base64Weight(base64) { | |
| if (!base64) return { Bytes: 0, KBytes: 0, MBytes: 0 }; | |
| // 1. Remove data: prefix if present | |
| if (base64.indexOf("data:") >= 0) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Object.IsPlain = function(obj){ | |
| // 1. It must be an object and not null | |
| if (typeof obj !== 'object' || obj === null) return false; | |
| // 2. It must be strictly a generic object, not Arrays, Dates, etc. | |
| if (Object.prototype.toString.call(obj) !== '[object Object]') return false; | |
| // 3. Verify the prototype | |
| const proto = Object.getPrototypeOf(obj); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * | |
| * @param {Number} input | |
| * @param {Number} inMin | |
| * @param {Number} inMax | |
| * @param {Number} outMin | |
| * @param {Number} outMax | |
| * @returns | |
| */ | |
| function Map(input, inMin, inMax, outMin, outMax){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * | |
| * @param {Number} input | |
| * @param {Number} min | |
| * @param {Number} max | |
| * @returns | |
| */ | |
| function Clamp(input, min, max){ | |
| return input > max? max : (input < min? min : input) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * | |
| * @param {String} value | |
| * @returns | |
| */ | |
| String.IsNullOrEmpty = function(value) { | |
| return value === null || value === undefined || value === ""; | |
| }; | |
| /** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| document.addEventListener('wheel', e =>{ | |
| if (e.ctrlKey || e.metaKey){ | |
| const zoomEvent = new CustomEvent('zoom', { | |
| detail: { deltaY: e.deltaY, ctrlKey: true }, | |
| bubbles: true, | |
| cancelable: true | |
| }); | |
| // Copiar todas las propiedades del evento wheel | |
| Object.assign(zoomEvent, { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const exts = ['jpg', 'jpeg', 'jfif', 'pjpeg', 'pjp', 'png', 'gif', 'webp', 'avif', 'svg', 'apng', 'bmp', 'ico']; | |
| /** | |
| * Get extension from string (try "name.xls.doc.js" result "js") | |
| * @param {String} fileName | |
| * @returns | |
| */ | |
| function getExtension(fileName){ | |
| let regex = /(?:\.([^.]+))?$/; | |
| return regex.exec(fileName+"")[1]; |