Fix indentation

This commit is contained in:
megawac 2014-10-25 15:07:15 -04:00
parent a53544b44a
commit fbe43b3b7a
1 changed files with 32 additions and 32 deletions

View File

@ -50,42 +50,42 @@ function uri(text) {
var regex = { var regex = {
color: /\003([0-9]{1,2})[,]?([0-9]{1,2})?([^\003]+)/, color: /\003([0-9]{1,2})[,]?([0-9]{1,2})?([^\003]+)/,
terminator: /\x0D/, terminator: /\x0D/,
styles: [ styles: [
[/\002([^\002]+)(\002)?/, ["<b>", "</b>"]], [/\002([^\002]+)(\002)?/, ["<b>", "</b>"]],
[/\037([^\037]+)(\037)?/, ["<u>", "</u>"]], [/\037([^\037]+)(\037)?/, ["<u>", "</u>"]],
] ]
}; };
function colors(text) { function colors(text) {
if (!text) { if (!text) {
return text; return text;
} }
if (regex.terminator.test(text)) { if (regex.terminator.test(text)) {
return $.map(text.split(regex.terminator), colors); return $.map(text.split(regex.terminator), colors);
} }
if (regex.color.test(text)) { if (regex.color.test(text)) {
var match; var match;
while (match = regex.color.exec(text)) { while (match = regex.color.exec(text)) {
var color = "color-" + match[1]; var color = "color-" + match[1];
var bg = match[2]; var bg = match[2];
if (bg) { if (bg) {
color += " bg-" + bg; color += " bg-" + bg;
} }
var text = text.replace( var text = text.replace(
match[0], match[0],
"<span class='" + color + "'>" + match[3] + "</span>" "<span class='" + color + "'>" + match[3] + "</span>"
); );
} }
} }
for (var i in regex.styles) { for (var i in regex.styles) {
var pattern = regex.styles[i][0]; var pattern = regex.styles[i][0];
var style = regex.styles[i][1]; var style = regex.styles[i][1];
if (pattern.test(text)) { if (pattern.test(text)) {
var match; var match;
while (match = pattern.exec(text)) { while (match = pattern.exec(text)) {
text = text.replace(match[0], style[0] + match[1] + style[1]); text = text.replace(match[0], style[0] + match[1] + style[1]);
} }
} }
} }
return text; return text;
} }