Adding emoticon support
authorJack Allnutt <jack@allnutt.eu>
Mon, 2 Sep 2013 04:03:14 +0000 (05:03 +0100)
committerJack Allnutt <jack@allnutt.eu>
Fri, 13 Sep 2013 21:56:12 +0000 (22:56 +0100)
Support for the following emoticons:

* :)
* :(
* :3
* ;3
* :s
* ;(
* ;)
* ;D
* :P
* xP
* :o and :O
* :D
* ^^,
* <3
* >.<
* >_<
* xD and XD
* o.0
* 0.o
* :\ and =\
* :/ and =/

Closes #260

57 files changed:
client/assets/img/emoticons/angel.png [new file with mode: 0644]
client/assets/img/emoticons/angry.png [new file with mode: 0644]
client/assets/img/emoticons/aww.png [new file with mode: 0644]
client/assets/img/emoticons/blushing.png [new file with mode: 0644]
client/assets/img/emoticons/confused.png [new file with mode: 0644]
client/assets/img/emoticons/cool.png [new file with mode: 0644]
client/assets/img/emoticons/creepy.png [new file with mode: 0644]
client/assets/img/emoticons/crying.png [new file with mode: 0644]
client/assets/img/emoticons/cthulhu.png [new file with mode: 0644]
client/assets/img/emoticons/cute.png [new file with mode: 0644]
client/assets/img/emoticons/cute_winking.png [new file with mode: 0644]
client/assets/img/emoticons/devil.png [new file with mode: 0644]
client/assets/img/emoticons/frowning.png [new file with mode: 0644]
client/assets/img/emoticons/gasping.png [new file with mode: 0644]
client/assets/img/emoticons/greedy.png [new file with mode: 0644]
client/assets/img/emoticons/grinning.png [new file with mode: 0644]
client/assets/img/emoticons/happy.png [new file with mode: 0644]
client/assets/img/emoticons/happy_smiling.png [new file with mode: 0644]
client/assets/img/emoticons/heart.png [new file with mode: 0644]
client/assets/img/emoticons/irritated.png [new file with mode: 0644]
client/assets/img/emoticons/irritated_2.png [new file with mode: 0644]
client/assets/img/emoticons/kissing.png [new file with mode: 0644]
client/assets/img/emoticons/laughing.png [new file with mode: 0644]
client/assets/img/emoticons/lips_sealed.png [new file with mode: 0644]
client/assets/img/emoticons/madness.png [new file with mode: 0644]
client/assets/img/emoticons/malicious.png [new file with mode: 0644]
client/assets/img/emoticons/naww.png [new file with mode: 0644]
client/assets/img/emoticons/pouting.png [new file with mode: 0644]
client/assets/img/emoticons/shy.png [new file with mode: 0644]
client/assets/img/emoticons/sick.png [new file with mode: 0644]
client/assets/img/emoticons/smiling.png [new file with mode: 0644]
client/assets/img/emoticons/speechless.png [new file with mode: 0644]
client/assets/img/emoticons/spiteful.png [new file with mode: 0644]
client/assets/img/emoticons/stupid.png [new file with mode: 0644]
client/assets/img/emoticons/surprised.png [new file with mode: 0644]
client/assets/img/emoticons/surprised_2.png [new file with mode: 0644]
client/assets/img/emoticons/terrified.png [new file with mode: 0644]
client/assets/img/emoticons/thumbs_down.png [new file with mode: 0644]
client/assets/img/emoticons/thumbs_up.png [new file with mode: 0644]
client/assets/img/emoticons/tired.png [new file with mode: 0644]
client/assets/img/emoticons/tongue_out.png [new file with mode: 0644]
client/assets/img/emoticons/tongue_out_laughing.png [new file with mode: 0644]
client/assets/img/emoticons/tongue_out_left.png [new file with mode: 0644]
client/assets/img/emoticons/tongue_out_up.png [new file with mode: 0644]
client/assets/img/emoticons/tongue_out_up_left.png [new file with mode: 0644]
client/assets/img/emoticons/unsure.png [new file with mode: 0644]
client/assets/img/emoticons/unsure_2.png [new file with mode: 0644]
client/assets/img/emoticons/winking.png [new file with mode: 0644]
client/assets/img/emoticons/winking_grinning.png [new file with mode: 0644]
client/assets/img/emoticons/winking_tongue_out.png [new file with mode: 0644]
client/assets/src/applets/settings.js
client/assets/src/helpers/utils.js
client/assets/src/index.html.tmpl
client/assets/src/translations/en-gb.po
client/assets/src/translations/template.po
client/assets/src/views/channel.js
config.example.js

diff --git a/client/assets/img/emoticons/angel.png b/client/assets/img/emoticons/angel.png
new file mode 100644 (file)
index 0000000..0cf707b
Binary files /dev/null and b/client/assets/img/emoticons/angel.png differ
diff --git a/client/assets/img/emoticons/angry.png b/client/assets/img/emoticons/angry.png
new file mode 100644 (file)
index 0000000..9ae5d18
Binary files /dev/null and b/client/assets/img/emoticons/angry.png differ
diff --git a/client/assets/img/emoticons/aww.png b/client/assets/img/emoticons/aww.png
new file mode 100644 (file)
index 0000000..60510bb
Binary files /dev/null and b/client/assets/img/emoticons/aww.png differ
diff --git a/client/assets/img/emoticons/blushing.png b/client/assets/img/emoticons/blushing.png
new file mode 100644 (file)
index 0000000..ab03ee8
Binary files /dev/null and b/client/assets/img/emoticons/blushing.png differ
diff --git a/client/assets/img/emoticons/confused.png b/client/assets/img/emoticons/confused.png
new file mode 100644 (file)
index 0000000..08ba7d3
Binary files /dev/null and b/client/assets/img/emoticons/confused.png differ
diff --git a/client/assets/img/emoticons/cool.png b/client/assets/img/emoticons/cool.png
new file mode 100644 (file)
index 0000000..cad8379
Binary files /dev/null and b/client/assets/img/emoticons/cool.png differ
diff --git a/client/assets/img/emoticons/creepy.png b/client/assets/img/emoticons/creepy.png
new file mode 100644 (file)
index 0000000..5615058
Binary files /dev/null and b/client/assets/img/emoticons/creepy.png differ
diff --git a/client/assets/img/emoticons/crying.png b/client/assets/img/emoticons/crying.png
new file mode 100644 (file)
index 0000000..2532976
Binary files /dev/null and b/client/assets/img/emoticons/crying.png differ
diff --git a/client/assets/img/emoticons/cthulhu.png b/client/assets/img/emoticons/cthulhu.png
new file mode 100644 (file)
index 0000000..fafc4b3
Binary files /dev/null and b/client/assets/img/emoticons/cthulhu.png differ
diff --git a/client/assets/img/emoticons/cute.png b/client/assets/img/emoticons/cute.png
new file mode 100644 (file)
index 0000000..a883ac3
Binary files /dev/null and b/client/assets/img/emoticons/cute.png differ
diff --git a/client/assets/img/emoticons/cute_winking.png b/client/assets/img/emoticons/cute_winking.png
new file mode 100644 (file)
index 0000000..ad3383d
Binary files /dev/null and b/client/assets/img/emoticons/cute_winking.png differ
diff --git a/client/assets/img/emoticons/devil.png b/client/assets/img/emoticons/devil.png
new file mode 100644 (file)
index 0000000..afc5c2c
Binary files /dev/null and b/client/assets/img/emoticons/devil.png differ
diff --git a/client/assets/img/emoticons/frowning.png b/client/assets/img/emoticons/frowning.png
new file mode 100644 (file)
index 0000000..79fc0c0
Binary files /dev/null and b/client/assets/img/emoticons/frowning.png differ
diff --git a/client/assets/img/emoticons/gasping.png b/client/assets/img/emoticons/gasping.png
new file mode 100644 (file)
index 0000000..b6655ce
Binary files /dev/null and b/client/assets/img/emoticons/gasping.png differ
diff --git a/client/assets/img/emoticons/greedy.png b/client/assets/img/emoticons/greedy.png
new file mode 100644 (file)
index 0000000..a179638
Binary files /dev/null and b/client/assets/img/emoticons/greedy.png differ
diff --git a/client/assets/img/emoticons/grinning.png b/client/assets/img/emoticons/grinning.png
new file mode 100644 (file)
index 0000000..85ff915
Binary files /dev/null and b/client/assets/img/emoticons/grinning.png differ
diff --git a/client/assets/img/emoticons/happy.png b/client/assets/img/emoticons/happy.png
new file mode 100644 (file)
index 0000000..51cf1a2
Binary files /dev/null and b/client/assets/img/emoticons/happy.png differ
diff --git a/client/assets/img/emoticons/happy_smiling.png b/client/assets/img/emoticons/happy_smiling.png
new file mode 100644 (file)
index 0000000..1332686
Binary files /dev/null and b/client/assets/img/emoticons/happy_smiling.png differ
diff --git a/client/assets/img/emoticons/heart.png b/client/assets/img/emoticons/heart.png
new file mode 100644 (file)
index 0000000..dcd28b9
Binary files /dev/null and b/client/assets/img/emoticons/heart.png differ
diff --git a/client/assets/img/emoticons/irritated.png b/client/assets/img/emoticons/irritated.png
new file mode 100644 (file)
index 0000000..b03ee1b
Binary files /dev/null and b/client/assets/img/emoticons/irritated.png differ
diff --git a/client/assets/img/emoticons/irritated_2.png b/client/assets/img/emoticons/irritated_2.png
new file mode 100644 (file)
index 0000000..b682458
Binary files /dev/null and b/client/assets/img/emoticons/irritated_2.png differ
diff --git a/client/assets/img/emoticons/kissing.png b/client/assets/img/emoticons/kissing.png
new file mode 100644 (file)
index 0000000..05509de
Binary files /dev/null and b/client/assets/img/emoticons/kissing.png differ
diff --git a/client/assets/img/emoticons/laughing.png b/client/assets/img/emoticons/laughing.png
new file mode 100644 (file)
index 0000000..edefc95
Binary files /dev/null and b/client/assets/img/emoticons/laughing.png differ
diff --git a/client/assets/img/emoticons/lips_sealed.png b/client/assets/img/emoticons/lips_sealed.png
new file mode 100644 (file)
index 0000000..46e4701
Binary files /dev/null and b/client/assets/img/emoticons/lips_sealed.png differ
diff --git a/client/assets/img/emoticons/madness.png b/client/assets/img/emoticons/madness.png
new file mode 100644 (file)
index 0000000..1c0946c
Binary files /dev/null and b/client/assets/img/emoticons/madness.png differ
diff --git a/client/assets/img/emoticons/malicious.png b/client/assets/img/emoticons/malicious.png
new file mode 100644 (file)
index 0000000..23f2579
Binary files /dev/null and b/client/assets/img/emoticons/malicious.png differ
diff --git a/client/assets/img/emoticons/naww.png b/client/assets/img/emoticons/naww.png
new file mode 100644 (file)
index 0000000..3512863
Binary files /dev/null and b/client/assets/img/emoticons/naww.png differ
diff --git a/client/assets/img/emoticons/pouting.png b/client/assets/img/emoticons/pouting.png
new file mode 100644 (file)
index 0000000..1a31c50
Binary files /dev/null and b/client/assets/img/emoticons/pouting.png differ
diff --git a/client/assets/img/emoticons/shy.png b/client/assets/img/emoticons/shy.png
new file mode 100644 (file)
index 0000000..be79df0
Binary files /dev/null and b/client/assets/img/emoticons/shy.png differ
diff --git a/client/assets/img/emoticons/sick.png b/client/assets/img/emoticons/sick.png
new file mode 100644 (file)
index 0000000..6f73e2f
Binary files /dev/null and b/client/assets/img/emoticons/sick.png differ
diff --git a/client/assets/img/emoticons/smiling.png b/client/assets/img/emoticons/smiling.png
new file mode 100644 (file)
index 0000000..725eef5
Binary files /dev/null and b/client/assets/img/emoticons/smiling.png differ
diff --git a/client/assets/img/emoticons/speechless.png b/client/assets/img/emoticons/speechless.png
new file mode 100644 (file)
index 0000000..4fc4246
Binary files /dev/null and b/client/assets/img/emoticons/speechless.png differ
diff --git a/client/assets/img/emoticons/spiteful.png b/client/assets/img/emoticons/spiteful.png
new file mode 100644 (file)
index 0000000..195ced8
Binary files /dev/null and b/client/assets/img/emoticons/spiteful.png differ
diff --git a/client/assets/img/emoticons/stupid.png b/client/assets/img/emoticons/stupid.png
new file mode 100644 (file)
index 0000000..3fcea49
Binary files /dev/null and b/client/assets/img/emoticons/stupid.png differ
diff --git a/client/assets/img/emoticons/surprised.png b/client/assets/img/emoticons/surprised.png
new file mode 100644 (file)
index 0000000..241f50f
Binary files /dev/null and b/client/assets/img/emoticons/surprised.png differ
diff --git a/client/assets/img/emoticons/surprised_2.png b/client/assets/img/emoticons/surprised_2.png
new file mode 100644 (file)
index 0000000..a1a54e4
Binary files /dev/null and b/client/assets/img/emoticons/surprised_2.png differ
diff --git a/client/assets/img/emoticons/terrified.png b/client/assets/img/emoticons/terrified.png
new file mode 100644 (file)
index 0000000..fad2e06
Binary files /dev/null and b/client/assets/img/emoticons/terrified.png differ
diff --git a/client/assets/img/emoticons/thumbs_down.png b/client/assets/img/emoticons/thumbs_down.png
new file mode 100644 (file)
index 0000000..4f70696
Binary files /dev/null and b/client/assets/img/emoticons/thumbs_down.png differ
diff --git a/client/assets/img/emoticons/thumbs_up.png b/client/assets/img/emoticons/thumbs_up.png
new file mode 100644 (file)
index 0000000..2ca0e0d
Binary files /dev/null and b/client/assets/img/emoticons/thumbs_up.png differ
diff --git a/client/assets/img/emoticons/tired.png b/client/assets/img/emoticons/tired.png
new file mode 100644 (file)
index 0000000..13f7d12
Binary files /dev/null and b/client/assets/img/emoticons/tired.png differ
diff --git a/client/assets/img/emoticons/tongue_out.png b/client/assets/img/emoticons/tongue_out.png
new file mode 100644 (file)
index 0000000..3d154f9
Binary files /dev/null and b/client/assets/img/emoticons/tongue_out.png differ
diff --git a/client/assets/img/emoticons/tongue_out_laughing.png b/client/assets/img/emoticons/tongue_out_laughing.png
new file mode 100644 (file)
index 0000000..fba5d75
Binary files /dev/null and b/client/assets/img/emoticons/tongue_out_laughing.png differ
diff --git a/client/assets/img/emoticons/tongue_out_left.png b/client/assets/img/emoticons/tongue_out_left.png
new file mode 100644 (file)
index 0000000..8015de7
Binary files /dev/null and b/client/assets/img/emoticons/tongue_out_left.png differ
diff --git a/client/assets/img/emoticons/tongue_out_up.png b/client/assets/img/emoticons/tongue_out_up.png
new file mode 100644 (file)
index 0000000..46328fb
Binary files /dev/null and b/client/assets/img/emoticons/tongue_out_up.png differ
diff --git a/client/assets/img/emoticons/tongue_out_up_left.png b/client/assets/img/emoticons/tongue_out_up_left.png
new file mode 100644 (file)
index 0000000..b67b69f
Binary files /dev/null and b/client/assets/img/emoticons/tongue_out_up_left.png differ
diff --git a/client/assets/img/emoticons/unsure.png b/client/assets/img/emoticons/unsure.png
new file mode 100644 (file)
index 0000000..7176856
Binary files /dev/null and b/client/assets/img/emoticons/unsure.png differ
diff --git a/client/assets/img/emoticons/unsure_2.png b/client/assets/img/emoticons/unsure_2.png
new file mode 100644 (file)
index 0000000..a7f5370
Binary files /dev/null and b/client/assets/img/emoticons/unsure_2.png differ
diff --git a/client/assets/img/emoticons/winking.png b/client/assets/img/emoticons/winking.png
new file mode 100644 (file)
index 0000000..1e01f94
Binary files /dev/null and b/client/assets/img/emoticons/winking.png differ
diff --git a/client/assets/img/emoticons/winking_grinning.png b/client/assets/img/emoticons/winking_grinning.png
new file mode 100644 (file)
index 0000000..5b1d5b7
Binary files /dev/null and b/client/assets/img/emoticons/winking_grinning.png differ
diff --git a/client/assets/img/emoticons/winking_tongue_out.png b/client/assets/img/emoticons/winking_tongue_out.png
new file mode 100644 (file)
index 0000000..2a22cf6
Binary files /dev/null and b/client/assets/img/emoticons/winking_tongue_out.png differ
index f9ee8adbcf5e36675a1c05de816416ea1029fd3f..32bf8554b8e31a8fb55ef91f7b75eddb253b823c 100644 (file)
@@ -15,6 +15,7 @@
                 join_part: _kiwi.global.i18n.translate('client_applets_settings_notification_joinpart').fetch(),\r
                 timestamps: _kiwi.global.i18n.translate('client_applets_settings_timestamp').fetch(),\r
                 mute: _kiwi.global.i18n.translate('client_applets_settings_notification_sound').fetch(),\r
+                emoticons: _kiwi.global.i18n.translate('client_applets_settings_emoticons').fetch(),\r
                 scroll_history: _kiwi.global.i18n.translate('client_applets_settings_history_length').fetch(),\r
                 languages: _kiwi.app.translations,\r
                 default_client: _kiwi.global.i18n.translate('client_applets_settings_default_client').fetch(),\r
index 6837a508b8af2de659ba425ef5291022fe732be6..99378bc50e45baeabb9186a39a3c81995537e000 100644 (file)
@@ -362,3 +362,88 @@ function formatDate (d) {
 function escapeRegex (str) {
     return str.replace(/[\[\\\^\$\.\|\?\*\+\(\)]/g, '\\$&');
 }
+
+function emoticonFromText(str) {
+    var words_in = str.split(' '),
+        words_out = [],
+        i,
+        pushEmoticon = function (alt, img) {
+            words_out.push('<img src="' + _kiwi.app.get('base_path') + '/assets/img/emoticons/' + img + '" alt="' + alt + ' " />');
+        };
+
+    for (i = 0; i < words_in.length; i++) {
+        switch(words_in[i]) {
+        case ':)':
+            pushEmoticon(':)', 'smiling.png');
+            break;
+        case ':(':
+            pushEmoticon(':(', 'frowning.png');
+            break;
+        case ':3':
+            pushEmoticon(':3', 'cute.png');
+            break;
+        case ';3':
+            pushEmoticon(';3', 'cute_winking.png');
+            break;
+        case ':s':
+            pushEmoticon(':s', 'confused.png');
+            break;
+        case ';(':
+            pushEmoticon(';(', 'crying.png');
+            break;
+        case ';)':
+            pushEmoticon(';)', 'winking.png');
+            break;
+        case ';D':
+            pushEmoticon(';D"', 'winking_grinning.png');
+            break;
+        case ':P':
+            pushEmoticon(':P', 'tongue_out.png');
+            break;
+        case 'xP':
+            pushEmoticon('xP', 'tongue_out_laughing.png');
+            break;
+        case ':o':
+        case ':O':
+            pushEmoticon(':o', 'gasping.png');
+            break;
+        case ':D':
+            pushEmoticon(':D', 'grinning.png');
+            break;
+        case '^^,':
+            pushEmoticon('^^,', 'happy.png');
+            break;
+        case '&lt;3':
+            pushEmoticon('<3', 'heart.png');
+            break;
+        case '&gt;.&lt;':
+            pushEmoticon('>.<', 'irritated_2.png');
+            break;
+        case '&gt;_&lt;':
+            pushEmoticon('>_<', 'irritated.png');
+            break;
+        case 'XD':
+        case 'xD':
+            pushEmoticon('xD', 'laughing.png');
+            break;
+        case 'o.0':
+            pushEmoticon('o.0', 'surprised.png');
+            break;
+        case '0.o':
+            pushEmoticon('0.o', 'surprised_2.png');
+            break;
+        case ':\\':
+        case '=\\':
+            pushEmoticon(':\\', 'unsure.png');
+            break;
+        case ':/':
+        case '=/':
+            pushEmoticon(':/', 'unsure_2.png');
+            break;
+        default:
+            words_out.push(words_in[i]);
+        }
+    }
+
+    return words_out.join(' ');
+}
index a50c93dd069047c7fbdc306e30dec96c7b1f1132..1f3f09cd438aad8c2f943c9631074ee876176a41 100644 (file)
                             <%= mute %>\r
                         </label>\r
                     </div>\r
+                    <div class="checkbox">\r
+                        <label>\r
+                            <input data-setting="show_emoticons" type="checkbox">\r
+                            <%= emoticons %>\r
+                        </label>\r
+                    </div>\r
                     <label>\r
                         <input data-setting="scrollback" class="input-small" type="text" size="4" pattern="\d*">\r
                         <span><%= scroll_history %></span>\r
index db5c47bd102db9266690504159b165769117140d..579a32f2df1abf5f56ff593bbc9431cf1d8fd133 100755 (executable)
@@ -64,6 +64,10 @@ msgid "client_applets_settings_notification_sound"
 msgstr "Mute sound notifications"
 
 #:
+msgid "client_applets_settings_emoticons"
+msgstr "Emoticons"
+
+#: 
 msgid "client_applets_settings_history_length"
 msgstr "messages in scroll history"
 
index 7e6a59a5dcde807b342497d05a3cc0c608acc519..b45bb0b11d4cfc1a6a1e9f74e22a816d570dd31a 100755 (executable)
@@ -48,6 +48,9 @@ msgstr ""
 msgid "client_applets_settings_notification_sound"\r
 msgstr ""\r
 \r
+msgid "client_applets_settings_emoticons"\r
+msgstr ""\r
+\r
 msgid "client_applets_settings_history_length"\r
 msgstr ""\r
 \r
index 3dd89ca216f3c6a15bc9898971a12d34180820d7..b6b32f3393e1131023ebcd750c3b858573f1549a 100644 (file)
@@ -92,6 +92,10 @@ _kiwi.view.Channel = _kiwi.view.Panel.extend({
         // Convert IRC formatting into HTML formatting
         msg.msg = formatIRCMsg(msg.msg);
 
+        // Replace text emoticons with images
+        if (_kiwi.global.settings.get('show_emoticons')) {
+            msg.msg = emoticonFromText(msg.msg);
+        }
 
         // Add some colours to the nick (Method based on IRSSIs nickcolor.pl)
         nick_colour_hex = (function (nick) {
index 83071a8bc23a543a923d4a3bd822103fe991b6ca..43ab2d9ec682243ac82900b114438a01af2586f1 100644 (file)
@@ -188,7 +188,8 @@ conf.client = {
         scrollback: 250,
         show_joins_parts: true,
         show_timestamps: false,
-        mute_sounds: false
+        mute_sounds: false,
+        show_emoticons: true
     }
 };