Namespace for IITC utils
Members
-
static, constant MAX_LATITUDE :Number
-
The maximum absolute latitude that can be represented in Web Mercator projection (EPSG:3857). This value is taken from L.Projection.SphericalMercator.MAX_LATITUDE
Methods
-
private, static clamp(n, max, min) → {number}
-
Clamps a given value between a minimum and maximum value. Simple implementation for internal use.
Parameters:
Name Type Description nnumber The value to clamp.
maxnumber The maximum allowed value.
minnumber The minimum allowed value.
Returns:
number -The clamped value.
-
static clampLatLng(latlng) → {Array.<number>}
-
Clamps a latitude and longitude to the maximum and minimum valid values.
Parameters:
Name Type Description latlngL.LatLng The latitude and longitude to clamp.
Returns:
Array.<number> -The clamped latitude and longitude.
-
static clampLatLngBounds(bounds) → {L.LatLngBounds}
-
Clamps a latitude and longitude bounds to the maximum and minimum valid values.
Parameters:
Name Type Description boundsL.LatLngBounds The bounds to clamp.
Returns:
L.LatLngBounds -The clamped bounds.
-
static deleteCookie(name)
-
Deletes a cookie by name.
Parameters:
Name Type Description namestring The name of the cookie to delete.
-
static escapeHtml(str, allowedTagsopt) → {string}
-
Escapes HTML special characters in a string.
Parameters:
Name Type Attributes Description strstring The string to escape.
allowedTagsArray.<string> <optional>
Optional array of allowed HTML tags that should not be escaped.
Returns:
string -The escaped string.
-
static escapeJS(str) → {string}
-
Escapes special characters in a string for use in JavaScript. (for strings passed as parameters to html onclick="..." for example)
Parameters:
Name Type Description strstring The string to escape.
Returns:
string -The escaped string.
-
static formatAgo(time, now, optionsopt) → {string}
-
Formats the time difference between two timestamps (in milliseconds) as a string.
Parameters:
Name Type Attributes Description timenumber The past timestamp in milliseconds.
nownumber The current timestamp in milliseconds.
optionsObject <optional>
Options for formatting.
Properties
Name Type Attributes Default Description showSecondsboolean <optional>
false Whether to include seconds in the result.
Returns:
string -The formatted time difference (e.g., "45s", "5m", "2h 45m", "1d 3h 45m")
-
static formatDistance(distance) → {string}
-
Formats a distance in meters, converting to kilometers with appropriate precision based on the distance range.
For distances:
- Under 1000m: shows in meters, rounded to whole numbers
- 1000m to 9999m: shows in kilometers with 1 decimal place
- 10000m and above: shows in whole kilometers
Parameters:
Name Type Description distancenumber The distance in meters.
Returns:
string -The formatted distance.
-
static formatInterval(seconds, maxTermsopt) → {string}
-
Formats an interval of time given in seconds into a human-readable string.
Parameters:
Name Type Attributes Description secondsnumber The interval in seconds.
maxTermsnumber <optional>
The maximum number of time units to include.
Returns:
string -The formatted time interval.
-
static formatNumber(num) → {string}
-
Formats a number with thousand separators (thin spaces). see https://en.wikipedia.org/wiki/Space_(punctuation)#Table_of_spaces
Parameters:
Name Type Description numnumber The number to format.
Returns:
string -The formatted number with thousand separators.
-
static genFourColumnTable(blocks) → {string}
-
Generates a four-column HTML table from an array of data blocks.
Parameters:
Name Type Description blocksArray Array of data blocks, where each block is an array with details for one row.
Returns:
string -HTML string representing the constructed table.
-
static getCookie(name) → {string|undefined}
-
Retrieves the value of a cookie by name.
Parameters:
Name Type Description namestring The name of the cookie to retrieve.
Returns:
string | undefined -The value of the cookie, or undefined if not found.
-
static getTeamId(input) → {number}
-
Converts a team string or object to a team ID. Accepts either team string directly (e.g. "RESISTANCE", "R") or an object with team property. Returns TEAM_NONE if no match found.
Parameters:
Name Type Description inputObject | string Input to convert to team ID
Properties
Name Type Attributes Description teamstring <optional>
Team string when input is an object
Returns:
number -The team ID corresponding to the team string.
-
static getURLParam(param) → {string}
-
Retrieves a parameter from the URL query string.
Parameters:
Name Type Description paramstring The name of the parameter to retrieve.
Returns:
string -The value of the parameter, or an empty string if not found.
-
static isPointInPolygon(polygon, point) → {boolean}
-
Determines if a point is inside a polygon.
Parameters:
Name Type Description polygonArray.<L.LatLng> The vertices of the polygon.
pointL.LatLng The point to test.
Returns:
boolean -True if the point is inside the polygon, false otherwise.
-
static isTouchDevice() → {boolean}
-
Checks if the device is a touch-enabled device. Alias for
L.Browser.touch()Returns:
boolean -True if the device is touch-enabled, otherwise false.
-
static prettyEnergy(nrg) → {string|number}
-
Formats the energy of a portal, converting to "k" units if over 1000.
Parameters:
Name Type Description nrgnumber The energy value to format.
Returns:
string | number -The formatted energy value.
-
static scrollBottom(elm) → {number}
-
Calculates the number of pixels left to scroll down before reaching the bottom of an element.
Parameters:
Name Type Description elmstring | HTMLElement | jQuery The element or selector to calculate the scroll bottom for.
Returns:
number -The number of pixels from the bottom.
-
static setCookie(name, value, daysopt)
-
Sets a cookie with a specified name and value, with a default expiration of 10 years.
Parameters:
Name Type Attributes Default Description namestring The name of the cookie.
valuestring The value of the cookie.
daysnumber <optional>
3650 Optional: the number of days until the cookie expires (default is 10 years).
-
static textToTable(text) → {string}
-
Converts text with newlines (
\n) and tabs (\t) into an HTML table.Parameters:
Name Type Description textstring The text to convert.
Returns:
string -The resulting HTML table.
-
static uniqueArray(arr) → {Array}
-
Converts a list of items into a unique array, removing duplicates.
Parameters:
Name Type Description arrArray The array to process.
Returns:
Array -A new array containing only unique elements.
-
static unixTimeToDateTimeString(time, millisecondopt) → {string|null}
-
Converts a UNIX timestamp to a precise date and time string in the local timezone. Formatted in ISO-style YYYY-MM-DD hh:mm:ss.mmm - but using local timezone.
Parameters:
Name Type Attributes Description timenumber The UNIX timestamp to convert.
millisecondboolean <optional>
Whether to include millisecond precision.
Returns:
string | null -The formatted date and time string.
-
static unixTimeToHHmm(time) → {string|null}
-
Converts a UNIX timestamp to a time string formatted as HH:mm.
Parameters:
Name Type Description timenumber | string The UNIX timestamp to convert.
Returns:
string | null -Formatted time as HH:mm.
-
static unixTimeToString(timestamp, fullopt) → {string|null}
-
Converts a UNIX timestamp to a human-readable string. If the timestamp is from today, returns the time (HH:mm:ss format); otherwise, returns the date (YYYY-MM-DD).
Parameters:
Name Type Attributes Default Description timestampnumber | string The UNIX timestamp in milliseconds to convert.
fullboolean <optional>
false If true, returns both date and time in "YYYY-MM-DD
" format. Returns:
string | null -The formatted date and/or time string, or null if no timestamp provided.
-
static zeroPad(number, length) → {string}
-
Pads a number with zeros up to a specified length.
Parameters:
Name Type Description numbernumber The number to pad.
lengthnumber The desired length of the output string.
Returns:
string -The padded number as a string.