Gadgets.util (v0.8)
From OpenSocial
| This page is out of date. A more current version of this page is available at Gadgets.util (v0.9). |
![]() |
This page has example code which needs to be improved. Please help improve this page by fixing existing code or writing additional examples. (November 2008) |
Contents |
gadgets.util
Provides general-purpose utility functions.
Methods
gadgets.util.escapeString
gadgets.util.escapeString(str)- Escapes the input using HTML entities to make it safer. The following characters are affected:
- newline (\n, Unicode code point 10)
- carriage return (\r, Unicode 13)
- double quote (", Unicode 34)
- ampersand (&, Unicode 38)
- single quote (', Unicode 39)
- left angle bracket (<, Unicode 60)
- right angle bracket (>, Unicode 62)
- backslash (\, Unicode 92)
- line separator (Unicode 8232)
- paragraph separator (Unicode 8233)
- Parameters
String str- The string to escape- Returns
String- The escaped string
gadgets.util.getFeatureParameters
gadgets.util.getFeatureParameters(feature)- Returns the value of parameters for this feature. A gadget specifies parameters using the <Param> subelement of the <Requires> or <Optional> element.
- Parameters
String feature- The feature to get parameters for- Returns
Object- The parameters for the given feature, or null
gadgets.util.hasFeature
gadgets.util.hasFeature(feature)- Returns whether the specified feature is supported.
- Parameters
String feature- The feature to test for- Returns
Boolean- True if the feature is supported
gadgets.util.registerOnLoadHandler
gadgets.util.registerOnLoadHandler(callback)- Registers an onload handler — a function that's executed when the gadget loads.
- Parameters
Function callback- The handler to run- Returns
- None
Examples
gadgets.util.registerOnLoadHandler(init); function init() { alert('Hello, World!'); }
gadgets.util.unescapeString
gadgets.util.unescapeString(str)- Reverses escapeString
- Parameters
String str- The string to unescape.- Returns
String- The unescaped string
gadgets.util.sanitizeHtml
gadgets.util.sanitizeHtml(text)- Parameters
String text- arbitrary text string- Returns
String- a sanitized version that may include HTML tags, but will not execute script.
Examples
example goes here
|
OpenSocial 0.8 |
|||
|
gadgets.util |
|||

