/* global initData, authorizationToken */ // List of HTML entities for escaping. var htmlEscapes = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', '/': '/' }; // Regex containing the keys listed immediately above. var htmlEscaper = /[&<>"'\/]/g; // Escape a string for HTML interpolation. escape = function(string) { return ('' + string).replace(htmlEscaper, function(match) { return htmlEscapes[match]; }); }; var urlRegex = /(https?://[^\s]+)/g; url = function(string){ return ''+string.replace(urlRegex, '$1') } var titleRegex = /^(.*\n)/; title = function(string){ var str=''+string.replace(titleRegex, '$1'); return ''+string.replace(titleRegex, '$1'); } function updatePage(data){ var content = ""; var item = {}; var id = ''; // If the log entry is unique, simulate a search result if( ! data['hits'] ){ data = {hits:{hits:[data]}}; } $.each(data.hits.hits, (k,v)=>{ item = v._source; id = v._id; content += `
${escape(item.created_at)} -- ${escape(item.author)} -- ${escape(item.server)}
${title(url(escape(item.content)))}