Scalar 2 User's Guide

ScalarNode

The ScalarNode class represents a single node of a Scalar book.

Methods

MethodTypeDescription
getDisplayTitle( removeMarkup )stringReturns the title of the node, formatted for display. If the removeMarkup parameter is true, HTML markup will be removed from the title.
getDominantScalarType()objectReturns an object literal describing the most specialized type associated with the node— for example: while every path is also a page, this method will only return the “path” object for nodes that are paths.
getRelatedNodes( type, direction, [includeNonPages], [sort] )array

Returns an array of ScalarNode objects related to the node by the specified criteria.

Method parameters:

  • type (string) - The type of relationship to match. Possible values include “annotation”, “path”, “reply” (i.e. comment), and “tag”.

  • direction (string) - The direction of the relationship relative to this node, either “outgoing” or “incoming”.

  • includeNonPages (boolean) - If true, will include non-page nodes (like authors, for example) in the results.

  • sort (string) - Sort method to be applied to the results. Available options are “index”, which returns results in their author-specified order, “reverseindex”, which reverses the author-specified order of the results, and “alphabetical”, which sorts the results by title.
getRelations( type, direction, [sort], [includeNonPages] )array

Returns an array of ScalarRelation objects related to the node by the specified criteria.

Method parameters:

  • type (string) - The type of relationship to match. Possible values include “annotation”, “path”, “reply” (i.e. comment), and “tag”.

  • direction (string) - The direction of the relationship relative to this node, either “outgoing” or “incoming”.

  • sort (string) - Sort method to be applied to the results. Available options are “index”, which returns results in their author-specified order, or “reverseindex” which reverses the author-specified order of the results.

  • includeNonPages (boolean) - If true, will include non-page nodes (like authors, for example) in the results.
getSortTitle()stringReturns the title of the node, formatted for alphabetical sorting (i.e. with initial non-alphabetic components like the word “the” removed). Normally used for internal processing of arrays of nodes.
hasScalarType( typeName )booleanReturns true if any of the Scalar types associated with the node match the specified type name.
 

Properties

PropertyTypeDescription
colorstringThe HTML color associated with this node.
currentScalarVersionThe most current known ScalarVersion associated with the node.
dataobjectThe raw JSON data for the node.
defaultViewstringThe name of the default view associated with this node.
incomingRelationsarrayAn array of ScalarRelation objects describing the node’s incoming relationships.
outgoingRelationsarrayAn array of ScalarRelation objects describing the node’s outgoing relationships.
propertiesobjectAll known properties associated with the node.
scalarTypesarrayAn array of objects describing all of the Scalar types this node is a member of.
slugstringThe unique URI segment that identifies the node within the current book.
thumbnailstringThe URL of the thumbnail image associated with this node.
urlstringThe URL of the node.
versionsarrayAn array of all known ScalarVersions associated with the node.

This page has paths: