1var script_tag = document.getElementById('prodGroups'); 2var query = script_tag.src.replace(/^[^\?]+\??/,''); 3// Parse the querystring into arguments and parameters 4var vars = query.split("&"); 5var args = {}; 6for (var i=0; i<vars.length; i++) { 7 var pair = vars[i].split("="); 8 // decodeURI doesn't expand "+" to a space. 9 args[pair[0]] = decodeURI(pair[1]).replace(/\+/g, ' '); 10} 11 12var family = args['family']; 13var category = args['cat']; 14var news; 15var displayedProducts = []; 16var newsToShow = 1000; 17 18function fetchData() { 19 var xhr = new XMLHttpRequest(); 20 xhr.onreadystatechange = function() { 21 if (xhr.readyState === 4) { 22 if (xhr.status === 200) { 23 news = JSON.parse(xhr.responseText); 24 if (news.length === 0) { 25 displayNoRecordsMessage(); 26 } else { 27 displayProducts(news.slice(0, newsToShow)); 28 // toggleShowMoreButton(); // Check if there are more news to show 29 } 30 } else { 31 console.error('Failed to fetch data. Status: ' + xhr.status); 32 } 33 } 34 }; 35 xhr.open("GET", 'getNews.php?fam=' + family + '&cat=' + category, true); 36 console.log(xhr.open); 37 xhr.send(); 38} 39 40function displayNoRecordsMessage() { 41 var productListDiv = document.getElementById('productList'); 42 productListDiv.innerHTML = ''; 43 var noRecordsMessage = document.createElement('p'); 44 noRecordsMessage.innerHTML = "<P><br><br>Sorry, nothing found.</p><p>If you're looking for something more specific, why not <a href='/en-us/contact/'>Contact Us</a>?</p>"; 45 productListDiv.appendChild(noRecordsMessage); 46} 47 48function filterNews() { 49 var searchTerm = document.getElementById('searchInput').value.toLowerCase(); 50 var subFilter = document.querySelector('input[name="subFilter"]:checked')?.value || ''; 51 var filteredProducts = news.filter(function(product) { 52 return ( 53 /* (subFilter === '' || (subFilter !== '' && product.product_subcategory && product.product_subcategory.includes(subFilter))) && */ 54 (product.Title.toLowerCase().includes(searchTerm) || 55 product.Body.toLowerCase().includes(searchTerm) || 56 product.Abs.toLowerCase().includes(searchTerm) || 57 product.Category.toLowerCase().includes(searchTerm)) 58 ); 59 }); 60 61 if (filteredProducts.length === 0) { 62 displayNoRecordsMessage(); 63 } else { 64 displayedProducts = filteredProducts.slice(0, newsToShow); 65 displayProducts(displayedProducts); 66 // toggleShowMoreButton(); // Check if there are more news to show 67 } 68} 69 70function displayProducts(news) { 71 var productListDiv = document.getElementById('productList'); 72 productListDiv.innerHTML = ''; 73 74 // Assuming productListDiv is your container for the cards 75 var productListDiv = document.getElementById('productList'); 76 77 // Create a row element 78 var rowDiv = document.createElement('div'); 79 rowDiv.classList.add('row'); 80 81 // Iterate over news 82 for (var i = 0; i < news.length; i++) { 83 84 var myNews = news.length; 85 document.getElementById("myNewsFound").innerHTML = myNews + " items "; 86 console.log (myNews); 87 88 // Format the Date 89 var monthNames = [ 90 "January", "February", "March", "April", "May", "June",
91 "July", "August", "September", "October", "November", "December" 92 ]; 93 94 var DateString = news[i].Date; 95 var nDate = new Date(DateString); 96 var nYear = nDate.getFullYear(); 97 var nDay = nDate.getDate(); 98 var MonthIndex = nDate.getMonth(); 99 var MonthName = monthNames[MonthIndex]; 100 101 var productDiv = document.createElement('div'); 102 productDiv.classList.add('col-12', 'col-sm-3', 'd-flex', 'justify-content-center', 'mt-2'); // Add Bootstrap grid classes 103 //productDiv.classList.add('col-lg-3', 'mb-4'); // Add Bootstrap grid classes 104 105 106 productDiv.innerHTML = ` 107 <div class='card-deck mb-4 mt-4'> 108 <div class='card card-content blog d-block h-100 d-flex flex-column justify-content-between' > 109 <div class='card-img news'> 110 <a href='/en-us/news/${news[i].Link}.htm'><img src='/primg/${news[i].ImgURL}' alt='${news[i].Title}' loading='lazy'></a> 111 </div> 112 113 <div class='card-body card-desc' style="text-align: center;"> 114 <a href='/en-us/news/${news[i].Link}.htm'><h3 style="font-size:0.8rem;">${news[i].Title}</h3></a> 115 </div> 116 <div class='card-footer news-footer'> 117 <div class='row'> 118 <div class='col-12 col-sm-6'> 119 <p class='date'> 120 <small class='date'>${nDay} </small> 121 <small class='month'>${MonthName} </small> 122 <small class='month'>${nYear}</small> 123 </p> 124 </div> 125 <div class='col-12 col-sm-6'> 126 <a href='/en-us/news/${news[i].Link}.htm' class='btn-card'>Read</a> 127 </div> 128 </div> 129 </div> 130 </div> 131 </div> 132 </div> 133 134 135 `; 136 137 // Append each product div to the row 138 rowDiv.appendChild(productDiv); 139 } 140 141 // Append the row to the product list container 142 productListDiv.appendChild(rowDiv); 143} 144 145/* function showMore() { 146 newsToShow += 2; 147 displayedProducts = news.slice(0, newsToShow); 148 displayProducts(displayedProducts); 149 toggleShowMoreButton(); // Check if there are more news to show 150 } 151 152 function toggleShowMoreButton() { 153 var showMoreBtn = document.getElementById('showMoreBtn'); 154 showMoreBtn.style.display = newsToShow < news.length ? 'block' : 'none'; 155} */ 156 157// Initial display of all products after DOM has loaded 158document.addEventListener('DOMContentLoaded', function(){ 159fetchData(); 160});
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.