From 2478c09ec3a83cffa93e871c58e9cb552292c524 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Fri, 21 Mar 2014 16:21:59 +0400 Subject: [PATCH 1/3] require smiles to be whitespace-surrounded --- jquery-emotions/jquery.emotions.js | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/jquery-emotions/jquery.emotions.js b/jquery-emotions/jquery.emotions.js index 5603a12..78ceec4 100644 --- a/jquery-emotions/jquery.emotions.js +++ b/jquery-emotions/jquery.emotions.js @@ -81,15 +81,10 @@ var rep = $s.replacement .replace(/\{eId\}/g, $s.map[pattern]); - if (pattern[0] === ';') { - text = text - .replace(new RegExp("(^|\\W)" + $t.quote(pattern), "g"), "$1" + rep) - .replace(new RegExp("(^|\\W)" + $t.quote(encPattent), "g"), "$1" + rep); - } else { - text = text - .replace(new RegExp($t.quote(pattern), "g"), rep) - .replace(new RegExp($t.quote(encPattent), "g"), rep); - } + text = text.replace( + new RegExp("(^|\\s)(" + $t.quote(pattern) + "|" + $t.quote(encPattent) + ")(?=\\s|$)", "g"), + "$1" + rep + ); } return text; From 2a773027836b95ddbb3d97caaab94102a8ed36ae Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Fri, 21 Mar 2014 16:22:22 +0400 Subject: [PATCH 2/3] copy smiles --- jquery-emotions/jquery.emotions.calm.css | 2 ++ jquery-emotions/jquery.emotions.fb.css | 2 ++ jquery-emotions/jquery.emotions.icq.css | 2 ++ jquery-emotions/jquery.emotions.js | 2 +- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/jquery-emotions/jquery.emotions.calm.css b/jquery-emotions/jquery.emotions.calm.css index 6b3938f..3fbbee2 100644 --- a/jquery-emotions/jquery.emotions.calm.css +++ b/jquery-emotions/jquery.emotions.calm.css @@ -4,6 +4,8 @@ background: url("emotions/blank.png") no-repeat center center; display: inline-block; vertical-align: top; + color: transparent; + overflow: hidden; } .emo-angel { diff --git a/jquery-emotions/jquery.emotions.fb.css b/jquery-emotions/jquery.emotions.fb.css index c4ef1bf..df3b3f1 100644 --- a/jquery-emotions/jquery.emotions.fb.css +++ b/jquery-emotions/jquery.emotions.fb.css @@ -4,6 +4,8 @@ background: url("emotions/blank.gif") no-repeat center center; display: inline-block; vertical-align: top; + color: transparent; + overflow: hidden; } .emo-angel { diff --git a/jquery-emotions/jquery.emotions.icq.css b/jquery-emotions/jquery.emotions.icq.css index 70c1c98..b900ec9 100644 --- a/jquery-emotions/jquery.emotions.icq.css +++ b/jquery-emotions/jquery.emotions.icq.css @@ -4,6 +4,8 @@ background: url("emotions/blank.gif") no-repeat center center; display: inline-block; vertical-align: bottom; + color: transparent; + overflow: hidden; } .emo-angel { diff --git a/jquery-emotions/jquery.emotions.js b/jquery-emotions/jquery.emotions.js index 78ceec4..3677219 100644 --- a/jquery-emotions/jquery.emotions.js +++ b/jquery-emotions/jquery.emotions.js @@ -23,7 +23,7 @@ $.extend($.emotions, { settings: { - replacement: '', + replacement: '$2', map: { "o:)": "angel", "0:)": "angel", From 4e8eec970d2563482c3d745048d73a117de7c5e8 Mon Sep 17 00:00:00 2001 From: Denis Ryabov Date: Fri, 21 Mar 2014 16:22:35 +0400 Subject: [PATCH 3/3] line breaks --- js/twister_formatpost.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/js/twister_formatpost.js b/js/twister_formatpost.js index 3c90d71..ca555cd 100644 --- a/js/twister_formatpost.js +++ b/js/twister_formatpost.js @@ -157,7 +157,7 @@ function htmlFormatMsg( msg, output, mentions ) { if( match ) { index = (match[0] === match[1]) ? match.index : match.index + 1; if( match[1] == "@" ) { - output.append($.emotions(msg.substr(0, index))); + output.append(_formatText(msg.substr(0, index))); tmp = msg.substr(index+1); var username = _extractUsername(tmp); if( username.length ) { @@ -177,12 +177,13 @@ function htmlFormatMsg( msg, output, mentions ) { } if( reHttp.exec(match[1]) ) { - output.append($.emotions(msg.substr(0, index))); + output.append(_formatText(msg.substr(0, index))); tmp = msg.substring(index); var space = tmp.indexOf(" "); var url; if( space != -1 ) url = tmp.substring(0,space); else url = tmp; if( url.length ) { + url = url.replace('&', '&'); var extLinkTemplate = $("#external-page-link-template").clone(true); extLinkTemplate.removeAttr("id"); extLinkTemplate.attr("href",url); @@ -195,7 +196,7 @@ function htmlFormatMsg( msg, output, mentions ) { } if( reEmail.exec(match[1]) ) { - output.append($.emotions(msg.substr(0, index))); + output.append(_formatText(msg.substr(0, index))); tmp = msg.substring(index); var space = tmp.indexOf(" "); var email; @@ -213,7 +214,7 @@ function htmlFormatMsg( msg, output, mentions ) { } if( match[1] == "#" ) { - output.append($.emotions(msg.substr(0, index))); + output.append(_formatText(msg.substr(0, index))); tmp = msg.substr(index+1); var hashtag = _extractHashtag(tmp); if( hashtag.length ) { @@ -236,12 +237,19 @@ function htmlFormatMsg( msg, output, mentions ) { } } - output.append($.emotions(msg)); + output.append(_formatText(msg)); msg = ""; } } // internal function for htmlFormatMsg +function _formatText(msg) +{ + msg = $.emotions(msg); + msg = msg.replace(/\n/g, '
'); + return msg; +} + function _extractUsername(s) { var username = ""; for( var i = 0; i < s.length; i++ ) { @@ -272,5 +280,5 @@ function _extractHashtag(s) { } function escapeHtmlEntities(str) { - return str.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, '''); + return str.replace('&', '&').replace('<', '<').replace('>', '>').replace('"', '"').replace("'", '''); }