Implement full support of WeeChat text styling
This commit is contained in:
parent
ea798ef3c4
commit
9772da0095
5 changed files with 3135 additions and 843 deletions
1929
css/style.css
Normal file
1929
css/style.css
Normal file
File diff suppressed because it is too large
Load diff
|
@ -7,6 +7,7 @@
|
|||
<title ng-bind-template="WeeChat {{ pageTitle}}"></title>
|
||||
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" media="screen">
|
||||
<link rel="shortcut icon" type="image/png" href="img/favicon.png" >
|
||||
<link href="css/style.css" rel="stylesheet" media="screen">
|
||||
<link href="css/glowingbear.css" rel="stylesheet" media="screen">
|
||||
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.min.js"></script>
|
||||
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular-sanitize.min.js"></script>
|
||||
|
@ -221,9 +222,9 @@ $ openssl req -nodes -newkey rsa:2048 -keyout relay.pem -x509 -days 365 -out rel
|
|||
{{ bufferline.date | date:'HH:mm' }}
|
||||
</span>
|
||||
</td>
|
||||
<td class="prefix vertical-line"><span ng-repeat="part in bufferline.prefix" style="{{ part.fg }}">{{ part.text }}</span></td>
|
||||
<td class="prefix vertical-line"><span ng-repeat="part in bufferline.prefix" ng-class="{{ part.classes }}">{{ part.text }}</span></td>
|
||||
<td class="message">
|
||||
<span ng-repeat="part in bufferline.content" class="text" style="{{ part.fg }}" ng-bind-html="part.text"></span>
|
||||
<span ng-repeat="part in bufferline.content" class="text" ng-class="{{ part.classes }}" ng-bind-html="part.text"></span>
|
||||
|
||||
<div ng-repeat="metadata in bufferline.metadata">
|
||||
<div ng-show="metadata.visible">
|
||||
|
|
75
js/models.js
75
js/models.js
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
var models = angular.module('weechatModels', []);
|
||||
|
||||
models.service('models', ['$rootScope', 'colors', function($rootScope, colors) {
|
||||
models.service('models', ['$rootScope', function($rootScope) {
|
||||
/*
|
||||
* Buffer class
|
||||
*/
|
||||
|
@ -59,36 +59,64 @@ models.service('models', ['$rootScope', 'colors', function($rootScope, colors) {
|
|||
* BufferLine class
|
||||
*/
|
||||
this.BufferLine = function(message) {
|
||||
|
||||
/*
|
||||
* Parse the text elements from the buffer line added
|
||||
*
|
||||
* @param message weechat message
|
||||
*/
|
||||
function parseLineAddedTextElements(message) {
|
||||
var text = colors.parse(message);
|
||||
text_elements =_.map(text, function(text_element) {
|
||||
if (text_element && ('fg' in text_element)) {
|
||||
text_element['fg'] = colors.prepareCss(text_element['fg']);
|
||||
}
|
||||
// TODO: parse background as well
|
||||
|
||||
return text_element;
|
||||
});
|
||||
return text_elements;
|
||||
}
|
||||
|
||||
|
||||
var buffer = message['buffer'];
|
||||
var date = message['date'];
|
||||
|
||||
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 = [];
|
||||
|
||||
var prefix = parseLineAddedTextElements(message['prefix']);
|
||||
// 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 allReset = true;
|
||||
for (var attr in textEl.attrs.override) {
|
||||
if (textEl.attrs.override[attr]) {
|
||||
allReset = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (allReset) {
|
||||
textEl.classes.push('a-reset');
|
||||
} else 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 tags_array = message['tags_array'];
|
||||
var displayed = message['displayed'];
|
||||
var highlight = message['highlight'];
|
||||
var content = parseLineAddedTextElements(message['message']);
|
||||
var content = weeChat.Protocol.rawText2Rich(message['message']);
|
||||
addClasses(content);
|
||||
|
||||
var rtext = "";
|
||||
if(content[0] != undefined) {
|
||||
|
@ -104,6 +132,7 @@ models.service('models', ['$rootScope', 'colors', function($rootScope, colors) {
|
|||
highlight: highlight,
|
||||
displayed: displayed,
|
||||
text: rtext,
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,16 +14,7 @@ weechat.filter('toArray', function () {
|
|||
}
|
||||
});
|
||||
|
||||
weechat.factory('colors', [function($scope) {
|
||||
|
||||
return {
|
||||
prepareCss: weeChat.color.prepareCss,
|
||||
parse: weeChat.color.parse
|
||||
};
|
||||
|
||||
}]);
|
||||
|
||||
weechat.factory('handlers', ['$rootScope', 'colors', 'models', 'plugins', function($rootScope, colors, models, plugins) {
|
||||
weechat.factory('handlers', ['$rootScope', 'models', 'plugins', function($rootScope, models, plugins) {
|
||||
|
||||
var handleBufferClosing = function(message) {
|
||||
var bufferMessage = message['objects'][0]['content'][0];
|
||||
|
@ -147,7 +138,7 @@ weechat.factory('handlers', ['$rootScope', 'colors', 'models', 'plugins', functi
|
|||
|
||||
}]);
|
||||
|
||||
weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers', 'colors', 'models', function($q, $rootScope, $log, storage, handlers, colors, models) {
|
||||
weechat.factory('connection', ['$q', '$rootScope', '$log', '$store', 'handlers', 'models', function($q, $rootScope, $log, storage, handlers, models) {
|
||||
protocol = new weeChat.Protocol();
|
||||
var websocket = null;
|
||||
|
||||
|
@ -570,4 +561,4 @@ weechat.controller('WeechatCtrl', ['$rootScope', '$scope', '$store', '$timeout',
|
|||
}
|
||||
|
||||
}]
|
||||
);
|
||||
);
|
||||
|
|
1952
js/weechat.js
1952
js/weechat.js
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue