Global Functions

Global functions are only available when using FancyPants JavaScript in the standalone environment. These functions are not available when using the FancyPants web broswer plugin.

fp_init

Description

fp_init() is the API used to initialize FancyPants SDK. Only a single instance can be obtained and calling this API multiple times will return the same instance each time.

Input Parameters

None

Return Values

Instance of Fp class allow subsequent FancyPants operations to be possible.

Example

var fp = fp_init();

fp_acquire

Description

fp_acquire() is the API used to acquire an instance of a specific FancyPants module. When calling fp_acquire() with ā€œfpā€ as the module, the API will return an instance of the Fp class, therefore fp_init() must have been called prior to this and this API returns null if FancyPants has not been initialized. This call is useful within the theme system where often an instance of the Fp is required for added effects.

Input Parameters

Parameter Type Description
module string The instance of the module to acquire

Return Values

Instance of specified module

Example

var fp = fp_acquire("fp");

include

Description

As JavaScript has no predefined function to include another JavaScript file, we have provided the include() API allowing developers to organize their code into different files for easier management.

Calling this API also triggers the specified JavaScript file to be compiled and evaluated.

Input Parameter

Parameter Type Description
module string The JavaScript file to include

Return Values

The evaluated result of the specified JavaScript file, or false in case the file cannot be found.

Environment

The environment variable FP_JS_INCLUDE_PATH is searched for the file to include. The syntax for the FP_JS_INCLUDE_PATH environment variable is as follows:

export FP_JS_INCLUDE_PATH=ā€<path>:<other path>:<3rd path>ā€

Example

include("file.js");

print

Description

As JavaScript has no predefined function to print text on the console, we have provided the print() API allowing developers to print arbitrary string(s) for the purpose of debugging.

Input Parameters

This API accepts one or more parameter values. The API utilizes the toString() of each value and outputs the resulting string onto the console. Please note that this API is not equivalent to C printf(), thus no formatting is supported, the string can be concatenated by the + operator however.

Example

var name = name_get();
print("The name is " + name);

Return Values

None

Back to main - Copyright © 2015 Fluffy Spider Techologies - http://fluffyspider.com