-
Notifications
You must be signed in to change notification settings - Fork 5
Retina basic functions
Retina.keys(object, noFunctions)
Returns an array of keys of object. If noFunctions is true, functions will be omitted in the array. This function only iterates over the topmost object level.
Retina.values(object)
Returns an array of values of object. This function only iterates over the topmost object level.
Retina.traverse(object, function)
Calls function on each scalar value of an object. This will traverse the entire object hierarchy.
Retina.mouseCoords(event)
This can be called with an event to receive an object with the properties x and y which are the mouse coordinates relative to the top left corner of the HTML document.
Retina.wait(milliseconds)
Synchronous function that will return after millliseconds milliseconds.
Retina.dateString(date)
Given a date object or a string representing a date this function will return an ISO 8601 date-time.
Retina.uuidv4(a, b)
Given two numbers a and b returns a RFC4122 compliant UUID v4.
Retina.findPos(DOMObject)
Given a DOMObject returns an array of the x- and y-coordinates on the HTML page of that object.
Retina.propSort(property, direction)
This can be used as a sorting function in array.sort(). The array must contain objects which will be sorted by the property property. Default sort order is alphabetically ascending. Setting direction to true will sort descending.
Retina.numSort(a, b)
This can be used as a sorting function in array.sort(). It will sort ascending numerically;
Retina.sortDesc(a, b)
This can be used as a sorting function in array.sort(). It will sort descending numerically or alphabetically depending on the data type in the array.
Retina.stripHTML(string)
Given a string returns the string without any HTML tags.
Retina.svg2png(source, target, width, height)
This function converts an SVG image to PNG. source must be a selector string of an SVG element. target must be a DOMObject to hold the PNG image. width and height must be integers specifying the size of the target image.
Retina.Base64.encode(string) Retina.Base64.decode(string)
Base64 encodes and decodes a string.
Retina.cgiParam(paramName)
Returns the value of the CGI parameter paramName from URL.
Retina.reverseComplement(sequence)
Returns the reverse complement of the genome sequence sequence.
Retina.log10(number)
Returns the log base 10 of number.
Retina.niceScale({ min, max, ticks })
Given an object of parameters returns the minimum, maximum and tick-space of a scale in the return object { 'min': niceMin, 'max': niceMax, 'space': tickSpace }. The numbers of the scale will be "nice" numbers.
Retina.d2h(number)
Returns the hexadecimal value of a decimal number.
Retina.h2d(number)
Returns the decimal value of a hexadecimal number.
Retina.md5(string)
Returns the md5 sum of a string.
Retina.round(number, precision)
Returns number rounded to precision.