display link if location is url

This commit is contained in:
giomba 2020-10-30 12:35:09 +01:00
parent de0032d639
commit 1392e94f62
1 changed files with 14 additions and 5 deletions

View File

@ -76,7 +76,16 @@ function zerocalcareDisplay(xhr) {
let locationElement = document.createElement('div');
let locationText = document.createElement('span');
if (json_obj[i]['LOCATION'] !== undefined && json_obj[i]['LOCATION'] != '') {
locationText.appendChild(document.createTextNode(decodeURI(json_obj[i]['LOCATION'])));
let text = decodeURI(json_obj[i]['LOCATION']);
let textNode = document.createTextNode(text);
if (text.match("^(http|https):\\/\\/.*$")) {
let anchorElement = document.createElement('a');
anchorElement.href = text;
anchorElement.appendChild(textNode);
locationText.appendChild(anchorElement);
} else {
locationText.appendChild(textNode);
}
}
else {
locationText.appendChild(document.createTextNode('Officina Informatica'));