Sign in or register
for additional privileges

Scalar 1 User’s Guide

Previous page on path     Next page on path

 

You appear to be using an older verion of Internet Explorer. For the best experience please upgrade your IE version or switch to a another web browser.

ScalarAPI

The primary class in the Scalar API JavaScript library. Once the Scalar API JavaScript library is loaded, the ScalarAPI object is available through the globally-scoped variable “scalarapi”.

Methods


MethodReturn valueDescription
getNode( uriOrSlug:string )ScalarNode
Returns the ScalarNode in the current book identified by the specified URI or URI segment (also known as the “slug”), or null if no matching ScalarNode can be found.
loadBook( forceReload:boolean, successCallback:function, errorCallback:function )string

Load data about the current Scalar book. Returns a string indicating the current state of the request, whose possible values are “loading”, “queued”, or “loaded”.

Method parameters:
  • forceReload - If true, any cached data for the book will be ignored, and a new request will be executed. If false, the method will return the string “loaded” if data for the book already exists.
  • successCallback - A function to be executed when the request is completed successfully.
  • errorCallback - A function to be executed when the request fails.
loadNode( uriSegment:string, forceReload:boolean, successCallback:function, errorCallback:function, depth:number, references:boolean, relation:string, start:number, results:number )string

Loads data about the specified Scalar node in the current book. Returns a string indicating the current state of the request, whose possible values are “loading”, “queued”, or “loaded”.

Method parameters:
  • uriSegment - The identifying URI segment (also known as the “slug”) for the node. For the home page of a Scalar book, this would be “index”.

  • forceReload - If true, any cached data for the node will be ignored, and a new request will be executed. If false, the method will return the string “loaded” if data for the requested node already exists.

  • successCallback - A function to be executed when the request is completed successfully.

  • errorCallback - A function to be executed when the request fails.

  • depth - The number of degrees of separation between the requested node and any related nodes that should also be returned with this request. Higher numbers will result in longer load times; use with caution. Defaults to 0.

  • references - If true, will return Scalar media linked from within the text of the requested node, if any. Defaults to false.

  • relation - If not null, will only return nodes related to the requested node through the named relationship. Defaults to null, which returns nodes related through any relationship. Other possible values include “annotation”, “path”, “reply” (i.e. comment), and “tag”.

  • start - If specified, indicates the zero-based index of the first result to be returned.

  • results - If specified, indicates the maximum number of results to be returned.
loadNodesByType( type:string, forceReload:boolean, successCallback:function, errorCallback:function, depth:number, references:boolean, relation:string, start:number, results:number )string

Loads all nodes of the specified type from the current Scalar book. Returns a string indicating the current state of the request, whose possible values are “loading” or “loaded”.

Method parameters:
  • type - The type of ScalarNode to be retrieved. Possible values include “annotation”, “content” (i.e. all types—use with caution), “media”, “page”, “path”, “reply” (i.e. comment), or “tag”.

  • forceReload - If true, any cached data for the nodes will be ignored, and a new request will be executed. If false, the method will return the string “loaded” if data for the type of nodes requested already exists.

  • successCallback - A function to be executed when the request is completed successfully.

  • errorCallback - A function to be executed when the request fails.

  • depth - The number of degrees of separation between the requested nodes and any related nodes that should also be returned with this request. Higher numbers will result in longer load times; use with caution. Defaults to 0.

  • references - If true, will return Scalar media linked from within the text of the requested nodes, if any. Defaults to false.

  • relation - If not null, will only return nodes related to the requested nodes through the named relationship. Defaults to null, which returns nodes related through any relationship. Other possible values include “annotation”, “path”, “reply” (i.e. comment), and “tag”.

  • start - If specified, indicates the zero-based index of the first result to be returned.

  • results - If specified, indicates the maximum number of results to be returned.
nodeSearch( sq:string, successCallback:function, errorCallback:function, depth:number, references:boolean, relation:string, start:number, results:number )none

Loads all nodes matching the specified search query from the current Scalar book.

Method parameters:
  • sq - The search query to be executed.

  • successCallback - A function to be executed when the request is completed successfully.

  • errorCallback - A function to be executed when the request fails.

  • depth - The number of degrees of separation between the requested nodes and any related nodes that should also be returned with this request. Higher numbers will result in longer load times; use with caution. Defaults to 0.

  • references - If true, will return Scalar media linked from within the text of the requested nodes, if any. Defaults to false.

  • relation - If not null, will only return nodes related to the requested nodes through the named relationship. Defaults to null, which returns nodes related through any relationship. Other possible values include “annotation”, “path”, “reply” (i.e. comment), and “tag”.

  • start - If specified, indicates the zero-based index of the first result to be returned.

  • results - If specified, indicates the maximum number of results to be returned.
setBook( scalarURL:string )noneSets the Scalar book referenced in the specified URI to be the target of future API requests.

Properties


PropertyTypeDescription
modelScalarModel
Object containing all nodes for which the client has received data.
Comment on this page
 

Discussion of "ScalarAPI"

Add your voice to this discussion.

Checking your signed in status ...

Previous page on path Scalar API JavaScript library reference, page 1 of 5 Next page on path