1
Fork 0

Replace now does multiple recurrances of emoticon code

This commit is contained in:
Jake Howard 2015-09-25 11:18:10 +01:00
parent 35aa577402
commit e09c3e8239

View file

@ -7,9 +7,13 @@ function insert_emoticons(ident, classes) {
key = Object.keys(decoder[i]); key = Object.keys(decoder[i]);
image = decoder[i][key]; image = decoder[i][key];
key = "(" + key + ")"; key = "(" + key + ")";
$(this).html($(this).html().replace(key, $(this).html(
"<img class='" + classes + "' style='height: 28px; width: auto;' src='" + image + "'/>" replaceAll(
)); $(this).html(),
key,
"<img class='" + classes + "' style='height: 28px; width: auto;' src='" + image + "'/>"
);
);
} }
}); });
console.log("Swapped " + ident); console.log("Swapped " + ident);
@ -21,12 +25,24 @@ function markdown_decoder(ident) {
raw_key = Object.keys(decoder[i]); raw_key = Object.keys(decoder[i]);
image = decoder[i][raw_key]; image = decoder[i][raw_key];
key = "(" + raw_key + ")"; key = "(" + raw_key + ")";
$(ident).val($(ident).val().replace(key, $(ident).val(
"![" + raw_key + "](" + image + ")" 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); console.log("Hipchat-emoticons-for-all is enabled on " + location.href);
var image_decoder = %image_decoder% var image_decoder = %image_decoder%