twister
+
@@ -28,6 +29,7 @@
+
diff --git a/jquery-emotions/README.md b/jquery-emotions/README.md
new file mode 100644
index 0000000..43a7083
--- /dev/null
+++ b/jquery-emotions/README.md
@@ -0,0 +1,40 @@
+# Emotions: a jQuery plugin
+
+Emotions is a jQuery plugin that makes it easy to convert some emotion text to images. ( e.g. 8) => img )
+
+## Usage
+
+First, load css, jQuery and the plugin:
+
+```html
+
+
+
+```
+
+Now, let's attach it to your dom elements:
+
+```html
+
+```
+
+Create dom elements which text should be transformed:
+
+```html
+
Some text with smile 8)
+
o.O o.O o.O :D :D :D
+
o:) o.O 3:) :D <3 :* :) 8| :/ ;) :'( :( 8) >:( :p
+```
+
+## Links
+[Смайлы в чате как в Facebook или ICQ c помощью JQuery](http://www.itlessons.info/javascript/facebook-or-icq-jquery-emotions-plugin/)
+
+## Author
+[itlessons](http://www.itlessons.info) ([@itlessonsinfo](http://twitter.com/itlessonsinfo))
+
+## Other
+[MIT License](http://www.opensource.org/licenses/mit-license.php)
\ No newline at end of file
diff --git a/jquery-emotions/emotions/blank.gif b/jquery-emotions/emotions/blank.gif
new file mode 100644
index 0000000..35d42e8
Binary files /dev/null and b/jquery-emotions/emotions/blank.gif differ
diff --git a/jquery-emotions/emotions/fb/angel.gif b/jquery-emotions/emotions/fb/angel.gif
new file mode 100644
index 0000000..d3406d0
Binary files /dev/null and b/jquery-emotions/emotions/fb/angel.gif differ
diff --git a/jquery-emotions/emotions/fb/confused.gif b/jquery-emotions/emotions/fb/confused.gif
new file mode 100644
index 0000000..db19a0a
Binary files /dev/null and b/jquery-emotions/emotions/fb/confused.gif differ
diff --git a/jquery-emotions/emotions/fb/cry.gif b/jquery-emotions/emotions/fb/cry.gif
new file mode 100644
index 0000000..f2ebdee
Binary files /dev/null and b/jquery-emotions/emotions/fb/cry.gif differ
diff --git a/jquery-emotions/emotions/fb/devil.gif b/jquery-emotions/emotions/fb/devil.gif
new file mode 100644
index 0000000..2551727
Binary files /dev/null and b/jquery-emotions/emotions/fb/devil.gif differ
diff --git a/jquery-emotions/emotions/fb/frown.gif b/jquery-emotions/emotions/fb/frown.gif
new file mode 100644
index 0000000..9003495
Binary files /dev/null and b/jquery-emotions/emotions/fb/frown.gif differ
diff --git a/jquery-emotions/emotions/fb/glasses.gif b/jquery-emotions/emotions/fb/glasses.gif
new file mode 100644
index 0000000..f08c2ee
Binary files /dev/null and b/jquery-emotions/emotions/fb/glasses.gif differ
diff --git a/jquery-emotions/emotions/fb/grin.gif b/jquery-emotions/emotions/fb/grin.gif
new file mode 100644
index 0000000..365fac4
Binary files /dev/null and b/jquery-emotions/emotions/fb/grin.gif differ
diff --git a/jquery-emotions/emotions/fb/grumpy.gif b/jquery-emotions/emotions/fb/grumpy.gif
new file mode 100644
index 0000000..ad38393
Binary files /dev/null and b/jquery-emotions/emotions/fb/grumpy.gif differ
diff --git a/jquery-emotions/emotions/fb/heart.gif b/jquery-emotions/emotions/fb/heart.gif
new file mode 100644
index 0000000..fda9aaf
Binary files /dev/null and b/jquery-emotions/emotions/fb/heart.gif differ
diff --git a/jquery-emotions/emotions/fb/kiss.gif b/jquery-emotions/emotions/fb/kiss.gif
new file mode 100644
index 0000000..4894d77
Binary files /dev/null and b/jquery-emotions/emotions/fb/kiss.gif differ
diff --git a/jquery-emotions/emotions/fb/smile.gif b/jquery-emotions/emotions/fb/smile.gif
new file mode 100644
index 0000000..5f0ec71
Binary files /dev/null and b/jquery-emotions/emotions/fb/smile.gif differ
diff --git a/jquery-emotions/emotions/fb/sunglasses.gif b/jquery-emotions/emotions/fb/sunglasses.gif
new file mode 100644
index 0000000..0b5d2a1
Binary files /dev/null and b/jquery-emotions/emotions/fb/sunglasses.gif differ
diff --git a/jquery-emotions/emotions/fb/tongue.gif b/jquery-emotions/emotions/fb/tongue.gif
new file mode 100644
index 0000000..865dc2e
Binary files /dev/null and b/jquery-emotions/emotions/fb/tongue.gif differ
diff --git a/jquery-emotions/emotions/fb/unsure.gif b/jquery-emotions/emotions/fb/unsure.gif
new file mode 100644
index 0000000..6348a00
Binary files /dev/null and b/jquery-emotions/emotions/fb/unsure.gif differ
diff --git a/jquery-emotions/emotions/fb/wink.gif b/jquery-emotions/emotions/fb/wink.gif
new file mode 100644
index 0000000..8246f2c
Binary files /dev/null and b/jquery-emotions/emotions/fb/wink.gif differ
diff --git a/jquery-emotions/emotions/icq/angel.gif b/jquery-emotions/emotions/icq/angel.gif
new file mode 100644
index 0000000..abf9ad4
Binary files /dev/null and b/jquery-emotions/emotions/icq/angel.gif differ
diff --git a/jquery-emotions/emotions/icq/confused.gif b/jquery-emotions/emotions/icq/confused.gif
new file mode 100644
index 0000000..7f951d2
Binary files /dev/null and b/jquery-emotions/emotions/icq/confused.gif differ
diff --git a/jquery-emotions/emotions/icq/cry.gif b/jquery-emotions/emotions/icq/cry.gif
new file mode 100644
index 0000000..48ca016
Binary files /dev/null and b/jquery-emotions/emotions/icq/cry.gif differ
diff --git a/jquery-emotions/emotions/icq/devil.gif b/jquery-emotions/emotions/icq/devil.gif
new file mode 100644
index 0000000..7866ca5
Binary files /dev/null and b/jquery-emotions/emotions/icq/devil.gif differ
diff --git a/jquery-emotions/emotions/icq/frown.gif b/jquery-emotions/emotions/icq/frown.gif
new file mode 100644
index 0000000..58fcb82
Binary files /dev/null and b/jquery-emotions/emotions/icq/frown.gif differ
diff --git a/jquery-emotions/emotions/icq/glasses.gif b/jquery-emotions/emotions/icq/glasses.gif
new file mode 100644
index 0000000..de3729d
Binary files /dev/null and b/jquery-emotions/emotions/icq/glasses.gif differ
diff --git a/jquery-emotions/emotions/icq/grin.gif b/jquery-emotions/emotions/icq/grin.gif
new file mode 100644
index 0000000..57cdcdb
Binary files /dev/null and b/jquery-emotions/emotions/icq/grin.gif differ
diff --git a/jquery-emotions/emotions/icq/grumpy.gif b/jquery-emotions/emotions/icq/grumpy.gif
new file mode 100644
index 0000000..9755722
Binary files /dev/null and b/jquery-emotions/emotions/icq/grumpy.gif differ
diff --git a/jquery-emotions/emotions/icq/heart.gif b/jquery-emotions/emotions/icq/heart.gif
new file mode 100644
index 0000000..20a6dbc
Binary files /dev/null and b/jquery-emotions/emotions/icq/heart.gif differ
diff --git a/jquery-emotions/emotions/icq/kiss.gif b/jquery-emotions/emotions/icq/kiss.gif
new file mode 100644
index 0000000..0990066
Binary files /dev/null and b/jquery-emotions/emotions/icq/kiss.gif differ
diff --git a/jquery-emotions/emotions/icq/smile.gif b/jquery-emotions/emotions/icq/smile.gif
new file mode 100644
index 0000000..bb40e6d
Binary files /dev/null and b/jquery-emotions/emotions/icq/smile.gif differ
diff --git a/jquery-emotions/emotions/icq/sunglasses.gif b/jquery-emotions/emotions/icq/sunglasses.gif
new file mode 100644
index 0000000..96f8e51
Binary files /dev/null and b/jquery-emotions/emotions/icq/sunglasses.gif differ
diff --git a/jquery-emotions/emotions/icq/tongue.gif b/jquery-emotions/emotions/icq/tongue.gif
new file mode 100644
index 0000000..48f9c3d
Binary files /dev/null and b/jquery-emotions/emotions/icq/tongue.gif differ
diff --git a/jquery-emotions/emotions/icq/unsure.gif b/jquery-emotions/emotions/icq/unsure.gif
new file mode 100644
index 0000000..0454811
Binary files /dev/null and b/jquery-emotions/emotions/icq/unsure.gif differ
diff --git a/jquery-emotions/emotions/icq/wink.gif b/jquery-emotions/emotions/icq/wink.gif
new file mode 100644
index 0000000..057cfb6
Binary files /dev/null and b/jquery-emotions/emotions/icq/wink.gif differ
diff --git a/jquery-emotions/jquery.emotions.fb.css b/jquery-emotions/jquery.emotions.fb.css
new file mode 100644
index 0000000..9486d12
--- /dev/null
+++ b/jquery-emotions/jquery.emotions.fb.css
@@ -0,0 +1,71 @@
+.emotions {
+ width: 14px;
+ height: 14px;
+ background: url("emotions/blank.gif") no-repeat center center;
+ display: inline-block;
+ vertical-align: top;
+}
+
+.emo-angel {
+ background: url("emotions/fb/angel.gif");
+ width: 16px;
+ height: 15px;
+}
+
+.emo-confused {
+ background: url("emotions/fb/confused.gif");
+}
+
+.emo-devil {
+ background: url("emotions/fb/devil.gif");
+ height: 15px;
+}
+
+.emo-grin {
+ background: url("emotions/fb/grin.gif");
+}
+
+.emo-heart {
+ background: url("emotions/fb/heart.gif");
+ width: 15px;
+}
+
+.emo-kiss {
+ background: url("emotions/fb/kiss.gif");
+}
+
+.emo-smile {
+ background: url("emotions/fb/smile.gif");
+}
+
+.emo-sunglasses {
+ background: url("emotions/fb/sunglasses.gif");
+}
+
+.emo-unsure {
+ background: url("emotions/fb/unsure.gif");
+}
+
+.emo-wink {
+ background: url("emotions/fb/wink.gif");
+}
+
+.emo-cry {
+ background: url("emotions/fb/cry.gif");
+}
+
+.emo-glasses {
+ background: url("emotions/fb/glasses.gif");
+}
+
+.emo-grumpy {
+ background: url("emotions/fb/grumpy.gif");
+}
+
+.emo-tongue {
+ background: url("emotions/fb/tongue.gif");
+}
+
+.emo-frown {
+ background: url("emotions/fb/frown.gif");
+}
\ No newline at end of file
diff --git a/jquery-emotions/jquery.emotions.icq.css b/jquery-emotions/jquery.emotions.icq.css
new file mode 100644
index 0000000..70c1c98
--- /dev/null
+++ b/jquery-emotions/jquery.emotions.icq.css
@@ -0,0 +1,67 @@
+.emotions {
+ width: 20px;
+ height: 20px;
+ background: url("emotions/blank.gif") no-repeat center center;
+ display: inline-block;
+ vertical-align: bottom;
+}
+
+.emo-angel {
+ background: url("emotions/icq/angel.gif");
+}
+
+.emo-confused {
+ background: url("emotions/icq/confused.gif");
+}
+
+.emo-devil {
+ background: url("emotions/icq/devil.gif");
+}
+
+.emo-grin {
+ background: url("emotions/icq/grin.gif");
+}
+
+.emo-heart {
+ background: url("emotions/icq/heart.gif");
+}
+
+.emo-kiss {
+ background: url("emotions/icq/kiss.gif");
+}
+
+.emo-smile {
+ background: url("emotions/icq/smile.gif");
+}
+
+.emo-sunglasses {
+ background: url("emotions/icq/sunglasses.gif");
+}
+
+.emo-unsure {
+ background: url("emotions/icq/unsure.gif");
+}
+
+.emo-wink {
+ background: url("emotions/icq/wink.gif");
+}
+
+.emo-cry {
+ background: url("emotions/icq/cry.gif");
+}
+
+.emo-glasses {
+ background: url("emotions/icq/glasses.gif");
+}
+
+.emo-grumpy {
+ background: url("emotions/icq/grumpy.gif");
+}
+
+.emo-tongue {
+ background: url("emotions/icq/tongue.gif");
+}
+
+.emo-frown {
+ background: url("emotions/icq/frown.gif");
+}
diff --git a/jquery-emotions/jquery.emotions.js b/jquery-emotions/jquery.emotions.js
new file mode 100644
index 0000000..80cb809
--- /dev/null
+++ b/jquery-emotions/jquery.emotions.js
@@ -0,0 +1,97 @@
+/**
+ * Emotions is a jQuery plugin that makes it easy to convert some emotion text to images (e.g 8) )
+ *
+ * @name emotions
+ * @version 0.0.1
+ * @requires jQuery v1.2.3+
+ * @license MIT License - http://www.opensource.org/licenses/mit-license.php
+ *
+ * For usage and examples, visit:
+ * https://github.com/itlessons/jquery-emotions
+ * http://www.itlessons.info/javascript/facebook-or-icq-jquery-emotions-plugin/
+ *
+ * Copyright (c) 2013, www.itlessons.info
+ */
+(function ($) {
+
+ $.emotions = function (text) {
+ return $.emotions.parse(text);
+ };
+
+ var $t = $.emotions;
+
+ $.extend($.emotions, {
+
+ settings: {
+ replacement: '',
+ map: {
+ "o:)": "angel",
+ "o.O": "confused",
+ "3:)": "devil",
+ "<3": "heart",
+ ":*": "kiss",
+ ":-)": "smile",
+ ":]": "smile",
+ "8|": "sunglasses",
+ ":/": "unsure",
+ ";)": "wink",
+ ":'(": "cry",
+ ">:(": "grumpy",
+ ":(": "frown",
+ "8)": "glasses",
+ ":p": "tongue",
+ ":)": "smile",
+ "=)": "smile",
+ ":D": "grin"
+ }
+ },
+ shortcode: function(eId){
+ var $s = $t.settings;
+ for (var pattern in $s.map) {
+ if($s.map[pattern] == eId)
+ return pattern;
+ }
+
+ return "";
+ },
+ parse: function (text) {
+
+ var $s = $t.settings;
+
+ for (var pattern in $s.map) {
+
+ var encPattent = $t.encode(pattern);
+
+ if (text.indexOf(pattern) < 0 && text.indexOf(encPattent) < 0) {
+ continue;
+ }
+
+ var rep = $s.replacement
+ .replace(/\{eId\}/g, $s.map[pattern]);
+
+ text = text
+ .replace(new RegExp($t.quote(pattern), "g"), rep)
+ .replace(new RegExp($t.quote(encPattent), "g"), rep);
+ }
+
+ return text;
+ },
+ encode: function (str) {
+ return (str + '')
+ .replace(/&/g, '&')
+ .replace(//g, '>')
+ .replace(/"/g, '"');
+ },
+ quote: function (str) {
+ return (str + '').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
+ }
+ });
+
+ $.fn.emotions = function (action, options) {
+ this.each(function () {
+ var el = $(this);
+ el.html($.emotions(el.html()));
+ });
+ };
+})(jQuery);
\ No newline at end of file
diff --git a/js/twister_formatpost.js b/js/twister_formatpost.js
index 8e8fc18..47ff029 100644
--- a/js/twister_formatpost.js
+++ b/js/twister_formatpost.js
@@ -153,7 +153,7 @@ function htmlFormatMsg( msg, output, mentions ) {
match = reAll.exec(msg);
if( match ) {
if( match[0] == "@" ) {
- output.append(msg.substr(0, match.index));
+ output.append($.emotions(msg.substr(0, match.index)));
tmp = msg.substr(match.index+1);
var username = _extractUsername(tmp);
if( username.length ) {
@@ -170,7 +170,7 @@ function htmlFormatMsg( msg, output, mentions ) {
}
if( reHttp.exec(match[0]) ) {
- output.append(msg.substr(0, match.index));
+ output.append($.emotions(msg.substr(0, match.index)));
tmp = msg.substring(match.index);
var space = tmp.indexOf(" ");
var url;
@@ -188,7 +188,7 @@ function htmlFormatMsg( msg, output, mentions ) {
}
if( match[0] == "#" ) {
- output.append(msg.substr(0, match.index));
+ output.append($.emotions(msg.substr(0, match.index)));
tmp = msg.substr(match.index+1);
var hashtag = _extractUsername(tmp);
if( hashtag.length ) {
@@ -203,7 +203,7 @@ function htmlFormatMsg( msg, output, mentions ) {
}
}
- output.append(msg);
+ output.append($.emotions(msg));
msg = "";
}
}