Class M.Environment
Extends
M.Object.
M.Environment encapsulates methods to retrieve information about the
environment, like browser used, platform, user agent (based on navigator
object) or whether or not the device is online (determined via an ajax
request).
Defined in: environment.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Method Attributes | Method Name and Description |
---|---|
Returns the browser version as received from navigator object.
|
|
getConnectionStatus(callback, url, timeout)
Checks the connection status by sending an ajax request
and waiting for the response to decide whether online or offline.
|
|
Returns the currently available height of the browser window.
|
|
Returns the platform as received from navigator object.
|
|
getSize()
Returns the currently available width and height of the browser window
as an array:
0 -> width
1 -> height
|
|
Returns the userAgent as received from navigator object.
|
|
getWidth()
Returns the currently available width of the browser window.
|
Method Detail
{String}
getBrowserName()
Returns the browser version as received from navigator object.
E.g. "5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7"
- Returns:
- {String} The user's browser.
getConnectionStatus(callback, url, timeout)
Checks the connection status by sending an ajax request
and waiting for the response to decide whether online or offline.
The callback is called when the request returns successful or times out. The parameter to callback is a
string saying either offline or online.
- Parameters:
- {function} callback
- The function to be called when request returns.
- {String} url
- Optional. The request url. When not given, a request is made to google.com. (Note: Add a proxy: /google)
- {Number} timeout
- Optional. Time in milliseconds until request is considered to be timed out. Defaults to 5 seconds.
{Number}
getHeight()
Returns the currently available height of the browser window.
- Returns:
- {Number} The height of the user's browser window.
{String}
getPlatform()
Returns the platform as received from navigator object.
E.g. "MacIntel"
- Returns:
- {String} The user's platform.
{Array}
getSize()
Returns the currently available width and height of the browser window
as an array:
0 -> width
1 -> height
- Returns:
- {Array} The widht and height of the user's browser window.
{String}
getUserAgent()
Returns the userAgent as received from navigator object.
E.g. "Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_5; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7"
- Returns:
- {String} The user agent.
{Number}
getWidth()
Returns the currently available width of the browser window.
- Returns:
- {Number} The width of the user's browser window.