Merge pull request #390 from glowing-bear/inlinecolours

Display HTML colour codes inline
This commit is contained in:
David Cormier 2014-07-31 09:25:44 -04:00
commit ace63454a7
3 changed files with 26 additions and 1 deletions

View file

@ -346,6 +346,15 @@ div.embed img.embed {
max-width: 100%;
}
div.colourbox {
display: inline-block;
border-radius: 3px;
border: 1px solid #bbb;
width: 14px;
height: 14px;
margin-bottom: -2px;
}
table.notimestamp td.time {
display: none !important;

View file

@ -255,7 +255,7 @@ $ openssl req -nodes -newkey rsa:4096 -keyout relay.pem -x509 -days 365 -out rel
<td class="prefix"><a ng-click="addMention(bufferline.prefix)"><span ng-repeat="part in bufferline.prefix" bo-class="part.classes" bo-html="part.text"></span></a></td>
<td class="message">
<div ng-repeat="metadata in bufferline.metadata" plugin data="metadata"></div>
<span ng-repeat="part in bufferline.content" class="text" bo-class="part.classes" bo-html="part.text|irclinky:'_blank'"></span>
<span ng-repeat="part in bufferline.content" class="text" bo-class="part.classes" bo-html="part.text | irclinky:'_blank' | inlinecolour"></span>
</td>
</tr>
<tr class="readmarker" ng-if="activeBuffer().lastSeen==$index">

View file

@ -49,6 +49,22 @@ weechat.filter('irclinky', ['$filter', function($filter) {
};
}]);
weechat.filter('inlinecolour', function() {
'use strict';
return function(text) {
if (!text) {
return text;
}
// only match 6-digit colour codes, 3-digit ones have too many false positives (issue numbers, etc)
var hexColourRegex = /(^|[^&])\#([0-9a-f]{6})($|[^\w'"])/gmi;
var substitute = '$1#$2 <div class="colourbox" style="background-color:#$2"></div> $3';
return text.replace(hexColourRegex, substitute);
};
});
weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', function($rootScope, $log, models, plugins) {
var handleBufferClosing = function(message) {