plugins: automatically hide lines that ends with nsfw
This commit is contained in:
parent
1f7cb5c3ba
commit
a1123ddad0
1 changed files with 10 additions and 1 deletions
|
@ -28,6 +28,8 @@ var Plugin = function(contentForMessage) {
|
||||||
*/
|
*/
|
||||||
plugins.service('plugins', ['userPlugins', '$sce', function(userPlugins, $sce) {
|
plugins.service('plugins', ['userPlugins', '$sce', function(userPlugins, $sce) {
|
||||||
|
|
||||||
|
var nsfwRegexp = new RegExp('nsfw$', 'i');
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Defines the plugin manager object
|
* Defines the plugin manager object
|
||||||
*/
|
*/
|
||||||
|
@ -54,9 +56,16 @@ plugins.service('plugins', ['userPlugins', '$sce', function(userPlugins, $sce)
|
||||||
|
|
||||||
var content = [];
|
var content = [];
|
||||||
for (var i = 0; i < plugins.length; i++) {
|
for (var i = 0; i < plugins.length; i++) {
|
||||||
|
|
||||||
|
var visible = true;
|
||||||
|
|
||||||
|
if (message.match(nsfwRegexp)) {
|
||||||
|
var visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
var pluginContent = plugins[i].contentForMessage(message);
|
var pluginContent = plugins[i].contentForMessage(message);
|
||||||
if (pluginContent) {
|
if (pluginContent) {
|
||||||
var pluginContent = {'visible': true,
|
var pluginContent = {'visible': visible,
|
||||||
'content': $sce.trustAsHtml(pluginContent) }
|
'content': $sce.trustAsHtml(pluginContent) }
|
||||||
|
|
||||||
content.push(pluginContent);
|
content.push(pluginContent);
|
||||||
|
|
Loading…
Reference in a new issue