From 345dc70f7a7892bce4f6def1f0bdda9e78fb22aa Mon Sep 17 00:00:00 2001 From: David Cormier Date: Fri, 4 Oct 2013 14:19:28 -0400 Subject: [PATCH] Support weechat colors --- css/glowingbear.css | 52 +++++++++++++++++++++++++++++++++++++++++++++ index.html | 2 +- js/websockets.js | 14 ++++++++++++ 3 files changed, 67 insertions(+), 1 deletion(-) diff --git a/css/glowingbear.css b/css/glowingbear.css index 941890f..26fd773 100644 --- a/css/glowingbear.css +++ b/css/glowingbear.css @@ -4,6 +4,58 @@ body { color: white; } +.color-light-green { + color: chartreuse; +} + +.color-27 { + color: deepskyblue; +} + +.color-28 { + color: greenyellow; +} + +.color-00 { + color: coral; +} + +.color-yellow { + color: yellow; +} + +.color-dark-red { + color: darkred; +} + +.color-dark-green { + color: green; +} + +.color-dark-blue { + color: darkblue; +} + +.color-dark-gray { + color: gray; +} + +.color-gray { + color: lightgray; +} + +.color-brown { + color: brown; +} + +.color-cyan { + color: cyan; +} + +.color-dark-cyan { + color: darkcyan; +} + li.notification { color: green; } \ No newline at end of file diff --git a/index.html b/index.html index 4e1ff77..ac8644a 100644 --- a/index.html +++ b/index.html @@ -49,7 +49,7 @@
- + {{ part.text }} diff --git a/js/websockets.js b/js/websockets.js index d872801..6287893 100644 --- a/js/websockets.js +++ b/js/websockets.js @@ -24,6 +24,13 @@ weechat.factory('colors', [function($scope) { return c; } + function prepareCss(color) { + /* + * Translates a weechat color string to CSS + */ + return'color-' + color.replace(' ', '-'); + } + var prefixes = { '\x19': function() { if (part.match(/^F/)) { @@ -95,6 +102,7 @@ weechat.factory('colors', [function($scope) { setAttrs: setAttrs, getColor: getColor, + prepareCss: prepareCss, parse: parse, parts: ['', 'black', 'dark gray', 'dark red', 'light red', 'dark green', 'light green', 'brown', 'yellow', 'dark blue', 'light blue', 'dark magenta', 'light magenta', 'dark cyan', 'light cyan', 'gray', 'white'] } @@ -198,6 +206,12 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'pluginManager', function($ var text = colors.parse(message['objects'][0]['content'][0]['message']); var buffer = message['objects'][0]['content'][0]['buffer']; var message = _.union(prefix, text); + message =_.map(message, function(message) { + if ('fg' in message) { + message['fg'] = colors.prepareCss(message['fg']); + } + return message; + }); buffer_line['message'] = message; if (!_isActiveBuffer(buffer)) {