mirror of
https://github.com/pierre42100/ComunicWeb
synced 2024-11-22 20:19:21 +00:00
Created emoji shorcut to HTML code translator
This commit is contained in:
parent
2601da21ad
commit
37adf3aa0d
@ -594,6 +594,13 @@ var ComunicWeb = {
|
|||||||
//TODO : implement
|
//TODO : implement
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Emojies list
|
||||||
|
*/
|
||||||
|
list: {
|
||||||
|
//TODO : implement
|
||||||
|
},
|
||||||
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
26
assets/js/components/emoji/list.js
Normal file
26
assets/js/components/emoji/list.js
Normal file
@ -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)": "📽",
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -23,6 +23,8 @@ ComunicWeb.components.emoji.parser = {
|
|||||||
*/
|
*/
|
||||||
parse: function(infos){
|
parse: function(infos){
|
||||||
|
|
||||||
|
//Peform string parsing
|
||||||
|
infos.element.innerHTML = this.shorcutToHTMLcode(infos.element.innerHTML);
|
||||||
|
|
||||||
//Perform Twitter parsing
|
//Perform Twitter parsing
|
||||||
this.twitterEmojiesParsing(infos.element);
|
this.twitterEmojiesParsing(infos.element);
|
||||||
@ -48,4 +50,27 @@ ComunicWeb.components.emoji.parser = {
|
|||||||
return true;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
@ -32,7 +32,7 @@ ComunicWeb.pages.home.home = {
|
|||||||
var emojiesArea = createElem2({
|
var emojiesArea = createElem2({
|
||||||
appendTo: targetElement,
|
appendTo: targetElement,
|
||||||
type: "p",
|
type: "p",
|
||||||
innerHTML: "Emoji test : :) 🇬🇫 🎅🏻"
|
innerHTML: "Emoji test : :) 🇬🇫 🎅🏻 :( (movie) (cool)"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
@ -137,6 +137,7 @@ $config['JSfiles'] = array(
|
|||||||
|
|
||||||
//Emojies
|
//Emojies
|
||||||
"%PATH_ASSETS%js/components/emoji/parser.js",
|
"%PATH_ASSETS%js/components/emoji/parser.js",
|
||||||
|
"%PATH_ASSETS%js/components/emoji/list.js",
|
||||||
|
|
||||||
//User scripts
|
//User scripts
|
||||||
"%PATH_ASSETS%js/user/loginTokens.js",
|
"%PATH_ASSETS%js/user/loginTokens.js",
|
||||||
|
Loading…
Reference in New Issue
Block a user