The fwlib/prefs
module includes utility functions for working with
Fireworks preferences files. By storing your persistent data as JSON
strings, these utility functions make it easy to save and retrieve
information for your commands across Fireworks sessions.
- Source:
- lib/fwlib/prefs.js, line 5
Requires
- module:dojo/json
Classes
Methods
-
<static> get
-
Returns the value of a preference setting. This function assumes that any existing data in the preference is a JSON string, and it will return the evaluated result of that JSON. If the preference doesn't currently exist, or its value throws an error when evaluated, an empty object will be returned.
The
inName
parameter should be a globally unique name for the preference. To avoid collisions, try using the name of your extension plus your initials, or a reverse domain name likecom.example.MyExtension
.You can pass in an object as the optional second parameter to provide default properties for the preference data. The defaults will not override any existing properties on the saved preference data:
var settings = prefs.get("MyPref", { foo: 42 }); alert(settings.foo); // 42 settings.foo = "bar"; prefs.set("MyPref", settings); settings = prefs.get("MyPref", { foo: 42 }); alert(settings.foo); // "bar"
Parameters:
Name Type Argument Default Description inName
String The name of the preference.
inDefaults
Object <optional>
null An optional object containing default properties that will be added to the stored preference data, if any.
- Source:
- lib/fwlib/prefs.js, line 59
Returns:
The evaluated JS value of the preference.
- Type
- Object
-
<static> set
-
Stores some data in the Fireworks preferences file as a JSON string. The data passed in as
inPrefs
is automatically converted to JSON.Parameters:
Name Type Description inName
String The name of the preference.
inPrefs
Object The value of the preference.
- Source:
- lib/fwlib/prefs.js, line 98