serendipity_editor.js.tpl: escapeBrackets(str)

This commit is contained in:
onli 2013-06-24 21:56:54 +02:00
parent 49181fb06d
commit edaf7e9d6f

View File

@ -174,8 +174,7 @@ function choose_media(id) {
// "Transfer" value from media db popup to form element, used for example for selecting a category-icon
function serendipity_imageSelector_addToElement (str, id) {
id = id.replace(/\[/g, "\\["); // jQuery fails to select the input when the selector contains unescaped [ or ]
id = id.replace(/\]/g, "\\]");
id = escapeBrackets(str);
var $input = $('#'+id);
$input.val(str);
@ -187,6 +186,14 @@ function serendipity_imageSelector_addToElement (str, id) {
$input.change();
}
// Escape an id with [ in it to be able to be used as selector
// jQuery fails to select the input when the selector contains unescaped [ or ]
function escapeBrackets(str) {
str = str.replace(/\[/g, "\\[");
str = str.replace(/\]/g, "\\]");
return str;
}
// Add another (image) keyword
function AddKeyword(keyword) {
s = document.getElementById('keyword_input').value;