New user setting for display embedded content by default

This commit is contained in:
Tor Hveem 2013-10-28 13:21:51 +01:00
parent 59206770e2
commit 6258303465
3 changed files with 22 additions and 5 deletions

View File

@ -183,6 +183,16 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel
</div> </div>
</form> </form>
</li> </li>
<li class="">
<form class="form-inline" role="form">
<div class="checkbox">
<label>
<input type="checkbox" ng-model="noembed">
Hide embedded content by default
</label>
</div>
</form>
</li>
<li class=""> <li class="">
<form class="form-inline" role="form"> <form class="form-inline" role="form">
<div class="checkbox"> <div class="checkbox">

View File

@ -53,16 +53,15 @@ plugins.service('plugins', ['userPlugins', '$sce', function(userPlugins, $sce) {
* Iterates through all the registered plugins * Iterates through all the registered plugins
* and run their contentForMessage function. * and run their contentForMessage function.
*/ */
var contentForMessage = function(message) { var contentForMessage = function(message, visible) {
message.metadata = []; message.metadata = [];
for (var i = 0; i < plugins.length; i++) { for (var i = 0; i < plugins.length; i++) {
var nsfw = false; var nsfw = false;
var visible = true;
if (message.text.match(nsfwRegexp)) { if (message.text.match(nsfwRegexp)) {
var nsfw = true; var nsfw = true;
var visible = false; visible = false;
} }
var pluginContent = plugins[i].contentForMessage(message.text); var pluginContent = plugins[i].contentForMessage(message.text);

View File

@ -27,7 +27,7 @@ weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootSc
// Only react to line if its displayed // Only react to line if its displayed
if(message.displayed) { if(message.displayed) {
var buffer = models.getBuffer(message.buffer); var buffer = models.getBuffer(message.buffer);
message = plugins.PluginManager.contentForMessage(message); message = plugins.PluginManager.contentForMessage(message, $rootScope.visible);
buffer.addLine(message); buffer.addLine(message);
if (buffer.active) { if (buffer.active) {
@ -513,6 +513,14 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
$store.bind($scope, "hotlistsync", true); $store.bind($scope, "hotlistsync", true);
// Save setting for displaying nicklist // Save setting for displaying nicklist
$store.bind($scope, "nonicklist", false); $store.bind($scope, "nonicklist", false);
// Save setting for displaying embeds
$store.bind($scope, "noembed", false);
// Save setting for displaying embeds in rootscope so it can be used from service
$rootScope.visible = $scope.noembed == false;
// Watch model and update show setting when it changes
$scope.$watch('noembed', function() {
$rootScope.visible = $scope.noembed == false;
});
$scope.setActiveBuffer = function(key) { $scope.setActiveBuffer = function(key) {
models.setActiveBuffer(key); models.setActiveBuffer(key);