Skip to content

Commit b4371ad

Browse files
committed
build 2.0.3
1 parent 88a7496 commit b4371ad

File tree

5 files changed

+16
-18
lines changed

5 files changed

+16
-18
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "Kappa.js",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"homepage": "http://simulatedgreg.github.io/kappa.js/",
55
"authors": [
66
"Greg Holguin <[email protected]>"

dist/kappa.js

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@
4242
});
4343
} else window.KappaJS = JSON.parse(localStorage.getItem('kappa-js'));
4444

45+
/**
46+
* Cache Regex
47+
*/
48+
var twitchEmotesRegExp = new RegExp("\\b(" + Object.keys(KappaJS.emotes).join("|") + ")\\b", "g");
49+
4550
/**
4651
* Initialize jQuery Plugin
4752
* @return {this} DOM element
@@ -94,13 +99,11 @@
9499
* Replace with generated <img> tag
95100
*/
96101
function replaceTextWithEmotes() {
97-
for (var emote in KappaJS.emotes) {
98-
if (KappaJS.emotes.hasOwnProperty(emote)) {
99-
$(self).each(function (i, el) {
100-
$(el).html($(el).html().replace(new RegExp('\\b' + emote + '\\b', 'g'), generateImgTag(KappaJS.emotes[emote], emote)));
101-
});
102-
}
103-
}
102+
$(self).each(function (i, el) {
103+
$(el).html($(el).html().replace(twitchEmotesRegExp, function (all, emote) {
104+
return generateImgTag(KappaJS.emotes[emote], emote);
105+
}));
106+
});
104107
}
105108

106109
/**

dist/kappa.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55
<title>Kappa.js</title>
66
</head>
77
<body>
8-
<div>
9-
<span class="kappa">Kappa</span>
10-
<span class="kappa">FailFish</span>
11-
<span class="kappa">WutFace</span>
12-
</div>
8+
<p class="kappa">
9+
HeyGuys why do you hate me BibleThump! I thought I was meme worthy Kappa. I enjoy the memes Kreygasm.
10+
</p>
1311

1412
<script src="https://code.jquery.com/jquery-2.2.0.min.js"></script>
1513
<script src="dist/kappa.min.js"></script>

package.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
{
22
"name": "kappa.js",
3-
"version": "2.0.2",
3+
"version": "2.0.3",
44
"description": "Kappa.js is a simple jQuery Plugin that can easily find text Twitch emotes and replace them with their respective emoticons. ",
55
"main": "dist/kappa.min.js",
6-
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
8-
},
96
"repository": {
107
"type": "git",
118
"url": "git+https://github.com/simulatedgreg/kappa.js.git"

0 commit comments

Comments
 (0)