Namespace: AttributesCodec

AttributesCodec

Methods

(static) getDecodedAttributes(encodedAttributes) → {Attributes}

A function to parse the attributes string for a domain into an object of the Attributes class.

Parameters:
Name Type Description
encodedAttributes string The encoded attribute string, of the form , where any number of the three may be empty. This format is chosen to eliminate storing redundant information for a domain when a cetain attribute is identical to the one produced by the default algorithm.
Source:
Returns:
The decoded object. If decoding fails, a default initialized object is returned.
Type
Attributes

(static) getDecodedAttributesList(encodedAttributesList) → {object}

A function to parse the string representing the list of site attributes stored in the browser preferences system.

Parameters:
Name Type Description
encodedAttributesList string The encoded string containing a stringified version of the JSON object representing the (domain, encoded Attributes) pair.
Source:
Returns:
A JSON of key-value pairs with site domain as key and site attributes (in compact string form) as value. Values are of the form , where at most two of those may be empty.
Type
object

(static) getEncodedAttributes(savedAttributes, proposedAttributes, attributes) → {string}

A function to encode an "Attributes" object to the form for storage in the browser preferences system. Attributes that are reproducible by the default algorithm will be skipped for efficient storage (since sync space is precious). However, if a previously overridden attribute is reset to the default value, it will still be saved, since this module can only compare differences and does not know about defaults.

Parameters:
Name Type Description
savedAttributes Attributes The existing saved attributes for a domain (default if none existed).
proposedAttributes Attributes The proposed attributes following the application of the algorithm on the saved/default attributes.
attributes Attributes The actual attributes that were captured from the UI when the user hit "Generate", which will encompass any custom changes the user made.
Source:
Returns:
The encoded attributes to save, if asked so.
Type
string

(static) getEncodedAttributesList(domain, siteAttributesList) → {string}

A function to encode the JSON (domain, encodedAttributes) object to the string used for storage in the browser preference system. The format is just the JSON stringification of the object.

Parameters:
Name Type Description
domain string The site domain.
siteAttributesList object A JSON (domain, encodedAttributes) representing existing saved attributes in the browser's preference system.
Source:
Returns:
The encoded list of attributes.
Type
string

(static) getSavedAttributes(domain, savedAttributesList) → {Attributes}

A function to obtain the saved "Attributes" object corresonding to a site domain.

Parameters:
Name Type Description
domain string The site domain to obtain the saved attributes for.
savedAttributesList object The JSON object containing (domain, encoded Attributes) pairs.
Source:
Returns:
The saved attributes. If no saved attributes exist, a default initialized object is returned.
Type
Attributes

AttributesCodec

Source:

Methods

(static) getDecodedAttributes(encodedAttributes) → {Attributes}

A function to parse the attributes string for a domain into an object of the Attributes class.

Parameters:
Name Type Description
encodedAttributes string The encoded attribute string, of the form , where any number of the three may be empty. This format is chosen to eliminate storing redundant information for a domain when a cetain attribute is identical to the one produced by the default algorithm.
Source:
Returns:
The decoded object. If decoding fails, a default initialized object is returned.
Type
Attributes

(static) getDecodedAttributesList(encodedAttributesList) → {object}

A function to parse the string representing the list of site attributes stored in the browser preferences system.

Parameters:
Name Type Description
encodedAttributesList string The encoded string containing a stringified version of the JSON object representing the (domain, encoded Attributes) pair.
Source:
Returns:
A JSON of key-value pairs with site domain as key and site attributes (in compact string form) as value. Values are of the form , where at most two of those may be empty.
Type
object

(static) getEncodedAttributes(savedAttributes, proposedAttributes, attributes) → {string}

A function to encode an "Attributes" object to the form for storage in the browser preferences system. Attributes that are reproducible by the default algorithm will be skipped for efficient storage (since sync space is precious). However, if a previously overridden attribute is reset to the default value, it will still be saved, since this module can only compare differences and does not know about defaults.

Parameters:
Name Type Description
savedAttributes Attributes The existing saved attributes for a domain (default if none existed).
proposedAttributes Attributes The proposed attributes following the application of the algorithm on the saved/default attributes.
attributes Attributes The actual attributes that were captured from the UI when the user hit "Generate", which will encompass any custom changes the user made.
Source:
Returns:
The encoded attributes to save, if asked so.
Type
string

(static) getEncodedAttributesList(domain, siteAttributesList) → {string}

A function to encode the JSON (domain, encodedAttributes) object to the string used for storage in the browser preference system. The format is just the JSON stringification of the object.

Parameters:
Name Type Description
domain string The site domain.
siteAttributesList object A JSON (domain, encodedAttributes) representing existing saved attributes in the browser's preference system.
Source:
Returns:
The encoded list of attributes.
Type
string

(static) getSavedAttributes(domain, savedAttributesList) → {Attributes}

A function to obtain the saved "Attributes" object corresonding to a site domain.

Parameters:
Name Type Description
domain string The site domain to obtain the saved attributes for.
savedAttributesList object The JSON object containing (domain, encoded Attributes) pairs.
Source:
Returns:
The saved attributes. If no saved attributes exist, a default initialized object is returned.
Type
Attributes