API Docs for: 2.2
Show:

MQ.Util Class

Extends L.Class

Utility class to aid MQ Leaflet plugins

Methods

cacheBust

() private

Function will return a string that is used in URL's indicate the server when the cache should and should not be used. example usage: var url = "http://url?cacheBust=" + MQ.IO.cacheBust();

doGetJSON

(
  • url
  • ioSettings
  • callback
)
private

Performs an HTTP GET of the given URL, returning the results as a JSON object to the callback.

Return value: The return value is a cancel function. If invoked, the request is cancelled.

The callback function takes one arg (the JSON response) on success. On failure, it takes arguments (false, errorInfo). errorInfo may be null and varies by the type of request made with ioSettings.

Parameters:

doJSONP

(
  • url
  • ioSettings
)

Injects a script tag into the dom with the src as the given url. It is intended to be used with services that support a callback param in the url, so that async calls can be done without cross-site domain security restrictions.

Parameters:

doJSONV

(
  • url
  • ioSettings
  • callback
)
private

Injects a script tag into the dom with the src as the given url. This is intended to be used with services that inject a varible into the dom as a result of the request. (GasPrices)

Parameters:

doPostJSON

(
  • url
  • requestObj
  • ioSettings
  • callback
)
private

Similar to doGetJSON but posts the request, serializing and sending the given requestObj as the post data. The content type is set to application/json

Parameters:

doXhr

(
  • url
  • ioSettings
  • xhrCallback
)
Function private

Perform an XHR get with the given URL and settings. The callback takes the parameters (xhr, errorInfo). errorInfo is an object if an error happened and is undefined/false if success. Returns an abort function.

Parameters:

  • url String

    the url we want to get data from

  • ioSettings Object

    the settings for the xhr request

  • xhrCallback Function

    the function to run on callback

Returns <Function>

an abort function

indexOf

(
  • haystack
  • needle
  • start
)
Number

deal with fact that ie8 doesn't support indexOf

Parameters:

Returns <Number>

loadCSS

(
  • text
)

Parameters:

parseJSON

(
  • jsonText
)
Object private

Parse JSON and return the resultant value. Return undefined on failure.

Parameters:

  • jsonText String

    the text that we want to convert to an object

Returns <Object>

the js object

quote

(
  • string
)
String private

If the string contains no control characters, no quote characters, and no backslash characters, then we can safely slap some quotes around it. Otherwise we must also replace the offending characters with safe escape sequences.

Parameters:

Returns <String>

the object converted to a string and wrapped in quotes

str

(
  • key
  • holder
)
String private

Produce a string based on the passed in variables

Parameters:

  • key String | Int

    the key to access the value in the holder

  • holder Object

    the object that we want to read through to produce strings

Returns <String>

the objects value converted to a string

stringifyJSON

(
  • obj
)
String private

The stringifyJSON method takes a value and returns as JSON text.

Parameters:

Returns <String>

the json string representing the object

toQueryString

(
  • obj
)
String private

Convert all non-default fields of the object to a query string format.

Parameters:

  • obj Object

    converts the object to a url query string

Returns <String>

the query string

xhr

() XMLHttpRequest | ActiveXObject private

Create and return an XMLHttpRequest object

Returns <XMLHttpRequest | ActiveXObject>