@@ -7,10 +7,10 @@ CommentManager (弹幕管理器)
7
7
----
8
8
The ` CommentManager ` is initalized by passing in a single parameter that assigns
9
9
the HTML DOM object to write comments on. This object should have a class type
10
- of ` container ` and be a descendant of another wrapper under the class ` abp ` .
10
+ of ` container ` and be a descendant of another wrapper under the class ` abp ` .
11
11
This DOM object is internally referenced as the comment's "stage".
12
12
13
- If you have not initialized this object and wish to do so, you should use the
13
+ If you have not initialized this object and wish to do so, you should use the
14
14
` CommentCore ` object to initialize the entire set.
15
15
16
16
弹幕管理器通过提供一个用于渲染的HTML元件来初始化。这个HTML元件应该属于"container"这个css 类
@@ -22,102 +22,95 @@ Example of the DOM substructure (HTML结构体的示例)
22
22
23
23
<div class = "abp">
24
24
<div class = "container">
25
- <!--
26
- This div will become the comment stage
25
+ <!--
26
+ This div will become the comment stage
27
27
You should pass a DOM reference to this element NOT its parent
28
28
-->
29
29
</div>
30
30
</div>
31
-
32
- The ` CommentManager ` expose a simple API for manipulating comments. The
31
+
32
+ The ` CommentManager ` expose a simple API for manipulating comments. The
33
33
functions along with their usage will be defined below. ` CommentManager ` 会暴露出
34
34
一套简单的API来供开发者控制弹幕。
35
35
36
36
* ` load ( CommentData[] timeline ) `
37
- This method loads in an array of unsorted comment data. Comment data is
38
- directly obtained by parsing the input file. The method will re-sort this
39
- data by timeline-time then by id then by send-time. It will overwrite the
37
+ This method loads in an array of unsorted comment data. Comment data is
38
+ directly obtained by parsing the input file. The method will re-sort this
39
+ data by timeline-time then by id then by send-time. It will overwrite the
40
40
current timeline instantly. 这个方法会载入一个新的弹幕列表到弹幕管理器中弹幕列表将会被
41
41
排序后存储。调用后方法会覆盖任何可能已经存在的时间轴(弹幕信息列表)。
42
-
42
+
43
43
* ` start () `
44
- This method starts the internal clock that scrolls comments. Comments will
44
+ This method starts the internal clock that scrolls comments. Comments will
45
45
not move if the comment manager has not been started. 这个方法会启动弹幕管理器的
46
46
内部计时器。弹幕在未启动计时器的状态下是不会移动的。
47
-
47
+
48
48
* ` stop () `
49
- This method does the opposite of start and pauses the internal clock.
50
- Comments currently scrolling and effects in progress will be stopped
49
+ This method does the opposite of start and pauses the internal clock.
50
+ Comments currently scrolling and effects in progress will be stopped
51
51
immediately. 这个方法于 start 方法作用相反,正在进行的效果和正在滚动的弹幕会被强制停止。
52
52
53
53
* ` insert ( CommentData comment ) `
54
- This method allows for insertion of new comment data into the timeline. It
54
+ This method allows for insertion of new comment data into the timeline. It
55
55
keeps the timeline sorted even after insertion. 这个方法会往弹幕管理器中插入一条
56
56
弹幕,并保持时间轴顺序。注意:当插入弹幕的时间小于已经播放的时间,有可能看不到的。
57
-
57
+
58
58
* ` send ( CommentData comment ) `
59
59
This method **sends a comment to display on the stage**. It does not add the
60
- comment into the timeline. The effects are instant, and the comment will
60
+ comment into the timeline. The effects are instant, and the comment will
61
61
start if the CommentManager's internal timer is running (see `start`, `stop`
62
- methods). Please note: This does NOT send the comment data to the remote
62
+ methods). Please note: This does NOT send the comment data to the remote
63
63
server, for that you will need to send to the provider instead.这个方法会把一条
64
64
弹幕显示到屏幕上。它不会把弹幕发送到服务器,也不会把弹幕插入时间轴。只要弹幕管理器处于运行状态
65
65
弹幕就会立刻显示(参考`start`,`stop`控制弹幕管理器状态)。
66
-
66
+
67
67
* ` clear () `
68
68
This method clears the stage. It removes all running comments, but keeps the
69
69
timeline intact. 这个方法会强制清空显示界面,但是会保留时间轴。
70
-
70
+
71
71
* ` time ( integer time ) `
72
72
This method sets the playhead time of the comment manager. Time is provided
73
- in miliseconds. All the comments from the last time() to the current time()
74
- will be output if the difference in time is positive and falls below a
75
- threshold. 这个方法设置了CommentManager的播放时间,单位是毫秒(0.001s),所有在上一个
73
+ in miliseconds. All the comments from the last time() to the current time()
74
+ will be output if the difference in time is positive and falls below a
75
+ threshold. 这个方法设置了CommentManager的播放时间,单位是毫秒(0.001s),所有在上一个
76
76
time 调用到现在的弹幕都会被输出,前提是两次时间差是正数且低于一个限度。
77
-
78
- * ` setFilter ( CommentFilter filter ) `
79
- This method sets the comment filter for the CommentManager. It replaces the
80
- default filter. 这个方法会替还默认的弹幕过滤器。
81
-
82
- * ` getFilter () `
83
- This method returns the current filter being used. 这个方法返回正在使用的过滤器。
84
-
77
+
85
78
CommentFilter (弹幕过滤器)
86
79
----
87
80
The comment filter is an object that determines if a comment should be displayed
88
- or not depending on its initializing data. It can also control how running
81
+ or not depending on its initializing data. It can also control how running
89
82
comments are displayed. 弹幕过滤器会根据弹幕信息判对一个弹幕是否显示,当然也可以控制弹幕运行的
90
83
方式。
91
84
92
85
* ` doValidate ( CommentData comment ) `
93
86
This method validates the comment data against a list of filters. It returns
94
87
true if the comment is displayed, false if it should be hidden.
95
-
88
+
96
89
* ` addRule ( Rule filterRule ) `
97
90
This method adds a rule into the filter engine.
98
-
99
- Rule Definitions:
100
-
91
+
92
+ Rule Definitions:
93
+
101
94
Rule {
102
95
"mode": int/string comment_mode,
103
96
"operator": string <comment_filter_operator>,
104
97
"subject": string <comment_property>,
105
98
"value": primitive <value>
106
99
}
107
-
108
- For modes, it can be any of [these modes](CommentTypes.md) or 'all'.
100
+
101
+ For modes, it can be any of [these modes](CommentTypes.md) or 'all'.
109
102
Operators can be any of:
110
103
* Equality operators : = , ==, eq, equals
111
104
* Comparison operators : < , >
112
105
* Inequality operators : !=, ineq
113
106
* Regular expression match : matches, regex, ~ (or inversly) notmatch, iregex, !~
114
107
* Range operators : range
115
-
108
+
116
109
* ` addModifier ( function modifier ( CommentData cd ) ) `
117
110
This method adds a modifier that given comment data returns a modified version
118
111
of the comment data.
119
-
112
+
120
113
* ` setRuntimeFilter ( function filter ( Comment c ) ) `
121
- This method is run every time any element is moved animated. It has access
114
+ This method is run every time any element is moved animated. It has access
122
115
to the comment's state. You can only set ONE runtime filter for the comments
123
116
as setting this greatly influences speed.
0 commit comments