Skip to content

Commit 8c4dae4

Browse files
committed
Cleanup
Remove unused files. Clean up Array to not contaminate global Array class and to use consistent definitions. Update readme with license badge.
1 parent 929e809 commit 8c4dae4

9 files changed

+68
-473
lines changed

README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
[![NPM version](https://badge.fury.io/js/comment-core-library.svg)](http://badge.fury.io/js/comment-core-library)
33
[![Bower version](https://badge.fury.io/bo/comment-core-library.svg)](http://badge.fury.io/bo/comment-core-library)
44
[![Built with Grunt](https://cdn.gruntjs.com/builtwith.png)](http://gruntjs.com/)
5-
5+
[![License](http://img.shields.io/badge/license-MIT-brightgreen.svg)](http://opensource.org/licenses/MIT)
66

77
The CommentCoreLibrary is a set of Javascript modules that make up the
88
core controller for comments streaming on top of timed media (video or audio).
@@ -40,8 +40,8 @@ gem 'rails-assets-comment-core-library'
4040
```
4141

4242
## Examples and Documentation
43-
- Documentation can be found inside the `docs/` folder.
44-
- Some sample extension modules may be found in `extend/`.
43+
- [Documentation](docs/) can be found inside the `docs/` folder.
44+
- Some sample extension modules may be found in `src/extend/`.
4545
- Experimental modules are in `experimental/`.
4646
- You may test using test data found in `tests/`.
4747

@@ -73,8 +73,8 @@ implementation of a video player with CommentCoreLibrary.
7373
CommentCoreLibrary (//github.com/jabbany/CommentCoreLibrary) - Licensed under the MIT license
7474

7575
## 使用
76-
- 有关本项目的文档可以在 `docs/` 文件夹里面找到。
77-
- 一些功能性扩展模块会出现在 `extend/` 中。
76+
- 有关本项目的[文档](docs/) 可以在 `docs/` 文件夹里面找到。
77+
- 一些功能性扩展模块会出现在 `src/extend/` 中。
7878
- 一些实验性模块在 `experimental/` 里。
7979
- 测试数据在 `tests/` 里。
8080

build/CommentCoreLibrary.js

+16-11
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* @license MIT
44
* @author Jim Chen
55
*/
6-
var BinArray = {};
7-
(function(BinArray){
6+
var BinArray = (function(){
7+
var BinArray = {};
88
BinArray.bsearch = function(arr, what, how){
99
if(arr.length == 0) return 0;
1010
if(how(what,arr[0]) < 0) return 0;
@@ -33,7 +33,8 @@ var BinArray = {};
3333
arr.splice(index,0,what);
3434
return index;
3535
};
36-
})(BinArray);
36+
return BinArray;
37+
})();
3738

3839
var __extends = this.__extends || function (d, b) {
3940
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
@@ -655,9 +656,11 @@ function CommentFilter(){
655656
}
656657

657658
/*!
658-
* Comment Core For HTML5 VideoPlayers
659+
* Comment Core Library CommentManager
660+
* @license MIT
661+
* @author Jim Chen
662+
*
659663
* Copyright (c) 2014 Jim Chen
660-
* License: MIT
661664
*/
662665
var CommentManager = (function() {
663666
var getRotMatrix = function(yrot, zrot) {
@@ -695,7 +698,8 @@ var CommentManager = (function() {
695698
scroll:{
696699
opacity:1,
697700
scale:1
698-
}
701+
},
702+
limit: 0
699703
};
700704
this.timeline = [];
701705
this.runline = [];
@@ -826,9 +830,9 @@ var CommentManager = (function() {
826830
this.lastPos = time;
827831
}
828832
for(;this.position < this.timeline.length;this.position++){
829-
if(this.limiter > 0 && this.runline.length > this.limiter) break;
833+
if(this.options.limit > 0 && this.runline.length > this.limiter) break;
830834
if(this.validate(this.timeline[this.position]) && this.timeline[this.position]['stime']<=time){
831-
this.sendComment(this.timeline[this.position]);
835+
this.send(this.timeline[this.position]);
832836
}else{
833837
break;
834838
}
@@ -837,7 +841,7 @@ var CommentManager = (function() {
837841
CommentManager.prototype.rescale = function(){
838842

839843
};
840-
CommentManager.prototype.sendComment = function(data){
844+
CommentManager.prototype.send = function(data){
841845
if(data.mode === 8){
842846
console.log(data);
843847
if(this.scripting){
@@ -886,8 +890,9 @@ var CommentManager = (function() {
886890
this.dispatchEvent("enterComment", cmt);
887891
this.runline.push(cmt);
888892
};
889-
CommentManager.prototype.send = function(data){
890-
this.sendComment(data); // Wrapper for future apis
893+
CommentManager.prototype.sendComment = function(data){
894+
console.log("CommentManager.sendComment is deprecated. Please use send instead");
895+
this.send(data); // Wrapper for Backwards Compatible APIs
891896
};
892897
CommentManager.prototype.finish = function(cmt){
893898
this.dispatchEvent("exitComment", cmt);

build/CommentCoreLibrary.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/CommentManager.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,7 @@
11
# 弹幕管理器 CommentManager
22
弹幕管理器自 `v1.0` 后将改成支持多种多层渲染的模式了,在此之前请先参考一些[不完整的API实现](CommentCoreLibraryAPI.md)
3+
4+
## Properties 属性
5+
6+
### options &lt;Object&gt;
7+
此处用于放置弹幕默认参数等.

docs/CommentObject.md

+19-19
Original file line numberDiff line numberDiff line change
@@ -11,37 +11,37 @@
1111

1212
## Properties 属性
1313

14-
### LINEAR <Func> [静态]
14+
### LINEAR &lt;Func&gt; [静态]
1515
LINEAR 为线形拟合函数,提供用于默认补间动画的拟合。
1616

17-
### mode <Num> = 1
17+
### mode &lt;Num&gt; = 1
1818
Danmaku Mode: mode 表示弹幕的类型,参考 [弹幕类型 (Comment Types)](CommentTypes.md)
1919

20-
### stime <Num> = 0
20+
### stime &lt;Num&gt; = 0
2121
Start Time: stime 表示弹幕相对于视频位置的开始时间(ms),`0`即在视频开始立即出现
2222

23-
### text <String>
23+
### text &lt;String&gt;
2424
Text: text 表示弹幕的文字内容。注意:在创造弹幕对象后,对 text 的更改将无意义。
2525

26-
### ttl <Num> = 4000
26+
### ttl &lt;Num&gt; = 4000
2727
Time To Live: ttl 表示弹幕剩余的生存时间(ms)(注意:在css模式下该子段可能不准确)
2828

29-
### dur <Num> = 4000
29+
### dur &lt;Num&gt; = 4000
3030
Duration: dur 表示弹幕的总生存时间(ms)。默认情况下,对于滚动弹幕这个数字是 4000。
3131

32-
### cindex <Num> = -1
32+
### cindex &lt;Num&gt; = -1
3333
Pool Index: cindex 表示弹幕的弹幕池ID,用于在删除弹幕时寻找弹幕所在弹幕池。
3434

35-
### motion <Array<IMotion>> = []
35+
### motion &lt;Array&lt;IMotion&gt;&gt; = []
3636
Motion Group: motion 控制一般弹幕(CoreComment)的运动轨迹,别的类型的弹幕可能忽略此属性(如
3737
滚动弹幕)
3838

39-
### movable <Bool> = true
39+
### movable &lt;Bool&gt; = true
4040
Is Movable: 弹幕是否可以移动。此处为 `False` 时,弹幕的 time 函数将不会调用 update() 来移动
4141
弹幕。这样弹幕将无动画效果(不管 motion 或者 update 函数的实现)。但是更改 `x,y` 坐标还是可以
4242
重新定位弹幕的。
4343

44-
### align <Num> = 0
44+
### align &lt;Num&gt; = 0
4545
Alignment: 对齐锚点(方形四角)。此数的高位表示上下,低位表示左右。
4646

4747
Byte | Number | Alignment
@@ -57,35 +57,35 @@ Alignment: 对齐锚点(方形四角)。此数的高位表示上下,低位
5757
设定后x,y坐标的锚点将变成对应的方形角。不过,在右和下的对齐时,读取 x,y 坐标不一定准确,而且因为
5858
效率低所以不推荐。比如 top right 模式下,读 x 坐标效率比较低,但是读 y 就要好很多。
5959

60-
### absolute <Bool> = true
60+
### absolute &lt;Bool&gt; = true
6161
Absolute Coordinates: 是否使用绝对坐标。当 `absolute === false` 时,x,y坐标将会表示相对
6262
于整个弹幕管理器的比例,如 `x=0.5``640 x 480` 的管理器上则会显示在 `320` 位置。
6363

6464
注意:width, height 总会以绝对坐标返回,所以如果需要叠加则必须手动转换到相对坐标。
6565

66-
### width/height/bottom/right <Num>
66+
### width/height/bottom/right &lt;Num&gt;
6767
Bounding Box: 定义弹幕的宽高和下部右部位置,前两个定义了 top left 顶点,后两个定义了bottom
6868
right顶点。
6969

70-
### size <Num> = 25
70+
### size &lt;Num&gt; = 25
7171
Font Size: 弹幕的文字大小,请参考 [弹幕大小 Comment Sizes](CommentSizes.md)。更改会更新视图。
7272

73-
### color <Num> = 0xffffff
73+
### color &lt;Num&gt; = 0xffffff
7474
Text Color: 文字颜色,为数字表示,RGB依次由高位到低位:`0xRRGGBB`。更改会更新视图。
7575

76-
### border <Bool> = false
76+
### border &lt;Bool&gt; = false
7777
Display Border: 是否显示边框。用于标注新弹幕。更改会同步更新视图。
7878

79-
### shadow <Bool> = true
79+
### shadow &lt;Bool&gt; = true
8080
Display Shadow: 是否显示弹幕描边/阴影(注意:具体用哪个描边效果需要CSS控制)。更改会同步更新视图。
8181

82-
### font <String> = ""
82+
### font &lt;String&gt; = ""
8383
Font Family: 弹幕字体。当设置为空字符串时,使用默认字体。更改会同步更新视图。
8484

85-
### parent <CommentManager>
85+
### parent &lt;CommentManager&gt;
8686
Parent: 此弹幕归属的上层管理器
8787

88-
### dom <HTMLDivElement/Canvas/etc.>
88+
### dom &lt;HTMLDivElement/Canvas/etc.&gt;
8989
DOM Correspondance: 对应的渲染元素,根据不同情况是不一样的。默认是 DIV 元素。
9090

9191
## Methods 方法

src/Array.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
* @license MIT
44
* @author Jim Chen
55
*/
6-
var BinArray = {};
7-
(function(BinArray){
6+
var BinArray = (function(){
7+
var BinArray = {};
88
BinArray.bsearch = function(arr, what, how){
99
if(arr.length == 0) return 0;
1010
if(how(what,arr[0]) < 0) return 0;
@@ -33,4 +33,5 @@ var BinArray = {};
3333
arr.splice(index,0,what);
3434
return index;
3535
};
36-
})(BinArray);
36+
return BinArray;
37+
})();

src/CommentCoreLibrary.js

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
/*!
2-
* Comment Core For HTML5 VideoPlayers
2+
* Comment Core Library CommentManager
3+
* @license MIT
4+
* @author Jim Chen
5+
*
36
* Copyright (c) 2014 Jim Chen
4-
* License: MIT
57
*/
68
var CommentManager = (function() {
79
var getRotMatrix = function(yrot, zrot) {
@@ -39,7 +41,8 @@ var CommentManager = (function() {
3941
scroll:{
4042
opacity:1,
4143
scale:1
42-
}
44+
},
45+
limit: 0
4346
};
4447
this.timeline = [];
4548
this.runline = [];
@@ -170,9 +173,9 @@ var CommentManager = (function() {
170173
this.lastPos = time;
171174
}
172175
for(;this.position < this.timeline.length;this.position++){
173-
if(this.limiter > 0 && this.runline.length > this.limiter) break;
176+
if(this.options.limit > 0 && this.runline.length > this.limiter) break;
174177
if(this.validate(this.timeline[this.position]) && this.timeline[this.position]['stime']<=time){
175-
this.sendComment(this.timeline[this.position]);
178+
this.send(this.timeline[this.position]);
176179
}else{
177180
break;
178181
}
@@ -181,7 +184,7 @@ var CommentManager = (function() {
181184
CommentManager.prototype.rescale = function(){
182185

183186
};
184-
CommentManager.prototype.sendComment = function(data){
187+
CommentManager.prototype.send = function(data){
185188
if(data.mode === 8){
186189
console.log(data);
187190
if(this.scripting){
@@ -230,8 +233,9 @@ var CommentManager = (function() {
230233
this.dispatchEvent("enterComment", cmt);
231234
this.runline.push(cmt);
232235
};
233-
CommentManager.prototype.send = function(data){
234-
this.sendComment(data); // Wrapper for future apis
236+
CommentManager.prototype.sendComment = function(data){
237+
console.log("CommentManager.sendComment is deprecated. Please use send instead");
238+
this.send(data); // Wrapper for Backwards Compatible APIs
235239
};
236240
CommentManager.prototype.finish = function(cmt){
237241
this.dispatchEvent("exitComment", cmt);

0 commit comments

Comments
 (0)