-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathemoji.js
38 lines (33 loc) · 1.15 KB
/
emoji.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
var emojiType = {
init: function(){
document.querySelector("#btn-replace-emoji").addEventListener("click", this.replaceEmoji.bind(this));
},
replaceEmoji : function(){
var text = this.getElementById("emoji-type-text").value.toLowerCase();
var options = document.getElementById("emoji-lang").selectedIndex;
var dictionary = {};
var counts = 0;
switch(options) {
case 0:
dictionary = dictionaryEng;
break;
case 1:
dictionary = dictionaryTr;
break;
case 2:
dictionary = dictionaryFr;
break;
}
for (var key in dictionary) {
counts = text.split(key);
for (count in counts){
text = text.replace(key, "<span class='emoji " + dictionary[key] + "'></span>");
}
}
this.getElementById("emoji-type-result").innerHTML = "<fieldset><legend>Result</legend>" + text + "</fieldset>";
},
getElementById: function(elementId){
return document.getElementById(elementId);
}
};
emojiType.init();