Namespace: core

core

Most of these are used internally as helper functions and using them directly is often not necessary.

Source:

Members

settings :object

Vorple and story settings.

Type:
  • object
Source:

Methods

engine(name) → {string|boolean|null}

Checks which engine is running the story under the hood (Undum or Parchment).

Parameters:
Name Type Argument Description
name string <optional>

Name of an engine to check, in lowercase ("undum" or "parchment"). True is returned if we're using this engine.

Source:
Returns:

The name of the current engine in lowercase, null if no engine is loaded or false if the engine is unknown.

When testing for a specific engine, true or false is returned.

Type
string | boolean | null

generateId(length) → {string}

Generates a random unique id composed of letters and numbers [1-9a-zA-Z].
The first character is never a number.

Parameters:
Name Type Argument Default Description
length number <optional>
32

The length of the generated id

Source:
Returns:

The generated id

Type
string

getEngine() → {object}

Returns the engine object.

Since:
  • 2.5
Source:
Returns:
Type
object

getVersion() → {string}

Returns the current version number.

Since:
  • 2.5
Source:
Returns:
Type
string

init(system)

Initialize and start Vorple.

A custom event 'init.vorple' is triggered after the core initialization has been done. Custom initialization functions can be added using a listener:

$( document ).on( 'init.vorple', function() {
    console.log( 'Vorple started!' );
});
Parameters:
Name Type Argument Description
system object <optional>

The engine running the story

Source:

requireVersion(requiredVersion, message) → {boolean}

Require a certain version of the Vorple library.

The accuracy of the check depends on the given parameter. Exact version number is assumed, except for parts of the version number that are omitted. For example if the actual current version number is 2.4.1, then:

vorple.core.requireVersion( "2" )      =>  true
vorple.core.requireVersion( "2.4" )    =>  true
vorple.core.requireVersion( "2.4.1" )  =>  true
vorple.core.requireVersion( "1" )      =>  error
vorple.core.requireVersion( "2.3" )    =>  error
vorple.core.requireVersion( "2.4.0" )  =>  error
vorple.core.requireVersion( "2.4.2" )  =>  error

The version number can be given as an array of two version numbers. The version number is then required to be inside the given range (inclusive).

An error is thrown if the current version does not fit within the bounds. A second parameter can be given that contains the error message, or a function that will be called instead of throwing the error.

Parameters:
Name Type Argument Description
requiredVersion string | number | array

The exact allowed version or an array of [lowest, highest] required version

message string | function <optional>

The error message's text or a function to call on error

Since:
  • 2.5
Source:
Returns:

True if version number is within bounds

Type
boolean
Vorple Copyright © 2011-2014 the Vorple project
Documentation generated by JSDoc 3.2.2 on Wed May 07 2014 14:47:40 GMT+0300 (EEST) using the DocStrap template.