API Documentation - MarkTime/MarkTimeJS GitHub Wiki
The MarkTime API system provides the ability for plugins to use APIs, which allow easy access of certain features that might normally be disallowed from within the plugin. The API system is made up of the API Manager, which provides a way to get, add, and do other things with APIs. MarkTime also comes with a series of inbuilt APIs, which provide functionality that might be used in your plugin.
- Manager
- Events
- UI
- Preferences
- Configuration
- Database
- File
The API manager provides the ability to manage APIs. It is used to access APIs, as well as add or perform other tasks on them. The API manager provides three core functions:
API.add(name, constructor)
API.get(name, params...)
API.has(name)
This function provides the ability to add an API to the manager. This function consists of two parameters:
-
string name
- The name of the API to add. It must be unique within your plugin. -
function constructor
- A constructor function for the object to be passed out ofAPI.get()
This function does not return a value.
When an API is added in a plugin, the plugins name will be prepended to the name of the API (<plugin name>.<API name>
). This allows multiple plugins to define the same named APIs.
This function provides the ability to get an API from the manager. This function consists of one parameter:
-
string name
- The name of the API to get.
This function returns an object containing the properties of the API.
When an API is gotten, the constructor will be called, and the resulting object returned. The constructor should act like a class. Remember to prepend the name of the plugin that 'owns' an API to the name of the API (<plugin name>.<API name>
). This is not required for the included APIs, however.
This function provides the ability to find if an API exists in the manager. This function consists of one parameter:
-
string name
- The name of the API to find.
This function returns a boolean specifying whether the API exists.
Remember to prepend the name of the plugin that 'owns' an API to the name of the API (<plugin name>.<API name>
). This is not required for the included APIs, however.