Skip to content
cjcliffe edited this page Oct 15, 2011 · 4 revisions

CubicVR.util

The util object provides extra utilities for common tasks.

Methods:

getScriptContents( id )

Get the contents of a DOM script node with id=id, or id=relative/absolute URL.

Parameters:

  • id : id of SCRIPT tag or URL

Returns:

Contents of script if successful, empty string if not.

getURL( srcUrl )

Get the contents of the document at absolute/relative url srcUrl.

Parameters:

  • srcUrl : URL of document to retrieve.

Returns:

srcUrl contents if successful, null if not.

getXML( srcUrl )

Get the contents of the document at absolute/relative url srcUrl, force XML type.

Parameters:

  • srcUrl : URL of XML document to retrieve.

Returns:

srcUrl contents as XML if successful, null if not.

repackArray( data, stride, count )

Given array data repack it into an Array of Arrays of size stride — supply count for validation.

Parameters:

  • data : Source, unpacked array.
  • stride : Number of elements to pack into each new element.
  • count (optional) : Total count of repacked element bundles for validation.

Returns:

A repacked Array.

collectTextNode( tn )

Collect all the text under the given DOM node tn. Will re-assemble broken text elements automatically.

Parameters:

  • tn : A DOM node with child elements of text.

Returns:

All text under DOM node tn.

floatDelimArray( float_str, delim )

Parse a string float_str into an array of floats, use delim as a separator (similar to common 'explode' or 'split').

Parameters:

  • float_str : String containing delimited floats, e.g. "1.0,2.0,3.0"
  • delim : String containing the delimiter, e.g. ","

Returns:

Array of floats extracted from float_str delimited by delim.

intDelimArray( int_str, delim )

Parse a string int_str into an array of integers, use delim as a separator (similar to common 'explode' or 'split').

Parameters:

  • int_str : String containing delimited ints, e.g. "1,2,3"
  • delim : String containing the delimiter, e.g. ","

Returns:

Array of ints extracted from int_str delimited by delim.

textDelimArray( text_str, delim )

Parse a string text_str into an array of strings, use delim as a separator (similar to common 'explode' or 'split').

Parameters:

  • text_str : String containing delimited strings, e.g. "A,B,C"
  • delim : String containing the delimiter, e.g. ","

Returns:

Array of strings extracted from text_str delimited by delim.

Clone this wiki locally