Versions Compared
compared with
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Comment:
Migrated to Confluence 5.3
Excerpt |
---|
Returns true Check if a dependency is available, otherwise falsetry and load it if not, return availability state... |
Syntax
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
if (uHas(filevar available = Check.has(file[, ver)) { // do something that needs that file } else { // do it a different way }[, lazy]]) |
Parameters
Parameter | Type | Mandatory | Notes | Util.js version | |||
---|---|---|---|---|---|---|---|
file | String | Filename of dependency | 1.0.8 | ||||
ver | Number | Minimum version of that file | 0.8 Constant | Specify the required version of the file (exact match) or a version constant:
Default: Check.ANY_VERSION For more information on autolaoding, see: Check.paths[]. | 1.0 | ||
lazy | Constant | By default, Check.has() will attempt to autoload missing dependencies. If you want to prevent autoloading, specify Check.LAZY_LOAD | 1.0 |
Return Values
Value | Type | Notes | Util.js version | ||||
---|---|---|---|---|---|---|---|
true | Boolean | Indicates the file (and optionally version) are available. | 0.8The dependency check was successful. | 1.0 | |||
false | Boolean | Either:
| 0.8 The dependency check failed. | 1.0 | |||
<error> | Error | Something unexpected happenedAn error occurred, most likely invalid parameters. | 0.8 | <object> | Object | Object with named properties (file names) and numeric values (versions) of all provided libraries. See "Notes" below for more information. | 1.0 |
Example
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
function bleh() { if (uHasCheck.has("foo.js",0 1.32)) { // do it the foo.js v0.3 or higher wayv1.2 way } else { // do it without any foo } else} |
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
function bleh() { if (uHasCheck.has("foo.js", 1.2, Check.LAZY_LOAD)) { // do it the foo.js v0v1.2 or earlier way } else { // do it without usingany foo.js } } |
Notes
You can get a list of all provided dependencies using using Util API diagnostics (requires Diag API Diagnostics or by calling uHas() without any parameters.
Div | ||||||
---|---|---|---|---|---|---|
| ||||||
Availability
Requires:
|
Div | ||||
---|---|---|---|---|
| ||||
See AlsoRelated functions: childrenContentsJump to:
|
Div | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
Dependency CheckingTopics:
|