-
Notifications
You must be signed in to change notification settings - Fork 0
/
emoji_test.cfm
157 lines (128 loc) · 5.77 KB
/
emoji_test.cfm
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<cfset emojiLib = new emojiJava()>
<cfsavecontent variable="Attributes.inputString">Let's get some awesome ☕ at the café down the straße. 😃</cfsavecontent>
<cfparam name="form.inputString" default="#Attributes.inputString#">
<cfset inputString = form.inputString>
<cfcontent type="text/html; charset=UTF-8">
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>cf-emoji-java Test</title>
<meta name="description" content="ColdFusion + Java library to convert short codes, emoticons, html entities, emoticons to emojis and vice-versa.">
<meta name="author" content="James Moberg / SunStar Media">
<style>
textarea {width:100%;}
fieldset {margin-bottom:25px;}
</style>
</head>
<body>
<cfoutput>
<h1>cf-emoji-java Test</h1>
<h2>Enter Test String Containing Emojis</h2>
<form action="#CGI.Path_Info#" method="post">
<textarea id="inputString" name="inputString" required placeholder="Enter a string containing emojis.">#inputString#</textarea>
<div style="float:right;">
<button type="button" onclick="document.getElementById('inputString').value='An 😀awesome 😃string with a few 😉emojis!';">Reset</button>
<button type="button" onclick="document.getElementById('inputString').value='I ❤️ 🍕';">I ❤️ 🍕</button>
</div>
<button type="submit">Perform Emoji Test</button>
</form>
<h2>Results</h2>
<fieldset><legend>writeOutput(inputString)</legend>
<xmp>#inputString#</xmp>
</fieldset>
<fieldset><legend>emojiLib.getForAlias("smiley")</legend>
<cfdump var="#emojiLib.getForAlias("smiley")#">
</fieldset>
<fieldset><legend>emojiLib.getForTag("happy")</legend>
<cfdump var="#emojiLib.getForTag("happy")#">
</fieldset>
<fieldset><legend>emojiLib.getAllTags()</legend>
<cfdump var="#emojiLib.getAllTags()#" expand="false" label="emoji tags">
</fieldset>
<fieldset><legend>emojiLib.getAll()</legend>
<cfdump var="#emojiLib.getAll()#" expand="false" label="emojis (top 25)" top="25">
</fieldset>
<fieldset><legend>emojiLib.containsEmoji(inputString)</legend>
containsEmoji = #emojiLib.containsEmoji(inputString)#
</fieldset>
<fieldset><legend>emojiLib.isEmoji(inputString)</legend>
isEmoji = #emojiLib.isEmoji(inputString)#
</fieldset>
<fieldset><legend>emojiLib.isOnlyEmojis(inputString)</legend>
isOnlyEmojis = #emojiLib.isOnlyEmojis(inputString)#
</fieldset>
<fieldset><legend>emojiLib.parseToAliases(inputString)</legend>
<xmp>#emojiLib.parseToAliases(inputString)#</xmp>
</fieldset>
<fieldset><legend>emojiLib.parseToHtmlDecimal(inputString)</legend>
<xmp>#emojiLib.parseToHtmlDecimal(inputString)#</xmp>
</fieldset>
<fieldset><legend>emojiLib.parseToHtmlHexadecimal(inputString)</legend>
<xmp>#emojiLib.parseToHtmlHexadecimal(inputString)#</xmp>
</fieldset>
<fieldset><legend>emojiLib.removeAllEmojis(inputString)</legend>
<xmp>#emojiLib.removeAllEmojis(inputString)#</xmp>
</fieldset>
<fieldset><legend>emojiLib.removeAllEmojisExcept(inputString, ["smiley"])</legend>
<xmp>#emojiLib.removeAllEmojisExcept(inputString, ["smiley"])#</xmp>
</fieldset>
<fieldset><legend>emojiLib.removeEmojis(inputString, "smiley")</legend>
<xmp>#emojiLib.removeEmojis(inputString, "smiley")#</xmp>
</fieldset>
<fieldset><legend>emojiLib.extractEmojis(inputString)</legend>
<cfdump var="#emojiLib.extractEmojis(inputString)#">
</fieldset>
<fieldset><legend>emojiLib.extractEmojis(inputString, true)</legend>
<cfdump var="#emojiLib.extractEmojis(inputString, true)#">
</fieldset>
<fieldset><legend>emojiLib.replaceAllEmojis(inputString, "[emoji]")</legend>
<xmp>#emojiLib.replaceAllEmojis(inputString, "[emoji]")#</xmp>
</fieldset>
<h2>Misc Tests</h2>
<fieldset><legend>writedump(emojiLib)</legend>
<cfdump VAR="#emojiLib#" label="emojiLib" expand="false">
</fieldset>
<fieldset><legend>Performance</legend>
<cfset start = getTickCount()>
<cfloop from="1" to="1000" index="i"><cfset ignoreString = emojiLib.parseToAliases(inputString)></cfloop>
1,000 "parseToAliases" Time: #NumberFormat(GetTickCount()-Start)#ms<br>
<cfset start = getTickCount()><cfset ignoreString = emojiLib.parseToAliases(inputString)>
1 "parseToAliases" Time: #NumberFormat(GetTickCount()-Start)#ms<br>
</fieldset>
<fieldset><legend>len(inputString)</legend>
#NumberFormat(len(inputString))# = ACTUAL len()<br>
#NumberFormat(len(emojiLib.replaceAllEmojis(inputString, "X")))# = VISIBLE length
</fieldset>
<fieldset><legend>HTMLEditFormat(inputString)</legend>
<xmp>#HTMLEditFormat(inputString)#</xmp>
</fieldset>
<fieldset><legend>EncodeForHTML(inputString)</legend>
<xmp>#EncodeForHTML(inputString)#</xmp>
</fieldset>
<fieldset><legend>EncodeForHTML(emojiLib.parseToHtmlDecimal(inputString), true)</legend>
<xmp>#EncodeForHTML(emojiLib.parseToHtmlDecimal(inputString), true)#</xmp>
</fieldset>
<fieldset><legend>EncodeForHTMLAttribute(inputString)</legend>
<xmp>#EncodeForHTMLAttribute(inputString)#</xmp>
</fieldset>
<fieldset><legend>HTMLEditFormat/EncodeforHTML Comparison</legend>
HTMLEditFormat(inputString) = <xmp>#HTMLEditFormat(inputString)#</xmp>
EncodeForHTML(inputString) = <xmp>#EncodeForHTML(inputString)#</xmp>
</fieldset>
<h2>Junidecode / Romanization Results (Extra)</h2>
<cftry>
<cfset JunidecodeLib = new Junidecode()>
<fieldset><legend>JunidecodeLib.unidecode(inputString)</legend>
<xmp>#JunidecodeLib.unidecode(inputString)#</xmp>
</fieldset>
<fieldset><legend>JunidecodeLib.unidecode(emojiLib.parseToAliases(inputString))</legend>
<cfdump var="#JunidecodeLib.unidecode(emojiLib.parseToAliases(inputString))#">
</fieldset>
<cfcatch>
<p style="color:red;">Junidecode testing not available.</p>
</cfcatch>
</cftry>
</cfoutput>
</body>
</html>