-
Notifications
You must be signed in to change notification settings - Fork 1
Utils
There are a few miscellaneous functions that are used across the app. These are contained in utils.js
.
Opens a url with the provided option. Will open in the same tab if the option is _self
or a new tab if it is _blank
.
- url
- String url to open.
- option
- String open option.
Builds a new URL string for a given HTML file and a object representation of query parameters.
- page
- String type of page to open (index/selection).
- query
- JS object of query parameters.
Builds a query string from a given object.
- query
- JS object of query parameters.
Attempt to get a parameter first as a URLSearchParam, then as a cookie if the parameter doesn't exist.
- key
- String name of the parameter/cookie.
- dvalue
- Default value to return if the parameter/cookie does not exist.
Creates a cookie with a given name and value, set to expire in 1 week.
- cname
- String name of the cookie.
- cvalue
- Value to store in the cookie.
Returns the value of the requested cookie or the default.
- cname
- String name of the cookie.
- dvalue
- Default value to return if the cookie does not exist. Also stored as the value if the cookie didn't exist.
Calculates the mean of a given array of values.
- values
- Array of values to calculate from.
Calculates the standard deviation of a given array of values.
- values
- Array of values to calculate from.
Calculates the median of a given array of values.
- values
- Array of values to calculate from.
Calculates the mode of a given array of values.
- values
- Array of values to calculate from.
Generates a random boolean.
- low_odds
- Numeric value between 0 and 1 representing the odds of false being selected.
Generates a random integer between two given bounds.
- min
- Lowest value to generate.
- max
- Highest value to generate.
Calculates the distance between 2 x, y coordinates.
- x1
- x value of first point.
- y1
- y value of first point.
- x2
- x value of second point.
- y2
- y value of second point.
Determines if a given point is contained in a shape. Used primarily for doing analysis of Zebra data.
- vertices
- Array of vertices containing x and y properties.
- x
- x value to compare to vertices.
- y
- y value to compare to verticies.
Scrolls a given element on page until a contained element can be seen. Useful for options lists.
- container
- String scrollable element ID.
- goal
- String contained element ID.
Colors the header based on the given team number.
- team_num
- String containing a team number.
Converts a given unix timestamp to Day Hour:Minute.
- unix_time
- Numeric unix timestamp in ms.
Removes the path from the end of a URL resulting in the root.
- addr
- String URL of a page.
Determines if the given server URL is available and is a WildRank POST server.
- server
- String URL of the server, does not have to be root.
- notify
- Boolean representing if the user should be notified of a failure.
Includes a script from /scripts
by name.
- name
- String name of a file without the
.js
.
- String name of a file without the
Applys the current theme to the application. Chooses theme from cookie.
Converts a given value to a 2 byte hex string.
- value
- Numeric value to convert.
Finds placeholder text in a string for a opponent or partner team.
- text
- String to find placeholder text in.