Replace now does multiple recurrances of emoticon code
This commit is contained in:
parent
35aa577402
commit
e09c3e8239
1 changed files with 22 additions and 6 deletions
|
@ -7,9 +7,13 @@ function insert_emoticons(ident, classes) {
|
|||
key = Object.keys(decoder[i]);
|
||||
image = decoder[i][key];
|
||||
key = "(" + key + ")";
|
||||
$(this).html($(this).html().replace(key,
|
||||
"<img class='" + classes + "' style='height: 28px; width: auto;' src='" + image + "'/>"
|
||||
));
|
||||
$(this).html(
|
||||
replaceAll(
|
||||
$(this).html(),
|
||||
key,
|
||||
"<img class='" + classes + "' style='height: 28px; width: auto;' src='" + image + "'/>"
|
||||
);
|
||||
);
|
||||
}
|
||||
});
|
||||
console.log("Swapped " + ident);
|
||||
|
@ -21,12 +25,24 @@ function markdown_decoder(ident) {
|
|||
raw_key = Object.keys(decoder[i]);
|
||||
image = decoder[i][raw_key];
|
||||
key = "(" + raw_key + ")";
|
||||
$(ident).val($(ident).val().replace(key,
|
||||
"![" + raw_key + "](" + image + ")"
|
||||
));
|
||||
$(ident).val(
|
||||
replaceAll(
|
||||
$(ident).val(),
|
||||
key,
|
||||
"![" + raw_key + "](" + image + ")"
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function escapeRegExp(string) {
|
||||
return string.replace(/([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1");
|
||||
}
|
||||
|
||||
function replaceAll(string, find, replace) {
|
||||
return string.replace(new RegExp(escapeRegExp(find), 'g'), replace);
|
||||
}
|
||||
|
||||
console.log("Hipchat-emoticons-for-all is enabled on " + location.href);
|
||||
|
||||
var image_decoder = %image_decoder%
|
||||
|
|
Reference in a new issue