Moved applet-core functionalities to individual libs, Updated UUID and IBAN generators

Update iban-generator.mjs, uuid-generator.mjs, and 4 more files...
This commit is contained in:
2025-03-17 23:44:09 +01:00
parent 3e8ec44ae4
commit 18bb55cea9
6 changed files with 170 additions and 54 deletions

View File

@@ -0,0 +1,36 @@
// NibblePoker - HTML Input Utils
// Author: Herwin Bozet (@NibblePoker)
// License: Public Domain (This code)
/**
* Retrieves the number from an `HTMLInputElement`
* @param eInput {HTMLInputElement} The `HTMLInputElement` from which the value will be retrieved.
* @param min {number|null} If given, sets a minimum the value can have when returned.
* @param max {number|null} If given, sets a maximum the value can have when returned.
* @returns {number} The value from the given `HTMLInputElement`, or `1` if no valid one was given.
*/
export function getInputCount(eInput, min = null, max = null) {
let desiredCount = null;
try {
desiredCount = parseInt(eInput.value);
} catch (e) {
console.error(e);
}
if (desiredCount === null) {
desiredCount = 1;
}
if (typeof min === 'number') {
if (desiredCount < min) {
desiredCount = min;
}
}
if (typeof max === 'number') {
if (desiredCount > max) {
desiredCount = max;
}
}
return desiredCount;
}