Lines 477-482
Link Here
|
477 |
aliases.splice(i, 1); |
477 |
aliases.splice(i, 1); |
478 |
refresh_aliases(); |
478 |
refresh_aliases(); |
479 |
} |
479 |
} |
|
|
480 |
|
481 |
function encodeHTMLEntities(str){ |
482 |
return str.replace(/[&<>'"]/g, |
483 |
tag => ({ |
484 |
'&': '&', |
485 |
'<': '<', |
486 |
'>': '>', |
487 |
"'": ''', |
488 |
'"': '"' |
489 |
}[tag])); |
490 |
} |
491 |
|
480 |
function add_alias(){ |
492 |
function add_alias(){ |
481 |
let alias = $("#new_alias").val(); |
493 |
let alias = $("#new_alias").val(); |
482 |
if ( !alias.length > 0 ) { return } |
494 |
if ( !alias.length > 0 ) { return } |
Lines 486-493
Link Here
|
486 |
function refresh_aliases(){ |
498 |
function refresh_aliases(){ |
487 |
let nodes = $("<div></div>"); |
499 |
let nodes = $("<div></div>"); |
488 |
aliases.forEach((a, i) => { |
500 |
aliases.forEach((a, i) => { |
489 |
let n = $("<div></div>").append(a.alias); |
501 |
let alias_str = encodeHTMLEntities(a.alias); |
490 |
n.append(`<input type="hidden" name="alias" value="${a.alias}">`) |
502 |
let n = $("<div></div>").append(alias_str); |
|
|
503 |
let input = $('<input type="hidden" name="alias" />'); |
504 |
input.val(a.alias); |
505 |
n.append(input); |
491 |
n.append(`<a onclick="remove_alias(${i});"><i class="fa fa-trash" aria-hidden="true"></i></a>`); |
506 |
n.append(`<a onclick="remove_alias(${i});"><i class="fa fa-trash" aria-hidden="true"></i></a>`); |
492 |
nodes.append(n); |
507 |
nodes.append(n); |
493 |
}); |
508 |
}); |
494 |
- |
|
|