Skip to content

Retina basic functions

Tobias Paczian edited this page Apr 11, 2018 · 12 revisions

keys

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.


values

Retina.values(object)

Returns an array of values of object. This function only iterates over the topmost object level.


traverse

Retina.traverse(object, function)

Calls function on each scalar value of an object. This will traverse the entire object hierarchy.


mouseCoords

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.


wait

Retina.wait(milliseconds)

Synchronous function that will return after millliseconds milliseconds.


dateString

Retina.dateString(date)

Given a date object or a string representing a date this function will return an ISO 8601 date-time.


uuidv4

Retina.uuidv4(a, b)

Given two numbers a and b returns a RFC4122 compliant UUID v4.


findPos

Retina.findPos(DOMObject)

Given a DOMObject returns an array of the x- and y-coordinates on the HTML page of that object.


propSort

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.


numSort

Retina.numSort(a, b)

This can be used as a sorting function in array.sort(). It will sort ascending numerically;


sortDesc

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.


stripHTML

Retina.stripHTML(string)

Given a string returns the string without any HTML tags.


svg2png

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.


Base64

Retina.Base64.encode(string) Retina.Base64.decode(string)

Base64 encodes and decodes a string.


cgiParam

Retina.cgiParam(paramName)

Returns the value of the CGI parameter paramName from URL.


reverseComplement

Retina.reverseComplement(sequence)

Returns the reverse complement of the genome sequence sequence.


log10

Retina.log10(number)

Returns the log base 10 of number.


niceScale

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.


d2h

Retina.d2h(number)

Returns the hexadecimal value of a decimal number.


h2d

Retina.h2d(number)

Returns the decimal value of a hexadecimal number.


md5

Retina.md5(string)

Returns the md5 sum of a string.


round

Retina.round(number, precision)

Returns number rounded to precision.

Clone this wiki locally