Gadgets.Prefs (v0.9)

From VZ Developer Wiki
Revision as of 13:03, 30 July 2010 by Seba (talk | contribs)
Jump to: navigation, search

This documentation is not completed yet and will be extended by more examples in future.

gadgets.Prefs

Provides access to user preferences, module dimensions, and messages. Clients can access their preferences by constructing an instance of gadgets.Prefs and passing in their module ID.

You should only save a maximum of 2kB per User as Preferences data. Currently we do not supper the datatype=”list” (array).

Example: <figure> <artwork xml:space="preserve"> var prefs = new gadgets.Prefs(); var name = prefs.getString("name"); var lang = prefs.getLang(); </artwork> </figure>

Methods

gadgets.Prefs.getArray

Array.<String> getArray(key)
Parameters
Name Type Description
key String The preference to fetch
Returns
Type Description
Array.<String> The preference; if not set, an empty array
Description
Retrieves a preference as an array. UserPref values that were not declared as lists are treated as one-element arrays.

gadgets.Prefs.getBool

Boolean getBool(key)
Parameters
Name Type Description
key String The preference to fetch
Returns
Type Description
Boolean The preference; if not set, false
Description
Retrieves a preference as a boolean.

gadgets.Prefs.getCountry

String getCountry()
Returns
Type Description
String The country for this module instance
Description
Gets the current country, returned as ISO 3166-1 alpha-2 code.

gadgets.Prefs.getFloat

Number getFloat(key)
Parameters
Name Type Description
key String The preference to fetch
Returns
Type Description
Number The preference; if not set, 0
Description
Retrieves a preference as a floating-point value.

gadgets.Prefs.getInt

Number getInt(key)
Parameters
Name Type Description
key String The preference to fetch
Returns
Type Description
Number The preference; if not set, 0
Description
Retrieves a preference as an integer.

gadgets.Prefs.getLang

String getLang()
Returns
Type Description
String The language for this module instance
Description
Gets the current language the gadget should use when rendering, returned as a ISO 639-1 language code.

gadgets.Prefs.getModuleId

String | Number getModuleId()
Returns
Type Description
String | Number The module ID for this module instance
Description
Gets the module ID for the current instance.

gadgets.Prefs.getMsg

String getMsg(key)
Parameters
Name Type Description
key String The message to fetch
Returns
Type Description
String The message
Description
Fetches an unformatted message.

gadgets.Prefs.getString

String getString(key)
Parameters
Name Type Description
key String The preference to fetch
Returns
Type Description
String The preference; if not set, an empty string
Description
Retrieves a preference as a string.

gadgets.Prefs.set

set(key, val)
Parameters
Name Type Description
key String The pref to store
val Object The values to store
Description
Stores a preference. To use this call, the gadget must require the feature setprefs.

Note: If the gadget needs to store an Array it should use setArray instead of this call.

gadgets.Prefs.setArray

setArray(key, val)
Parameters
Name Type Description
key String The pref to store
val Array The values to store
Description
Stores an array preference of custom essay writing services. To use this call, the gadget must require the feature setprefs.



OpenSocial (v0.9)

gadgets

gadgets.io

gadgets.json

gadgets.Prefs

gadgets.util

gadgets.views

gadgets.flash

gadgets.MiniMessage

gadgets.oauth.Popup

gadgets.rpc

gadgets.skins

gadgets.pubsub

gadgets.Tab

gadgets.TabSet

gadgets.window

gadgets.i18n

opensocial

opensocial.Activity

opensocial.Address

opensocial.Album

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.MessageCollection

opensocial.Name

opensocial.NavigationParameters

opensocial.Organization

opensocial.Permission

opensocial.Person

opensocial.Phone

opensocial.ResponseItem

opensocial.Url

osapi.Request

osapi.BatchRequest

osapi.people

osapi.activities

osapi.appdata

osapi.messages

osapi.http