Skip to content

Latest commit

History

History
executable file
266 lines (222 loc) 路 8.44 KB

PUBLIC_FUNCTIONS.md

File metadata and controls

executable file
266 lines (222 loc) 路 8.44 KB

JHson.js - Public Functions:

Below is a list of all the public functions that can be called from the JHson.js instance.

Binding:

renderAll():

Finds all the elements with the correct binding attribute and renders the JSON as HTML.
Returns: 'Object' - The JHson.js class instance.

JSON:

json():

Returns all the chained functions that will allow an HTML DOM element to be converted to JSON.
Returns: 'Object' - The JSON properties object.

json() > includeAttributes( flag ):

States if the attributes should be included.
Parameter: flag: 'boolean' - The boolean flag that states the condition (defaults to true).
Returns: 'Object' - The JSON properties object.

json() > includeCssProperties( flag ):

States if the CSS style properties should be included.
Parameter: flag: 'boolean' - The boolean flag that states the condition (defaults to false).
Returns: 'Object' - The JSON properties object.

json() > includeText( flag ):

States if the node text should be included.
Parameter: flag: 'boolean' - The boolean flag that states the condition (defaults to true).
Returns: 'Object' - The JSON properties object.

json() > includeChildren( flag ):

States if the children should be included.
Parameter: flag: 'boolean' - The boolean flag that states the condition (defaults to true).
Returns: 'Object' - The JSON properties object.

json() > friendlyFormat( flag ):

States if the JSON should be formatted in an easy-to-read layout.
Parameter: flag: 'boolean' - The boolean flag that states the condition (defaults to true).
Returns: 'Object' - The JSON properties object.

json() > indentSpaces( spaces ):

States the total indent spaces that should be used for the friendly format JSON.
Parameter: spaces: 'number' - The spaces value that should be used (defaults to 2).
Returns: 'Object' - The JSON properties object.

json() > ignoreNodeTypes( types ):

States the node types that should not be included in the JSON.
Parameter: types: 'Object' - The node types to ignore (can be an array of strings, or a space-separated string, and defaults to []).
Returns: 'Object' - The JSON properties object.

json() > ignoreCssProperties( cssProperties ):

States the CSS properties that should not be included in the JSON.
Parameter: cssProperties: 'Object' - The CSS properties to ignore (can be an array of strings, or a space-separated string, and defaults to []).
Returns: 'Object' - The JSON properties object.

json() > ignoreAttributes( attributes ):

States the attributes that should not be included in the JSON.
Parameter: attributes: 'Object' - The attributes to ignore (can be an array of strings, or a space-separated string, and defaults to []).
Returns: 'Object' - The JSON properties object.

json() > generateUniqueMissingIds( flag ):

States if the JSON should include unique IDs for DOM elements that don't have them set already.
Parameter: flag: 'boolean' - The boolean flag that states the condition (defaults to true).
Returns: 'Object' - The JSON properties object.

json() > get( element ):

Uses all the options selected via the chained functions to get the JSON from the HTML DOM element.
Parameter: element: 'Object' - The DOM element to get the JSON for.
Returns: 'string' - The JSON string.

json() > getVariables( json ):

Uses all the options selected via the chained functions to get the template variables from a JSON string.
Parameter: json: 'string' - The JSON to get the template variables from.
Returns: 'string[]' - The template variables.

HTML:

html():

Returns all the chained functions that will allow JSON to be written as HTML DOM elements.
Returns: 'Object' - The HTML properties object.

html() > json( json ):

States the JSON that should be written as HTML DOM elements.
Parameter: json: 'string' - The JSON that should be converted to HTML.
Returns: 'Object' - The HTML properties object.

html() > templateData( templateData ):

States the template data that should be used inside each HTML DOM elements HTML.
Parameter: templateData: 'Object' - The template data to set inside each node's HTML.
Returns: 'Object' - The HTML properties object.

html() > removeOriginalAttributes( flag ):

States if the original attributes on the element should be removed.
Parameter: flag: 'boolean' - The boolean flag that states the condition (defaults to true).
Returns: 'Object' - The HTML properties object.

html() > clearOriginalHTML( flag ):

States if the original HTML in the element should be cleared.
Parameter: flag: 'boolean' - The boolean flag that states the condition (defaults to true).
Returns: 'Object' - The HTML properties object.

html() > addCssToHead( flag ):

States if the CSS style properties should be written to a "style" tag in the HTML documents HEAD DOM element.
Parameter: flag: 'boolean' - The boolean flag that states the condition (defaults to false).
Returns: 'Object' - The HTML properties object.

html() > clearCssFromHead( flag ):

States if all the CSS style tags should be cleared from the HTML documents HEAD DOM element.
Parameter: flag: 'boolean' - The boolean flag that states the condition (defaults to false).
Returns: 'Object' - The HTML properties object.

html() > logTemplateDataWarnings( flag ):

States if the template data variables not found in any data are logged as warnings.
Parameter: flag: 'boolean' - The boolean flag that states the condition (defaults to false).
Returns: 'Object' - The HTML properties object.

html() > addAttributes( flag ):

States if the attributes should be written for each element.
Parameter: flag: 'boolean' - The boolean flag that states the condition (defaults to true).
Returns: 'Object' - The HTML properties object.

html() > addCssProperties( flag ):

States if the CSS properties should be written for each element.
Parameter: flag: 'boolean' - The boolean flag that states the condition (defaults to true).
Returns: 'Object' - The HTML properties object.

html() > addText( flag ):

States if the text should be written for each element.
Parameter: flag: 'boolean' - The boolean flag that states the condition (defaults to true).
Returns: 'Object' - The HTML properties object.

html() > addChildren( flag ):

States if the children should be written for each element.
Parameter: flag: 'boolean' - The boolean flag that states the condition (defaults to true).
Returns: 'Object' - The HTML properties object.

html() > write( element ):

Uses all the options selected via the chained functions to convert the JSON into HTML DOM elements.
Parameter: element: 'Object' - The DOM element to add the new JSON HTML nodes to.
Returns: 'Object' - The JHson.js class instance.

html() > getVariables( element ):

Uses all the options selected via the chained functions to get the template variables from a HTML DOM element.
Parameter: element: 'Object' - The DOM element to get the template variables from.
Returns: 'string[]' - The template variables.

Configuration:

setConfiguration( newConfiguration ):

Sets the specific configuration options that should be used.
Parameter: newConfiguration: 'Object' - All the configuration options that should be set (refer to "Configuration Options" documentation for properties).
Returns: 'Object' - The JHson.js class instance.

Additional Data:

getVersion():

Returns the version of JHson.js.
Returns: 'string' - The version number.

Example:

<script> 
    var version = $jhson.getVersion();
</script>