From 00468606afcecbd0d8adf703e207eb3983f3edf5 Mon Sep 17 00:00:00 2001 From: nuintun Date: Wed, 2 Dec 2015 13:24:38 +0800 Subject: [PATCH] update files --- static/js/terminal/index.js | 57 +++++++++++++++++++++---------------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/static/js/terminal/index.js b/static/js/terminal/index.js index e28823c..c52f558 100644 --- a/static/js/terminal/index.js +++ b/static/js/terminal/index.js @@ -1053,30 +1053,9 @@ AnsiTerminal.prototype.toString = function (type){ stylesBuffer[i][j].value = node.value; } - if (styleBuffer.foreground) { - style += 'color:' + styleBuffer.foreground + ';'; - } - - if (styleBuffer.background) { - style += 'background-color:' + styleBuffer.background + ';'; - } - - if (styleBuffer.bold) { - style += 'font-weight:bold;'; - } - - if (styleBuffer.italic) { - style += 'font-style: italic;'; - } - - if (styleBuffer.underline) { - style += 'text-decoration: underline;'; - } - if (j === 0) { + style = htmlStyle(styleBuffer); s += ''; - - style = ''; attrCache = node.attr; } else if (j === cols - 1) { s += ''; @@ -1084,9 +1063,8 @@ AnsiTerminal.prototype.toString = function (type){ if (node.value) { if (node.attr !== attrCache) { + style = htmlStyle(styleBuffer); s += ''; - - style = ''; attrCache = node.attr; } @@ -2762,3 +2740,34 @@ function styles(node){ return styles; } + +/** + * html style + * @param styles + * @returns {string} + */ +function htmlStyle(styles){ + var style = ''; + + if (styles.foreground) { + style += 'color:' + styles.foreground + ';'; + } + + if (styles.background) { + style += 'background-color:' + styles.background + ';'; + } + + if (styles.bold) { + style += 'font-weight:bold;'; + } + + if (styles.italic) { + style += 'font-style: italic;'; + } + + if (styles.underline) { + style += 'text-decoration: underline;'; + } + + return style; +}