diff --git a/js/misc-functions.js b/js/misc-functions.js index d9be7e9..73f23c5 100644 --- a/js/misc-functions.js +++ b/js/misc-functions.js @@ -643,7 +643,9 @@ function qOrAmp(stream) { function countCharsInQueetBox(src,trgt,btn) { - var $src_txt = $('
').append($.trim(src.text().replace(/^\s+|\s+$/g, ''))); + // count linebreaks by converting them to spaces + var $src_txt = $('
').append(src.html().replace(/
/g,' ')); + $src_txt = $('
').append($.trim($src_txt.text().replace(/\n/g,'').replace(/^\s+|\s+$/g, ''))); var numchars = ($src_txt.text()).length; // check for long urls and disable/enable url shorten button if present diff --git a/js/qvitter.js b/js/qvitter.js index 4b07dca..6f30474 100644 --- a/js/qvitter.js +++ b/js/qvitter.js @@ -263,7 +263,6 @@ $(window).load(function() { // login or not if(window.loggedIn) { - console.log('logged in user: ' + window.loggedIn.screen_name); doLogin(getStreamFromUrl()); } else { @@ -1508,9 +1507,16 @@ $('body').on('click', '.queet-toolbar button',function () { var queetBox = $(this).parent().parent().siblings('.queet-box'); var queetBoxID = queetBox.attr('id'); - - var queetText = $.trim(queetBox.text().replace(/^\s+|\s+$/g, '')); - var queetHtml = '
' + replaceHtmlSpecialChars(queetText.replace(/\n/g,'
')) + '
'; + + // jquery's .text() function is not consistent in converting
:s to \n:s, + // so we do this detour to make sure line breaks are preserved + queetBox.html(queetBox.html().replace(/
/g, '{{{lb}}}')); + var queetText = $.trim(queetBox.text().replace(/^\s+|\s+$/g, '').replace(/\n/g, '')); + queetText = queetText.replace(/{{{lb}}}/g, "\n"); + + var queetTempText = replaceHtmlSpecialChars(queetText.replace(/\n/g,'
')); // no xss + queetTempText = queetTempText.replace(/<br>/g,'
'); // but preserve line breaks + var queetHtml = '
'; queetHtml = detectRTL(queetHtml); // popup reply @@ -1745,7 +1751,7 @@ $('body').on('mouseup', 'div.syntax-two', function(e){ function stripHtmlFromPaste(e) { e.preventDefault(); var text = replaceHtmlSpecialChars(e.clipboardData.getData("text/plain")); - text = text.replace("\n",'
'); // keep line-breaks + text = text.replace(/\n/g,'
').replace(/\t/g, '    '); // keep line-breaks and tabs document.execCommand("insertHTML", false, text); }