ec56cf17ee3ad7bc515d535df27df849d2957c4d
[KiwiIRC.git] / client / src / views / texttheme.js
1 _kiwi.view.TextTheme = _kiwi.view.Panel.extend({
2 initialize: function(text_theme) {
3 this.text_theme = text_theme;
4 },
5 styleText: function(string_id, params) {
6 var style, text;
7
8 style = formatToIrcMsg(_kiwi.global.text_theme.options[string_id]);
9
10 // Bring member info back to first level of params
11 if (params['%M']) {
12 for(key in params['%M']) {
13 params[key] = params['%M'][key];
14 }
15 }
16
17 // Do the magic. Use the shorthand syntax to produce output.
18 text = style.replace(/%([TJHNCR])/g, function(match, key) {
19 key = '%' + key;
20
21 if (typeof params[key.toUpperCase()] !== 'undefined')
22 return params[key.toUpperCase()];
23 });
24 return text;
25 }
26 });