Gadgets.Prefs (v0.9)
NeedsExamples
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. Example: var prefs = new gadgets.Prefs(); var name = prefs.getString("name"); var lang = prefs.getLang();
Methods
gadgets.Prefs.getArray
;Array.<String> getArray(key)
Parameters
NameTypeDescription |
key |
String |
The preference to fetch |
Returns
TypeDescription |
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
NameTypeDescription |
key |
String |
The preference to fetch |
Returns
TypeDescription |
Boolean |
The preference; if not set, false |
Description
Retrieves a preference as a boolean.
gadgets.Prefs.getCountry
;String getCountry()
Returns
TypeDescription |
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
NameTypeDescription |
key |
String |
The preference to fetch |
Returns
TypeDescription |
Number |
The preference; if not set, 0 |
Description
Retrieves a preference as a floating-point value.
gadgets.Prefs.getInt
;Number getInt(key)
Parameters
NameTypeDescription |
key |
String |
The preference to fetch |
Returns
TypeDescription |
Number |
The preference; if not set, 0 |
Description
Retrieves a preference as an integer.
gadgets.Prefs.getLang
;String getLang()
Returns
TypeDescription |
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
TypeDescription |
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
NameTypeDescription |
key |
String |
The message to fetch |
Returns
TypeDescription |
String |
The message |
Description
Fetches an unformatted message.
gadgets.Prefs.getString
;String getString(key)
Parameters
NameTypeDescription |
key |
String |
The preference to fetch |
Returns
TypeDescription |
String |
The preference; if not set, an empty string |
Description
Retrieves a preference as a string.
gadgets.Prefs.set
;set(key, val)
Parameters
NameTypeDescription |
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
NameTypeDescription |
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.
{{ JsApiAlphaList_(v0.9) }}