Skip to content

Commit d0fd23e

Browse files
committed
Various fixes and reformatting for the scripter.
1 parent fefb62b commit d0fd23e

35 files changed

Lines changed: 394 additions & 1804 deletions

demo/scripting/ccl.htm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,9 @@ <h2>Tests</h2>
8888
cm.getBounds();
8989
isWindowedFullscreen = !isWindowedFullscreen;
9090
}
91-
91+
var $ = function (e) { return document.getElementById(e); }
9292
var cm = new CommentManager($('commentCanvas'));
93-
var bscripter = new CCLScripting("../../build/scripting/Worker.js");
93+
var bscripter = new CCLScripting("../../dist/scripting/Worker.js");
9494
bscripter.logger = new function(){
9595
this.log = function(t){
9696
var pre = document.createElement("pre");

dist/CommentCoreLibrary.js

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1112,6 +1112,14 @@ var CommentManager = (function() {
11121112
*/
11131113
var CommentFilter = (function () {
11141114

1115+
/**
1116+
* Matches a rule against an input that could be the full or a subset of
1117+
* the comment data.
1118+
*
1119+
* @param rule - rule object to match
1120+
* @param cmtData - full or portion of comment data
1121+
* @return boolean indicator of match
1122+
*/
11151123
function _match (rule, cmtData) {
11161124
var path = rule.subject.split('.');
11171125
var extracted = cmtData;
@@ -1168,6 +1176,10 @@ var CommentFilter = (function () {
11681176
}
11691177
}
11701178

1179+
/**
1180+
* Constructor for CommentFilter
1181+
* @constructor
1182+
*/
11711183
function CommentFilter() {
11721184
this.rules = [];
11731185
this.modifiers = [];
@@ -1184,16 +1196,37 @@ var CommentFilter = (function () {
11841196
};
11851197
}
11861198

1199+
/**
1200+
* Runs all modifiers against current comment
1201+
*
1202+
* @param cmt - comment to run modifiers on
1203+
* @return modified comment
1204+
*/
11871205
CommentFilter.prototype.doModify = function (cmt) {
11881206
return this.modifiers.reduce(function (c, f) {
11891207
return f(c);
11901208
}, cmt);
11911209
};
11921210

1211+
/**
1212+
* Executes a method defined to be executed right before the comment object
1213+
* (built from commentData) is placed onto the runline.
1214+
*
1215+
* @deprecated
1216+
* @param cmt - comment data
1217+
* @return cmt
1218+
*/
11931219
CommentFilter.prototype.beforeSend = function (cmt) {
11941220
return cmt;
11951221
};
11961222

1223+
/**
1224+
* Performs validation of the comment data before it is allowed to get sent
1225+
* by applying type constraints and rules
1226+
*
1227+
* @param cmtData - comment data
1228+
* @return boolean indicator of whether this commentData should be shown
1229+
*/
11971230
CommentFilter.prototype.doValidate = function (cmtData) {
11981231
if ((!this.allowUnknownTypes ||
11991232
cmtData.mode.toString() in this.allowTypes) &&
@@ -1211,13 +1244,26 @@ var CommentFilter = (function () {
12111244
});
12121245
};
12131246

1247+
/**
1248+
* Adds a rule for use with validation
1249+
*
1250+
* @param rule - object containing rule definitions
1251+
* @throws Exception when rule mode is incorrect
1252+
*/
12141253
CommentFilter.prototype.addRule = function (rule) {
12151254
if (rule.mode !== 'accept' && rule.mode !== 'reject') {
12161255
throw new Error('Rule must be of accept type or reject type.');
12171256
}
12181257
this.rules.push(rule);
12191258
};
12201259

1260+
/**
1261+
* Adds a modifier to be used
1262+
*
1263+
* @param modifier - modifier function that takes in comment data and
1264+
* returns modified comment data
1265+
* @throws Exception when modifier is not a function
1266+
*/
12211267
CommentFilter.prototype.addModifier = function (f) {
12221268
if (typeof f !== 'function') {
12231269
throw new Error('Modifiers need to be functions.');
@@ -1870,7 +1916,7 @@ var BilibiliFormat = (function () {
18701916
BilibiliFormat.TextParser = function (params) {
18711917
this._allowInsecureDomParsing = true;
18721918
this._attemptEscaping = true;
1873-
this._canSecureParse = false;
1919+
this._canSecureNativeParse = false;
18741920
if (typeof params === 'object') {
18751921
this._allowInsecureDomParsing = params.allowInsecureDomParsing === false ? false : true;
18761922
this._attemptEscaping = params.attemptEscaping === false ? false : true;

dist/CommentCoreLibrary.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/scripting/Worker.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@ importScripts("OOAPI.js");
55
if (!__OOAPI) {
66
console.log("Error: OOAPI Not Loaded");
77
self.close();
8-
};
8+
}
99

1010
// Hook independent channels that cannot be removed
1111
__OOAPI.createChannel("::eval", 1, Math.round(Math.random() * 100000));
1212
__OOAPI.createChannel("::debug", 1, Math.round(Math.random() * 100000));
1313

1414
// Load the BSE Abstraction Runtime
1515
importScripts('api/Runtime.js',
16-
'api/ScriptManager.js',
1716
'api/Player.js',
1817
'api/Display.js',
1918
'api/Tween.js',

0 commit comments

Comments
 (0)