- Notifications
You must be signed in to change notification settings - Fork 1
Components
These are extra imports that you can add to your extensions which allows more open-source and flexibility.
GeoLocation can be loaded using the following code:
Note: This does require an API key from IPInfo
importGeoLocationfrom'/WebServerAI/assets/AI/js/components/geolocation.js'constlocation=newGeoLocation();// IPV4 or "auto"/** @param {String} ipapiKey IP-API key goes here* @param {String|String[]} [info='*'] Selections go in an array or use "*" for all selections* @returns {JSON} JSON of IPA info */location.displayRecords(ipapiKey,info="*");These are security to inputs that can sanitize and validate certain text
import*asSecurityfrom'/WebServerAI/assets/AI/js/components/security.js';console.log(Security.validate('127.0.0.1',Security.FILTER_VALIDATE_IP));//Returns 127.0.0.1Functions:
validate - Returns validated string/int/float/boolean
sanitize - Returns sanitized string/int/float/boolean
Validate Filters:
| Filter Name | ID | Description |
|---|---|---|
| FILTER_VALIDATE_INT | 257 | Make sure the value is a intager |
| FILTER_VALDATE_BOOLEAN | 258 | Make sure the value is a boolean |
| FILTER_VALIDATE_FLOAT | 259 | Make sure the value is a float |
| FILTER_VALIDATE_REGEXP | 260 | Make sure the value is a RegExp |
| FILTER_VALIDATE_DOMAIN | 277 | Make sure the value is a Domain |
| FILTER_VALIDATE_URL | 273 | Make sure the value is a URL |
| FILTER_VALIDATE_EMAIL | 274 | Make sure the value is a Email |
| FILTER_VALIDATE_IP | 275 | Make sure the value is a IP |
| FILTER_VALIDATE_MAC | 276 | Make sure the value is a MAC Address |
Sanitize Filters:
| Filter Name | ID | Description |
|---|---|---|
| FILTER_SANITIZE_ADD_SLASHES | 523 | Adds slashes to special characters |
| FILTER_SANITIZE_EMAIL | 517 | Sanitizes string to a valid email address |
| FILTER_SANITIZE_ENCODED | 514 | Encodes the string |
| FILTER_SANITIZE_NUMBER_FLOAT | 520 | Removes all non-digit characters but keeps +,- |
| FILTER_SANITIZE_NUMBER_INT | 519 | Removes all non-digit characters |
| FILTER_SANITIZE_SPECIAL_CHARS | 515 | Converts special characters to HTML Entities |
| FILTER_SANITIZE_URL | 518 | Sanitizes string to a valid URL |
Flags:
| Flag Name | ID | Description | Merge |
|---|---|---|---|
| FILTER_FLAG_ALLOW_FRACTION | 4096 | Allows . in floats | FILTER_SANITIZE_NUMBER_FLOAT |
| FILTER_FLAG_ALLOW_THOUSAND | 8192 | Allows , in floats | FILTER_SANITIZE_NUMBER_FLOAT |
| FILTER_FLAG_ALLOW_SCIENTIFIC | 16384 | Allows e or E in floats | FILTER_SANITIZE_NUMBER_FLOAT |
| FILTER_FLAG_STRIP_LOW | 4 | Adds slashes to special characters | FILTER_SANITIZE_SPECIAL_CHARS |
| FILTER_FLAG_STRIP_HIGH | 8 | Adds slashes to special characters | FILTER_SANITIZE_SPECIAL_CHARS |
| FILTER_FLAG_ENCODE_HIGH | 32 | Adds slashes to special characters | FILTER_SANITIZE_SPECIAL_CHARS |
| FILTER_FLAG_IPV4 | 1048576 | Checks if IP is a IPV4 | FILTER_VALIDATE_IP |
| FILTER_FLAG_IPV6 | 2097152 | Checks if IP is a IPV6 | FILTER_VALIDATE_IP |
| FILTER_FLAG_NO_PRIV_RANGE | 8388608 | Checks if IP is not in a private range | FILTER_VALIDATE_IP |
| FILTER_FLAG_NO_RES_RANGE | 4194304 | Checks if IP is not in a reserived range | FILTER_VALIDATE_IP |
Process the wsa-build events
importEventsfrom'/WebServerAI/assets/AI/js/components/Events.js';conste=newEvents();/* * @param CustomEvent event - CustomEvent List * @param String label - What you want to search * @return {*|undefined} Returns any value, UNDEFINED if not found*/e.get(event,label);/** * Returns array of users statements * @param {String} str Users input * @returns {Array<String>} List of matching users dbl quotations*/e.statement(str);/** * Gets file content * @param {String} url Location to get the file content * @param {Boolean} [isJSON=false] Converts string to JSON object * @param {Boolean} [async=false] Wait until page load * @returns {JSON|String} */e.request(url,isJson=false,async=false);/** * Looks up an array to see if value is in-place * @param {Array<*>} arr Array to lookup * @param {String|Number} index value to look at * @returns {Boolean} */e.lookup(arr,index);/** * Returns the output of a certain command from the AI * @param {RegExp} eventPattern Check what to * @param {String} str String to check * @param {Function|null} [callback=null] Return as a function * @returns {RegExpMatchArray|null} */e.cmdLine(eventPattern,str,callback=null);import{rgbaToHex,keyboardFocusable,isDecimal,version_compare,getInfo,isScrollable,getInfo,HTMLEncoder,HTMLDecoder,merge,uniqid,IS_ENABLED,//CONSTVIDEO_PATH,AUDIO_PATH,IMAGE_PATH,SUBTITLE_PATH,DS,ORGIN}FROM"WebServerAI/assets/AI/js/components/utils.js";RGBA: converts rgb(a)? to hexdecimal
rgbaToHex(rgba);keyboardFocusable: Checks if the element is keyboard-focusable
keyboardFocusable(element);isDecimal: Checks if number is a decimal
isDecimal(number);version_compare: Compares two versions either TRUE/FALSE or -1, 0, or 1
/** v1 - version 1* v2 - version 2* operator [OPTIONAL] - <, >, <=, >=, =, ==, !=, or <>*/version_compare(v1,v2,'=');getInfo: Get extension information based on language
/** * Receives the extension information's based on language * @param {String} name Extension Name * @returns {String} JSON format of the extension */getInfo(name);isScrollable: Checks if an element is scrollable
/** * Returns if element is scrollable * @param {Element} element Element to check * @returns {Number|Array<Number>} -1 if scrollbar is horizontal, 1 if scrollbar is vertical, 0 if no scrollabars are present */isScrollable(elem);HTMLEncoder: Encodes HTML to sanitized string
/** * Decode HTML to encoded * @param {Array<String>|String} $items * @returns {Array<String>|String} Returns the encoded HTML */HTMLEncoder(name);HTMLDecoder: Decodes sanitized string to HTML string
/** * Encoded HTML to decoded * @param {Array<String>|String} $items * @returns {Array<String>|String} Returns the decoded HTML */HTMLDecoder($items);merge: Join array items with a character
/** * Merges array items with a certain character into 1 item array * @param {Array} Arr Array to merge * @param {String} mergeWith A character to merge items with * @returns {Array} Merges into 1 item array */merge(Arr,mergeWith='');uniqid: Generatates a uniqueID
/** * Generate a unique id * @param {string} [prefix=''] Prefix to the start of the ID * @param {boolean} [more_entropy=false] add more to the list * @returns {string}*/uniqid(prefix='',more_entropy=false);IS_ENABLED: Checks if the software is enabled
IS_ENABLED();| CONST | VALUE |
|---|---|
| VIDEO_PATH | /WebServerAI/assets/AI/videos |
| AUDIO_PATH | /WebServerAI/assets/AI/audios |
| IMAGE_PATH | /WebServerAI/assets/AI/images |
| SUBTITLE_PATH | /WebServerAI/assets/AI/subtitles |
| DS | / |
| ORGIN | http(s)?//domain/ |