From 20d8d3922c8164550305b69741b52ead2f256f3b Mon Sep 17 00:00:00 2001 From: coderaiser Date: Wed, 26 Jun 2013 08:05:08 +0000 Subject: [PATCH] fix(console) remove odd \n --- lib/client/console.js | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/client/console.js b/lib/client/console.js index c0786fea..f4b90021 100644 --- a/lib/client/console.js +++ b/lib/client/console.js @@ -72,14 +72,26 @@ var CloudCmd, Util, DOM, $; this.log = function(pText){ if (jqconsole) - jqconsole.Write(pText + '\n', 'log-msg'); + jqconsole.Write( addNewLine(pText), 'log-msg'); }; - this.error = function(pText){ + this.error = function(pText){ if (jqconsole) - jqconsole.Write(pText + '\n', 'error-msg'); + jqconsole.Write( addNewLine(pText), 'error-msg'); }; + function addNewLine(pText){ + var lNewLine, n = pText && pText.length; + + if(n && pText[n-1] !== '\n') + lNewLine = '\n'; + else + lNewLine = ''; + + return pText + lNewLine; + } + + function load(pCallBack){ Util.time(Name + ' load');