diff --git a/index.html b/index.html index 112d994..8fb2157 100644 --- a/index.html +++ b/index.html @@ -215,7 +215,9 @@ $ openssl req -nodes -newkey rsa:4096 -keyout relay.pem -x509 -days 365 -out rel -
+
+ +
diff --git a/js/handlers.js b/js/handlers.js index e1dfe9d..065a4b8 100644 --- a/js/handlers.js +++ b/js/handlers.js @@ -64,8 +64,13 @@ weechat.factory('handlers', ['$rootScope', '$log', 'models', 'plugins', 'notific var buffer = obj.pointers[0]; var old = models.getBuffer(buffer); old.fullName = obj.full_name; - old.title = obj.title; + old.title = models.parseRichText(obj.title); old.number = obj.number; + + old.rtitle = ""; + for (var i = 0; i < old.title.length; ++i) { + old.rtitle += old.title[i].text; + } }; var handleBufferRenamed = function(message) { diff --git a/js/models.js b/js/models.js index 8f576f8..6ee7295 100644 --- a/js/models.js +++ b/js/models.js @@ -8,6 +8,48 @@ var models = angular.module('weechatModels', []); models.service('models', ['$rootScope', '$filter', function($rootScope, $filter) { + var parseRichText = function(text) { + var textElements = weeChat.Protocol.rawText2Rich(text), + typeToClassPrefixFg = { + 'option': 'cof-', + 'weechat': 'cwf-', + 'ext': 'cef-' + }, + typeToClassPrefixBg = { + 'option': 'cob-', + 'weechat': 'cwb-', + 'ext': 'ceb-' + }; + + textElements.forEach(function(textEl) { + textEl.classes = []; + + // foreground color + var prefix = typeToClassPrefixFg[textEl.fgColor.type]; + textEl.classes.push(prefix + textEl.fgColor.name); + + // background color + prefix = typeToClassPrefixBg[textEl.bgColor.type]; + textEl.classes.push(prefix + textEl.bgColor.name); + + // attributes + if (textEl.attrs.name !== null) { + textEl.classes.push('coa-' + textEl.attrs.name); + } + var attr, val; + for (attr in textEl.attrs.override) { + val = textEl.attrs.override[attr]; + if (val) { + textEl.classes.push('a-' + attr); + } else { + textEl.classes.push('a-no-' + attr); + } + } + }); + return textElements; + }; + this.parseRichText = parseRichText; + /* * Buffer class */ @@ -21,7 +63,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter) var trimmedName = shortName.replace(/^[#&+]/, '') || (shortName ? ' ' : null); // get channel identifier var prefix = ['#', '&', '+'].indexOf(shortName.charAt(0)) >= 0 ? shortName.charAt(0) : ''; - var title = message.title; + var title = parseRichText(message.title); var number = message.number; var pointer = message.pointers[0]; var notify = 3; // Default 3 == message @@ -44,6 +86,11 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter) notify = message.notify; } + var rtitle = ""; + for (var i = 0; i < title.length; ++i) { + rtitle += title[i].text; + } + /* * Adds a line to this buffer * @@ -234,6 +281,7 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter) prefix: prefix, number: number, title: title, + rtitle: rtitle, lines: lines, clear: clear, requestedLines: requestedLines, @@ -268,53 +316,11 @@ models.service('models', ['$rootScope', '$filter', function($rootScope, $filter) var date = message.date; var shortTime = $filter('date')(date, 'HH:mm'); - function addClasses(textElements) { - var typeToClassPrefixFg = { - 'option': 'cof-', - 'weechat': 'cwf-', - 'ext': 'cef-' - }; - var typeToClassPrefixBg = { - 'option': 'cob-', - 'weechat': 'cwb-', - 'ext': 'ceb-' - }; - textElements.forEach(function(textEl) { - textEl.classes = []; - - // foreground color - var prefix = typeToClassPrefixFg[textEl.fgColor.type]; - textEl.classes.push(prefix + textEl.fgColor.name); - - // background color - prefix = typeToClassPrefixBg[textEl.bgColor.type]; - textEl.classes.push(prefix + textEl.bgColor.name); - - // attributes - if (textEl.attrs.name !== null) { - textEl.classes.push('coa-' + textEl.attrs.name); - } - var val; - for (var attr in textEl.attrs.override) { - val = textEl.attrs.override[attr]; - if (val) { - textEl.classes.push('a-' + attr); - } else { - textEl.classes.push('a-no-' + attr); - } - } - }); - } - - - var prefix = weeChat.Protocol.rawText2Rich(message.prefix); - addClasses(prefix); - + var prefix = parseRichText(message.prefix); var tags_array = message.tags_array; var displayed = message.displayed; var highlight = message.highlight; - var content = weeChat.Protocol.rawText2Rich(message.message); - addClasses(content); + var content = parseRichText(message.message); if (highlight) { prefix.forEach(function(textEl) { diff --git a/js/notifications.js b/js/notifications.js index fbeba09..6bd71c9 100644 --- a/js/notifications.js +++ b/js/notifications.js @@ -52,7 +52,7 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', function($root var activeBuffer = models.getActiveBuffer(); if (activeBuffer) { - $rootScope.pageTitle = activeBuffer.shortName + ' | ' + activeBuffer.title; + $rootScope.pageTitle = activeBuffer.shortName + ' | ' + activeBuffer.rtitle; } };