# CCL API ()
Note, the API spec is not completely and correctly implemented yet.
CommentManager ()
----
The `CommentManager` is initalized by passing in a single parameter that assigns
the HTML DOM object to write comments on. This object should have a class type
of `container` and be a descendant of another wrapper under the class `abp`.
This DOM object is internally referenced as the comment's "stage".
If you have not initialized this object and wish to do so, you should use the
`CommentCore` object to initialize the entire set.
HTMLHTML"container"css
'abp'
var cm = new CommentManager ( HtmlDomElement stage )
Example of the DOM substructure HTML
The `CommentManager` expose a simple API for manipulating comments. The
functions along with their usage will be defined below. `CommentManager`
API
* `load ( CommentData[] timeline )`
This method loads in an array of unsorted comment data. Comment data is
directly obtained by parsing the input file. The method will re-sort this
data by timeline-time then by id then by send-time. It will overwrite the
current timeline instantly.
* `start ()`
This method starts the internal clock that scrolls comments. Comments will
not move if the comment manager has not been started.
* `stop ()`
This method does the opposite of start and pauses the internal clock.
Comments currently scrolling and effects in progress will be stopped
immediately. start
* `insert ( CommentData comment )`
This method allows for insertion of new comment data into the timeline. It
keeps the timeline sorted even after insertion.
* `send ( CommentData comment )`
This method **sends a comment to display on the stage**. It does not add the
comment into the timeline. The effects are instant, and the comment will
start if the CommentManager's internal timer is running (see `start`, `stop`
methods). Please note: This does NOT send the comment data to the remote
server, for that you will need to send to the provider instead.
`start``stop`
* `clear ()`
This method clears the stage. It removes all running comments, but keeps the
timeline intact.
* `time ( integer time )`
This method sets the playhead time of the comment manager. Time is provided
in miliseconds. All the comments from the last time() to the current time()
will be output if the difference in time is positive and falls below a
threshold. CommentManager(0.001s)
time
CommentFilter
----
The comment filter is an object that determines if a comment should be displayed
or not depending on its initializing data. It can also control how running
comments are displayed.
* `doValidate ( CommentData comment )`
This method validates the comment data against a list of filters. It returns
true if the comment is displayed, false if it should be hidden.
* `addRule ( Rule filterRule )`
This method adds a rule into the filter engine.
Rule Definitions:
Rule {
"mode": int/string comment_mode,
"operator": string ,
"subject": string ,
"value": primitive
}
For modes, it can be any of [these modes](CommentTypes.md) or 'all'.
Operators can be any of:
* Equality operators : = , ==, eq, equals
* Comparison operators : < , >
* Inequality operators : !=, ineq
* Regular expression match : matches, regex, ~ (or inversly) notmatch, iregex, !~
* Range operators : range
* `addModifier ( function modifier ( CommentData cd ) )`
This method adds a modifier that given comment data returns a modified version
of the comment data.
* `setRuntimeFilter ( function filter ( Comment c ) )`
This method is run every time any element is moved animated. It has access
to the comment's state. You can only set ONE runtime filter for the comments
as setting this greatly influences speed.