Class SpazPrefs

SpazPrefs

Defined in: spazprefs.js.

Class Summary
Constructor Attributes Constructor Name and Description
 
SpazPrefs(defaults, sanity_methods, sanity_methods)

A preferences lib for AIR JS apps.

Method Summary
Method Attributes Method Name and Description
 
get(key, encrypted)

Get a preference Note that undefined is returned if the key does not exist

 

get an encrypted preference

 
load(name)

loads the prefs file and parses the prefs into this._prefs, or initializes the file and loads the defaults

 

resets all prefs to defaults and saves

 
save()

saves the current preferences

 
set(key, val, encrypted)

set a preference and save automatically

 
setDefaults(defaults)

sets the passed object of key:val pairs as the default preferences

 
setEncrypted(key, val)

Sets an encrypted pref

 
setSanityMethod(key, type, method)

Class Detail

SpazPrefs(defaults, sanity_methods, sanity_methods)

A preferences lib for AIR JS apps. This requires the json2.js library

Parameters:
{object} defaults
a JS object of key:value pairs used for the pref defaults. Example: { foo:124545, bar:'Hello!', boo:false };
{object} sanity_methods
a JS object of key:object pairs that defines methods to be called when the pref is get() or set(). Example: { foo:{ onGet:function(key, value) {}; onSet:function(key, value) {}; }, bar:{ onGet:function(key, value) {}; onSet:function(key, value) {}; } } events raised: 'spazprefs_loaded'
sanity_methods
Method Detail

get(key, encrypted)

Get a preference Note that undefined is returned if the key does not exist

Parameters:
key
encrypted

getEncrypted(key)

get an encrypted preference

Parameters:
key

load(name)

loads the prefs file and parses the prefs into this._prefs, or initializes the file and loads the defaults

Parameters:
name

resetPrefs()

resets all prefs to defaults and saves

save()

saves the current preferences

set(key, val, encrypted)

set a preference and save automatically

Parameters:
key
val
encrypted

setDefaults(defaults)

sets the passed object of key:val pairs as the default preferences

Parameters:
{object} defaults

setEncrypted(key, val)

Sets an encrypted pref

Parameters:
key
val

setSanityMethod(key, type, method)

Parameters:
{string} key
the name of the pref
{string} type
the type of method. Currently either 'onGet' or 'onSet'
{function} method
the method definition