1// Move this to a function 2// Call this function on document load... 3// Handle no results 4// Move to document.load... 5// Make sure to clear the the news-results 6// Make sure to turn off the next and previous buttons: 7 8 9 function performSearch(initialSearch, pageNumber) 10 { 11// FIX ME!!! GET THE SEARCH TERM: 12 // Clear the current results if any: 13 $("#news-resultleft").empty(); 14 $("#news-resultright").empty(); 15 //$(".search-term-display").text(searchTerm); 16 var tags = getTags(); 17 // Parse the path to remove various AEM handlers: 18 var currentPath = location.pathname; 19 // Clip out 'cf#': 20 if(currentPath.indexOf("cf#") != -1) 21 { 22 // Has cf# - remove: 23 currentPath = currentPath.slice(currentPath.indexOf("cf#")); 24 } 25 // Clip out 'editor.html': 26 if(currentPath.indexOf("editor.html") != -1) 27 { 28 // Has editor.html - remove: 29 currentPath = currentPath.slice(currentPath.indexOf("editor.html")); 30 } 31 // Does it have .html? 32 if(currentPath.indexOf(".html") != -1) 33 { 34 // Has html - remove: 35 currentPath = currentPath.substr(0,currentPath.indexOf(".html")); 36 } 37 var searchPath = currentPath + ".centenenews.json"; 38 let newsMsg = Granite.I18n.get("newsroom"); 39 var modeValue = $('#footer-news-wrapper').data("homepnews"); 40 $.getJSON(searchPath+"?pageNumber="+pageNumber+"&tags="+tags, 41 //$.getJSON("/content/sunshine/en_us.centenenews.json?pageSize="+pageSize, 42 function(newsResultJson) 43 { 44 // Do we have a good result set? 45 //future consideration: Style one wide section if there is only one article 46 if(newsResultJson.newsResults.length > 0) 47 { 48 //strip any html 49 //commenting out because this breaks the home page news and is not use anywhere 50 //var excerpt0 = document.createElement("p"); 51 //excerpt0.innerHTML = newsResultJson.newsResults[0].excerpt; 52 //excerpt0 = excerpt0.innerText; 53 //var excerpt1 = document.createElement("p"); 54 //excerpt1.innerHTML = newsResultJson.newsResults[1].excerpt; 55 //excerpt1 = excerpt1.innerText; 56 //removed description and replaced with excerpt 57 var newsPath = getContentNewsPath(newsResultJson.newsResults[0].path); 58 let footerNewsBody = '<section class="container-fluid secondary-footer home-news">'; 59 footerNewsBody += '<div class="container">'; 60 footerNewsBody += '<h3 class="col-md-22 col-md-offset-1">'+newsMsg+'</h3>'; 61 footerNewsBody += '<article class="col-md-10 col-md-offset-1">'; 62 footerNewsBody += '<div id="news-resultleft">'; 63 footerNewsBody += '<a href='+newsPath+'.html class="block-anchor"><h2>'+newsResultJson.newsResults[0].title+'</h2><p>'+newsResultJson.newsResults[0].excerpt+'</p></a>'; 64 footerNewsBody += '</div></article>'; 65 //don't build the right section unless there are two articles 66 if (newsResultJson.newsResults.length > 1){ 67 var newsPath1 = getContentNewsPath(newsResultJson.newsResults[1].path); 68 footerNewsBody += '<article class="col-md-10 col-md-offset-1">'; 69 footerNewsBody += '<div id="news-resultright">'; 70 footerNewsBody += '<a href='+newsPath1+'.html class="block-anchor"><h2>'+newsResultJson.newsResults[1].title+'</h2><p>'+newsResultJson.newsResults[1].excerpt+'</p></a>'; 71 footerNewsBody += '</div></article>'; 72 } 73 footerNewsBody += '</div></section>'; 74 $("#footer-news-wrapper").append(footerNewsBody); 75 } 76 else 77 { 78 // None found: 79 //$("#news-resultleft").append('No news items were found.'); 80 //If no artices found, hide the home page news when not in edit mode 81 if (modeValue != 'edit') { 82 $("section.home-news").addClass('hidden'); 83 } 84 } 85 } 86 ); 87 } 88 89 function getUrlParameter(sParam) { 90 var sPageURL = window.location.search.substring(1); 91 var sURLVariables = sPageURL.split('&'); 92 for ( var i = 0; i < sURLVariables.length; i++) { 93 var sParameterName = sURLVariables[i].split('='); 94 if (sParameterName[0] == sParam) { 95 return sParameterName[1]; 96 } 97 } 98 return ""; 99 } 100 101 function getContentNewsPath(newsPath){ 102 var hostName = location.hostname;
103 var newsItemPath = newsPath; 104 if (newsItemPath != undefined) { 105 if (hostName.match(/^(localhost|author-p\d+.*?|preview-p\d+.*?|publish-p\d+.*?)$/) || newsItemPath.match(/^\/content\/healthnet\/.*?/)) { 106 newsItemPath = newsItemPath; 107 } else { 108 var pathPattern = /\/content\/.*?\/.*?\//; 109 newsItemPath = "/" + newsItemPath.replace(pathPattern, ""); 110 } 111 } 112 return newsItemPath; 113 } 114 115 function getTags() { 116 var tags = ""; 117 tags = getUrlParameter("tags"); 118 if (tags != "") { 119 return tags; 120 } 121 $.each($("#tags ul li"), function(index, value) { 122 tags = tags + value.textContent + ","; 123 }); 124 return tags; 125 } 126 127 $( document ).ready(function() 128 { 129 // Initial search: 130 performSearch(true,1); 131});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.