Convert smilies into their alt-value for manual text quotes
authorAlexander Ebert <ebert@woltlab.com>
Wed, 6 Sep 2017 13:05:20 +0000 (15:05 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 6 Sep 2017 13:05:20 +0000 (15:05 +0200)
Closes #2415

wcfsetup/install/files/js/WCF.Message.js

index 162ed17af3c39e9b4b43c49d8ae80ee1d6de9437..38d2f93bf6747b51463d6eaae79f917905a14775 100644 (file)
@@ -1181,10 +1181,16 @@ if (COMPILER_TARGET_DEFAULT) {
                        var $nodeFilter = function (node) {
                                switch (node.tagName) {
                                        case 'BLOCKQUOTE':
-                                       case 'IMG':
                                        case 'SCRIPT':
                                                return NodeFilter.FILTER_REJECT;
                                        
+                                       case 'IMG':
+                                               if (!node.classList.contains('smiley') || node.alt.length === 0) {
+                                                       return NodeFilter.FILTER_REJECT;
+                                               }
+                                               // fallthrough
+                                       
+                                       //noinspection FallthroughInSwitchStatementJS
                                        default:
                                                return NodeFilter.FILTER_ACCEPT;
                                }
@@ -1203,6 +1209,7 @@ if (COMPILER_TARGET_DEFAULT) {
                                var $node = $walker.currentNode;
                                
                                if ($node.nodeType === Node.ELEMENT_NODE) {
+                                       console.log($node);
                                        switch ($node.tagName) {
                                                case 'A':
                                                        // \u2026 === &hellip;
@@ -1235,6 +1242,11 @@ if (COMPILER_TARGET_DEFAULT) {
                                                case 'P':
                                                        $text += "\n\n";
                                                        break;
+                                                       
+                                               // smilies
+                                               case 'IMG':
+                                                       $text += " " + $node.alt + " ";
+                                                       break;
                                        }
                                }
                                else {