API Documentation for: 0.6.0
Show:

RequestUtils Class

Defined in: RequestUtils:36
Module: PreloadJS

Utilities that assist with parsing load items, and determining file types, etc.

Item Index

Methods

Properties

Methods

buildPath

(
  • src
  • [data]
)
String static

Defined in buildPath:130

A utility method that builds a file path using a source and a data object, and formats it into a new path.

Parameters:

  • src String

    The source path to add values to.

  • [data] Object optional

    Object used to append values to this request as a query string. Existing parameters on the path will be preserved.

Returns:

String:

A formatted string that contains the path and the supplied parameters.

formatQueryString

(
  • data
  • [query]
)
static

Formats an object into a query string for either a POST or GET request.

Parameters:

  • data Object

    The data to convert to a query string.

  • [query] Array optional

    Existing name/value pairs to append on to this query.

getTypeByExtension

(
  • extension
)
String static

Determine the type of the object using common extensions. Note that the type can be passed in with the load item if it is an unusual extension.

Parameters:

  • extension String

    The file extension to use to determine the load type.

Returns:

String:

The determined load type (for example, AbstractLoader.IMAGE). Will return null if the type can not be determined by the extension.

isAudioTag

(
  • item
)
Boolean static

Defined in isAudioTag:224

Check if item is a valid HTMLAudioElement

Parameters:

Returns:

isBinary

(
  • type
)
Boolean static

Defined in isBinary:192

Determine if a specific type should be loaded as a binary file. Currently, only images and items marked specifically as "binary" are loaded as binary. Note that audio is not a binary type, as we can not play back using an audio tag if it is loaded as binary. Plugins can change the item type to binary to ensure they get a binary result to work with. Binary files are loaded using XHR2. Types are defined as static constants on AbstractLoader.

Parameters:

Returns:

Boolean:

If the specified type is binary.

isCrossDomain

(
  • item
)
Boolean static

Defined in isCrossDomain:159

Parameters:

Returns:

Boolean:

If the load item is loading from a different domain than the current location.

isImageTag

(
  • item
)
Boolean static

Defined in isImageTag:213

Check if item is a valid HTMLImageElement

Parameters:

Returns:

isLocal

(
  • item
)
Boolean static

Defined in isLocal:179

Parameters:

Returns:

Boolean:

If the load item is loading from the "file:" protocol. Assume that the host must be local as well.

isText

(
  • type
)
Boolean static

Defined in isText:254

Determine if a specific type is a text-based asset, and should be loaded as UTF-8.

Parameters:

Returns:

Boolean:

If the specified type is text.

isVideoTag

(
  • {Objectitem
)
Boolean static

Defined in isVideoTag:239

Check if item is a valid HTMLVideoElement

Parameters:

Returns:

parseURI

(
  • path
)
Object static

Defined in parseURI:67

Parse a file path to determine the information we need to work with it. Currently, PreloadJS needs to know:

  • If the path is absolute. Absolute paths start with a protocol (such as http://, file://, or //networkPath)
  • If the path is relative. Relative paths start with ../ or /path (or similar)
  • The file extension. This is determined by the filename with an extension. Query strings are dropped, and the file path is expected to follow the format name.ext.

Parameters:

Returns:

Object:

An Object with an absolute and relative Boolean values, as well as an optional 'extension` property, which is the lowercase extension.

Properties

ABSOLUTE_PATH

RegExp static

Defined in ABSOLUTE_PATH:42

The Regular Expression used to test file URLS for an absolute path.

EXTENSION_PATT

RegExp static

Defined in EXTENSION_PATT:58

The Regular Expression used to test file URLS for an extension. Note that URIs must already have the query string removed.

RELATIVE_PATH

RegExp static

Defined in RELATIVE_PATH:50

The Regular Expression used to test file URLS for a relative path.