Skip to content
XHiddenProjects edited this page Sep 3, 2024 · 3 revisions

These are extra imports that you can add to your extensions which allows more open-source and flexibility.

Geolocation

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="*");

Security

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.1

Functions:

validate - Returns validated string/int/float/boolean

sanitize - Returns sanitized string/int/float/boolean

Validate Filters:

Filter NameIDDescription
FILTER_VALIDATE_INT257Make sure the value is a intager
FILTER_VALDATE_BOOLEAN258Make sure the value is a boolean
FILTER_VALIDATE_FLOAT259Make sure the value is a float
FILTER_VALIDATE_REGEXP260Make sure the value is a RegExp
FILTER_VALIDATE_DOMAIN277Make sure the value is a Domain
FILTER_VALIDATE_URL273Make sure the value is a URL
FILTER_VALIDATE_EMAIL274Make sure the value is a Email
FILTER_VALIDATE_IP275Make sure the value is a IP
FILTER_VALIDATE_MAC276Make sure the value is a MAC Address

Sanitize Filters:

Filter NameIDDescription
FILTER_SANITIZE_ADD_SLASHES523Adds slashes to special characters
FILTER_SANITIZE_EMAIL517Sanitizes string to a valid email address
FILTER_SANITIZE_ENCODED514Encodes the string
FILTER_SANITIZE_NUMBER_FLOAT520Removes all non-digit characters but keeps +,-
FILTER_SANITIZE_NUMBER_INT519Removes all non-digit characters
FILTER_SANITIZE_SPECIAL_CHARS515Converts special characters to HTML Entities
FILTER_SANITIZE_URL518Sanitizes string to a valid URL

Flags:

Flag NameIDDescriptionMerge
FILTER_FLAG_ALLOW_FRACTION4096Allows . in floatsFILTER_SANITIZE_NUMBER_FLOAT
FILTER_FLAG_ALLOW_THOUSAND8192Allows , in floatsFILTER_SANITIZE_NUMBER_FLOAT
FILTER_FLAG_ALLOW_SCIENTIFIC16384Allows e or E in floatsFILTER_SANITIZE_NUMBER_FLOAT
FILTER_FLAG_STRIP_LOW4Adds slashes to special charactersFILTER_SANITIZE_SPECIAL_CHARS
FILTER_FLAG_STRIP_HIGH8Adds slashes to special charactersFILTER_SANITIZE_SPECIAL_CHARS
FILTER_FLAG_ENCODE_HIGH32Adds slashes to special charactersFILTER_SANITIZE_SPECIAL_CHARS
FILTER_FLAG_IPV41048576Checks if IP is a IPV4FILTER_VALIDATE_IP
FILTER_FLAG_IPV62097152Checks if IP is a IPV6FILTER_VALIDATE_IP
FILTER_FLAG_NO_PRIV_RANGE8388608Checks if IP is not in a private rangeFILTER_VALIDATE_IP
FILTER_FLAG_NO_RES_RANGE4194304Checks if IP is not in a reserived rangeFILTER_VALIDATE_IP

Events

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);

Utils

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();
CONSTVALUE
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/
ORGINhttp(s)?//domain/

Clone this wiki locally