plugins: automatically hide lines that ends with nsfw

This commit is contained in:
David Cormier 2013-10-13 14:44:37 -04:00
parent 1f7cb5c3ba
commit a1123ddad0
1 changed files with 10 additions and 1 deletions

View File

@ -28,6 +28,8 @@ var Plugin = function(contentForMessage) {
*/
plugins.service('plugins', ['userPlugins', '$sce', function(userPlugins, $sce) {
var nsfwRegexp = new RegExp('nsfw$', 'i');
/*
* Defines the plugin manager object
*/
@ -54,9 +56,16 @@ plugins.service('plugins', ['userPlugins', '$sce', function(userPlugins, $sce)
var content = [];
for (var i = 0; i < plugins.length; i++) {
var visible = true;
if (message.match(nsfwRegexp)) {
var visible = false;
}
var pluginContent = plugins[i].contentForMessage(message);
if (pluginContent) {
var pluginContent = {'visible': true,
var pluginContent = {'visible': visible,
'content': $sce.trustAsHtml(pluginContent) }
content.push(pluginContent);