diff --git a/assets/js/common/functionsSchema.js b/assets/js/common/functionsSchema.js index 87b1e94a..d56ab1ef 100644 --- a/assets/js/common/functionsSchema.js +++ b/assets/js/common/functionsSchema.js @@ -593,6 +593,13 @@ var ComunicWeb = { parser: { //TODO : implement }, + + /** + * Emojies list + */ + list: { + //TODO : implement + }, }, }, diff --git a/assets/js/components/emoji/list.js b/assets/js/components/emoji/list.js new file mode 100644 index 00000000..de6a0810 --- /dev/null +++ b/assets/js/components/emoji/list.js @@ -0,0 +1,26 @@ +/** + * Emojies list + * + * @author Pierre HUBERT + */ + +ComunicWeb.components.emoji.list = { + + /** + * Emojies translation list + */ + translation: { + //Heads + ":)": "😀", + ":(": "😥", + ":D": "😁", + ":P": "😛", + "(devil)": "😈", + ":O": "😲", + "(cool)": "😎", + + //Objects + "(movie)": "📽", + } + +} \ No newline at end of file diff --git a/assets/js/components/emoji/parser.js b/assets/js/components/emoji/parser.js index ab4c2516..0d280fdd 100644 --- a/assets/js/components/emoji/parser.js +++ b/assets/js/components/emoji/parser.js @@ -23,6 +23,8 @@ ComunicWeb.components.emoji.parser = { */ parse: function(infos){ + //Peform string parsing + infos.element.innerHTML = this.shorcutToHTMLcode(infos.element.innerHTML); //Perform Twitter parsing this.twitterEmojiesParsing(infos.element); @@ -48,4 +50,27 @@ ComunicWeb.components.emoji.parser = { return true; }, + /** + * Perform shorcut emoji to HTML code parsing + * + * @param {String} string The input string + * @return {String} The output string + */ + shorcutToHTMLcode: function(string){ + + //Process all emojie list + var i; + for(i in ComunicWeb.components.emoji.list.translation){ + + //Change smileys as many time as required + while(string.includes(i)) + string = string.replace(i, ComunicWeb.components.emoji.list.translation[i]); + + } + + //Return result + return string; + } + + } \ No newline at end of file diff --git a/assets/js/pages/home/home.js b/assets/js/pages/home/home.js index c2c3c69a..eddac137 100644 --- a/assets/js/pages/home/home.js +++ b/assets/js/pages/home/home.js @@ -32,7 +32,7 @@ ComunicWeb.pages.home.home = { var emojiesArea = createElem2({ appendTo: targetElement, type: "p", - innerHTML: "Emoji test : :) 🇬🇫 🎅🏻" + innerHTML: "Emoji test : :) 🇬🇫 🎅🏻 :( (movie) (cool)" }); diff --git a/corePage/config/dev.config.php b/corePage/config/dev.config.php index 768ed06a..f4284c19 100644 --- a/corePage/config/dev.config.php +++ b/corePage/config/dev.config.php @@ -137,6 +137,7 @@ $config['JSfiles'] = array( //Emojies "%PATH_ASSETS%js/components/emoji/parser.js", + "%PATH_ASSETS%js/components/emoji/list.js", //User scripts "%PATH_ASSETS%js/user/loginTokens.js",