const escapeHtml = (unsafe) => ( unsafe.replaceAll('&', '&') .replaceAll('<', '<') .replaceAll('>', '>') .replaceAll('"', '"') .replaceAll("'", ''') ); const renderUserMention = (tag, userName) => { const safeUserName = escapeHtml(userName); return `${safeUserName}`; }; window.renderSmartAnnotations = (text) => ( text.replace(/\[@([^~\]]+)~([0-9a-zA-Z]+)\]|\[#(.*?)~(rep_item|prj|exp|tsk)~([0-9a-zA-Z]+)\]/g, (match, userName, _userId, label, type) => { const tag = encodeURIComponent(match.slice(1, -1)); if (userName) { return renderUserMention(tag, userName); } const safeLabel = escapeHtml(label); const safeType = escapeHtml(type); switch (type) { case 'rep_item': return `INV${safeLabel}`; default: return `${safeType}${safeLabel}`; } }) ); window.renderElementSmartAnnotations = (element) => { element.innerHTML = window.renderSmartAnnotations(element.innerHTML); return true; }; $(document).on('focus', '.user-tooltip', function () { $.get($(this).data('url'), (data) => { const content = `
thumb
${escapeHtml(data.full_name)}

${data.info}

`; $(this).attr('data-content', content); $(this).popover('show'); $(this).one('mouseout', function () { $(this).popover('hide'); }); }); });