Creates new instance of TadData class.
the location of the associated JSON data file in the Drafts iCloud files area.
// Example
objDataStore1 = new TadData("/Library/Scripts/ds1.json");
Add a numeric value to the value of the specified key, which can be expressed as a path.
Returns true
if the data file was successfully written, otherwise false
.
the period separated JSON-style path that uniquely identifies a key-value pair for the data object.
the number to add to the value.
// Example
objDataStore1.TA_addition("bar.foo", 10);
// This wll add 10 to the value associated with the key `foo` held within root key `bar`.
Delete a key value pair to file, where the key can be expressed as a path.
The key path will interpret periods as path separators (it isn't good practice to use periods in your
variable names in any case).
Returns true
if the data file was successfully written, otherwise false
.
Load data from file.
The location of the data files is specified during the class instance construction.
The data is merged into the class instance, but typically this would never need to be called at
any other time other than creation, and it is called as part of the construction process.
Returns true
if the file exists, otherwise false
.
// Example
objDataStore1 = new TadData("/Library/Scripts/ds1.json");
objDataStore1.TA_load();
Add a prefix to the value of the specified key, which can be expressed as a path.
Returns true
if the data file was successfully written, otherwise false
.
the period separated JSON-style path that uniquely identifies a key-value pair for the data object.
the text to add to the start of the value.
// Example
objDataStore1.TA_prefix("bar.foo", "baz");
// This wll prefix the value associated with the key `foo` held within root key `bar` with "baz".
Save a key value pair to file, where the key can be expressed as a path.
The key path will interpret periods as path separators (it isn't good practice to use periods in your
variable names in any case), and can build structures automatically.
Returns true
if the data file was successfully written, otherwise false
.
the period separated JSON-style path that uniquely identifies a key-value pair for the data object.
the value to set the property value to.
// Example
objDataStore1 = new TadData("/Library/Scripts/ds1.json");
objDataStore1.TA_save("foo", "bar");
objDataStore1.TA_save("bar.foo", "baz");
The resulting JSON will then look like this:
{
"foo" : "bar",
"bar" : {
"foo" : "baz"
},
"dataPath" : "\/Library\/Scripts\/ds1.json"
}
Store the current object properties in the instance's specified data file.
The data file location is specified by the object's dataPath
property, which is set at the construction
stage.
Returns true
if the file was successfully written, otherwise false
.
// Example
objDataStore1 = new TadData("/Library/Scripts/ds1.json");
objDataStore1.newValue = true;
objDataStore1.TA_store();
Deduct a numeric value from the value of the specified key, which can be expressed as a path.
Returns true
if the data file was successfully written, otherwise false
.
the period separated JSON-style path that uniquely identifies a key-value pair for the data object.
the number to subtract from the value.
// Example
objDataStore1.TA_subtraction("bar.foo", 5;
// This wll add 10 to the value associated with the key `foo` held within root key `bar`.
Add a suffix to the value of the specified key, which can be expressed as a path.
Returns true
if the data file was successfully written, otherwise false
.
the period separated JSON-style path that uniquely identifies a key-value pair for the data object.
the text to add to the end of the value.
// Example
objDataStore1.TA_suffix("bar.foo", "baz");
// This wll sufffix the value associated with the key `foo` held within root key `bar` with "baz".
Return the value of a key, which can be expressed as a path.
the period separated JSON-style path that uniquely identifies a key-value pair for the data object.
// Example
alert(objDataStore1.TA_value("bar.foo"));
// This wll return the value associated with the key `foo` held within root key `bar`.
TadData (Library)
This is a class that allows for the saving of data persistently. The data is stored in a JSON file in the Drafts iCloud area, meaning it is accessible across devices, and persists between runs of actions.