Gadgets.util (v0.8)

From OpenSocial

Jump to: navigation, search
Image:Icon-50-alert.png This page is out of date. A more current version of this page is available at Gadgets.util (v0.9).
Image:Codesample.png 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.flash

gadgets.io

gadgets.json

gadgets.MiniMessage

gadgets.Prefs

gadgets.pubsub

gadgets.rpc

gadgets.skins

gadgets.Tab

gadgets.TabSet

gadgets.util

gadgets.views

gadgets.window

opensocial

opensocial.Activity

opensocial.Address

opensocial.BodyType

opensocial.Collection

opensocial.CreateActivityPriority

opensocial.DataRequest

opensocial.DataResponse

opensocial.Email

opensocial.Enum

opensocial.Environment

opensocial.EscapeType

opensocial.IdSpec

opensocial.MediaItem

opensocial.Message

opensocial.Name

opensocial.NavigationParameters

opensocial.Organization

opensocial.Permission

opensocial.Person

opensocial.Phone

opensocial.ResponseItem

opensocial.Url

Personal tools