1 2 3 4 5$(document).ready(function() { 6 7 $("body").addClass("ltblue"); 8 //SET FILTER LIST 9 var totalCount = $(".resource-list li:visible").length; 10 //$('#results_header h2').html('Displaying <strong>'+1+'</strong> - <strong>'+totalCount+'</strong> of <strong>'+totalCount+'</strong> Results').show(); 11 $('#results_header h2').html('Displaying <strong>'+totalCount+'</strong> Results').show(); 12 $('#result1 strong').text($('.filterlist:nth-child(1) span').text()+': '); //top header NAME 13 $('#result2 strong').text($('.filterlist:nth-child(2) span').text()+': '); //top header NAME 14 $('#result3 strong').text($('.filterlist:nth-child(3) span').text()+': '); //top header NAME 15 16 setShowMore(); 17 matchHeight(); 18 19 //Filter functionality 20 $(window).on('resize',function(){ 21 matchHeight(); 22 }); 23 24 25 //Menu start //JG UPDATED 01/04/2023 26 $('nav.secondary .dropdown > a').on('click', function(e) { //CHANGED TO POINT TO HYPERLINK 27 e.preventDefault(); //NNEDS TO BE ENABLED 28 if($(this).hasClass('active')) { 29 $(this).removeClass('active'); 30 $(this).next('ul').slideUp(); // CHANGED FIND SELECTOR FOR MULTICOLUMN 31 } else { 32 $('nav.secondary .dropdown a').removeClass('active'); 33 $('nav.secondary .dropdown a').next('ul').slideUp(); // CHANGED FIND SELECTOR FOR MULTICOLUMN 34 $(this).addClass('active'); 35 $(this).next('ul').slideDown(); // CHANGED FIND SELECTOR FOR MULTICOLUMN 36 } 37 }); 38 39 $('.share-icon > a:first-child').on('click', function(e) { 40 e.preventDefault(); 41 42 if( $('.media-link').is(':visible') ){ 43 $('.media-link').slideUp(); 44 }else{ 45 $('.media-link').slideDown(); 46 } 47 48 /* 49 if( $('.media-link').hasClass('active') ){ 50 $('.media-link').removeClass('active'); 51 $('.media-link').slideUp(); 52 }else{ 53 $('.media-link').addClass('active'); 54 55 } 56 */ 57 58 }); 59 //Menu end 60 61 //CLOSE DROPDOWNS WHEN CLICKING AWAY COMMON FOR MENU/FILTER 62 $("html").on("click", function (e) { 63 if( ! $(e.target).parents(".dropdown").length ){ 64 65 if( $('nav.secondary .dropdown > a').hasClass('active') ){ 66 $('nav.secondary .dropdown > a').removeClass('active'); 67 $('nav.secondary .dropdown > a').next('ul').slideUp(); 68 } 69 } 70 71 if( ! $(e.target).parents(".share-icon").length ){ 72 $('.media-link').slideUp(); 73 } 74 75 if( ! $(e.target).parents(".filterlist").length ) { 76 if( $('.filterHead').hasClass('active') ) { 77 $('.filterHead').removeClass('active'); 78 $('.filterHead + ul').slideUp(); 79 } 80 } 81 }); 82 83//Filter click 84//IDC keyboard function added 24/7/2025 85 86const $trigger = $('.filterHead'); 87 let $dropdown = null; 88 let $items = []; 89 let currentIndex = -1; 90 91 $('.filterHead').on('click', function(e){ 92 e.preventDefault(); 93 if( $(this).hasClass('active') ){ 94 $(this).removeClass('active'); 95 $(this).next('ul').slideUp(); 96 } else { 97 $('.filterHead').removeClass('active'); 98 $('.filterHead + ul').slideUp(); 99 $(this).addClass('active'); 100 $(this).next('ul').slideDown(); 101 } 102 }); 103 104 105//IDC keyboard function added 24/7/2025 106 107 $('.filterHead').on("keydown", function(e){ 108 if(e.key === "Enter" || e.key === " "){ 109 e.preventDefault(); 110 if( $(this).hasClass('active') ){ 111 $(this).removeClass('active'); 112 $(this).next('ul').slideUp(); 113 currentIndex = -1; 114 } else { 115 $('.filterHead').removeClass('active'); 116 $('.filterHead + ul').slideUp(); 117 $(this).addClass('active'); 118 $(this).next('ul').slideDown(); 119 $dropdown = $(this).next('ul'); 120 $items = $dropdown.find('li'); 121 currentIndex = 0; 122 focusItem(currentIndex); 123 attachDropdownKeyEvents(); 124 } 125 } 126 }); 127 128 $('.filterHead').on('click', function(){ 129 130 $(this).trigger('keydown', { 131 key: "Enter" 132 }) 133 }) 134 135 136//IDC keyboard function added 24/7/2025 137 function focusItem(index) { 138 if ($items.length === 0) return; 139 $items.attr('tabindex', '-1'); // ensure focusable 140 $items.eq(index).focus(); 141 } 142 143//IDC keyboard function added 24/7/2025 144 function attachDropdownKeyEvents() { 145 $dropdown.off('keydown').on('keydown', function (e) { 146 if (e.key === 'ArrowDown') { 147 e.preventDefault(); 148 currentIndex = (currentIndex + 1) % $items.length; 149 focusItem(currentIndex); 150 } else if (e.key === 'ArrowUp') { 151 e.preventDefault(); 152 currentIndex = (currentIndex - 1 + $items.length) % $items.length; 153 focusItem(currentIndex); 154 } else if (e.key === 'Enter' || e.key === ' ') { 155 e.preventDefault(); 156 const $checkbox = $items.eq(currentIndex).find('input[type="checkbox"]'); 157 if ($checkbox.length) { 158 $checkbox.prop('checked', !$checkbox.prop('checked')); 159 } 160 } else if (e.key === 'Escape') { 161 e.preventDefault(); 162 163 const $currentFilter = $('.filterHead.active'); 164 165 $currentFilter.next('ul').slideUp(); 166 $currentFilter.removeClass('active'); 167 currentIndex = -1; 168 $currentFilter.focus(); 169 170 } 171 });
172 } 173 174 175 176 177 178 179 180 // Find url if it has query string execuet callback to show results 181 function executeIfqueryStringExist(queryStringUrl,queryStringExistCallback){ 182 var urlObj = new URL(queryStringUrl); 183 var params = new URLSearchParams(urlObj.search); 184 185 if( params.has("industries") && params.has("resource-type") && params.has("date") 186 || params.has("services") && params.has("industries") && params.has("date") 187 || params.has("services")&& params.has("resource-type") && params.has("date")){ 188 queryStringExistCallback(); 189 } else { 190 console.log("querystring wont works"); 191 } 192 193 } 194 195 196 var queryStringUrl = executeIfqueryStringExist(window.location.href,queryStringExistCallback); 197 198 // Call backfunction to execute if querystring exist 199 function queryStringExistCallback(){ 200 var param3; 201 var url = window.location.href; 202 var urlProperties = new URL(url); 203 var industries = urlProperties.searchParams.get("industries"); 204 var resourceType = urlProperties.searchParams.get("resource-type"); 205 var services = urlProperties.searchParams.get("services"); 206 var date = urlProperties.searchParams.get("date"); 207 208 if(date != "all"){ 209 param3 = parseInt(date.substring(5, 8)); 210 } else { 211 param3 = "all"; 212 } 213 214 215 $("#dd_industries li input[type='checkbox']").each(function(){ 216 // uncheck allindustries 217 $(this).parent().removeClass("selected"); 218 // get the text of each li and trim it. 219 var liTextIndustries = $(this).val().toLowerCase(); 220 var industriesValues = industries.toLowerCase() 221 222 if(liTextIndustries !== "non-profit"){ 223 if(industriesValues.replace(/-and-/g, "-&-").replace(/-/g, " ").includes(liTextIndustries)){ 224 $(this).parent().addClass('selected'); 225 } 226 } else { 227 // add the selected class to the matching li 228 $(this).parent().addClass('selected'); 229 } 230 231 }); 232 233 234 $("#dd_resource_type li input[type='checkbox']").each(function(){ 235 // uncheck allresources 236 $(this).parent().removeClass("selected"); 237 // get the text of each li and trim it. 238 var liTextResources = $(this).val().toLowerCase(); 239 var resourceTypeValues = resourceType.toLowerCase(); 240 if(resourceTypeValues.replace(/-and-/g, "-&-").replace(/-/g, " ").includes(liTextResources)){ 241 // add the selected class to the matching li 242 $(this).parent().addClass('selected'); 243 } 244 }); 245 246 247 $("#dd_date li input[type='checkbox']").each(function(){ 248 // uncheck alldate 249 $(this).parent().removeClass("selected"); 250 // get the text of each li and trim it. 251 var liDateResource = $(this).val().toLowerCase();; 252 //add the selected class to the matching li 253 if(param3 == liDateResource){ 254 $(this).parent().addClass('selected'); 255 } 256 }); 257 258 259 $("#dd_services li input[type='checkbox']").each(function(){ 260 // uncheck allresources 261 $(this).parent().removeClass("selected"); 262 // get the text of each li and trim it. 263 var liTextServices = $(this).val().toLowerCase(); 264 var serviesValues = services.toLowerCase() 265 if(serviesValues.replace(/-and-/g, "-&-").replace(/-/g, " ").includes(liTextServices)){ 266 // add the selected class to the matching li 267 $(this).parent().addClass('selected') 268 } 269 }); 270 271 272 function toFormatPascalCase(str) { 273 var segments = str.split(','); 274 275 function convertSegment(segment){ 276 var words = segment.split('-'); 277 return words.map(word => { 278 // Convert the word to PascalCase unless it is "and" 279 if (word.toLowerCase() === 'and') { 280 return '&'; 281 } else { 282 return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase(); 283 } 284 }).join(' '); 285 } 286 287 var formattedString = segments.map(convertSegment).join(', '); 288 return formattedString; 289 } 290 291 292 // to show the header result querystring values 293 if(resourceType == null){ 294 var result1 = toFormatPascalCase(services); 295 var result2 = toFormatPascalCase(industries); 296 } else if(services == null){ 297 var result1 = toFormatPascalCase(industries); 298 var result2 = toFormatPascalCase(resourceType); 299 } else { 300 var result1 = toFormatPascalCase(services); 301 var result2 = toFormatPascalCase(resourceType); 302 } 303 304 305 var queryStringDropdown1, queryStringDropdown2, queryStringDropdown3, queryStringSingleValue, queryStringMultiValue , queryStringPublishDateValue, queryStringNumberOfDays= ""; 306 var queryStringDropdownArray1, queryStringDropdownArray2, multiValueArray = []; 307 var queryStringHasDropdown1 = true; 308 var queryStringHasDropdown2 = true; 309 var queryStringHasDropdown3 = true; 310 var queryStringResultCount = 0; 311 var queryStringDropdownId1 = $('.filterlist:nth-child(1) ul').attr('id'); //ID name differ page to page 312 var queryStringDropdownId2 = $('.filterlist:nth-child(2) ul').attr('id'); //ID name differ page to page 313 var queryStringDropdownId3 = $('.filterlist:nth-child(3) ul').attr('id'); //ID name differ page to page 314 var filterbyResourceType = true; 315 //queryStringDropdown1, queryStringDropdown2, queryStringDropdown3 = "query string"; 316 317 queryStringDropdown1 = getSelectedValues('#'+queryStringDropdownId1); 318 queryStringDropdown2 = getSelectedValues('#'+queryStringDropdownId2); 319 queryStringDropdown3 = getSelectedValues('#'+queryStringDropdownId3); 320 321 322 if(industries == "all" || services == "all"){ 323 queryStringDropdown1 = "All"; 324 } 325 326 if(resourceType == "all" || industries == "all"){ 327 queryStringDropdown2 = "All"; 328 } 329 330 if(param3 == "all"){ 331 queryStringDropdown3 = "All"; 332 param3 = queryStringDropdown3; 333 } 334 335 336 337 console.log("queryStringDropdown1", queryStringDropdown1); 338 console.log("queryStringDropdown2", queryStringDropdown2); 339 console.log("queryStringDropdown3", queryStringDropdown3); 340 341 342 $('#locload').show(); 343 setTimeout(function(){ 344 $('#locload').hide(); 345 $('#result1 span').text(result1); 346 $('#result2 span').text(result2); 347 $('#result3 span').text(param3 + " days"); // top header date Value 348 349 if(queryStringDropdown1 !="All" || queryStringDropdown2 !="All" || queryStringDropdown3 !="All"){ 350 351 $(".resource-list li").each(function (){ 352 queryStringSingleValue = $(this).attr('data-type').toLowerCase(); //Single value 353 queryStringMultiValue = $(this).attr('data-services').toLowerCase();//Multiple value with divider 354 queryStringMultiValueArray = queryStringMultiValue.split("|"); //Multiple values to array 355 queryStringPublishDateValue = $(this).attr('data-publishdate').toLowerCase(); //Actual date value of resource list 356 357 358 if(queryStringDropdown1 != "All"){ 359 if(queryStringDropdownId1 == "dd_industries" ){ 360 queryStringDropdownArray1 = industries.split(",").map(item => item.trim()); 361 var industriesArray = queryStringDropdownArray1.map(function(item){
362 if(item !== "non-profit"){ 363 return item.replace(/-and-/g, "-&-").replace(/-/g, " "); 364 } 365 return item; 366 }) 367 queryStringHasDropdown1 = industriesArray.some(elem => queryStringMultiValueArray.indexOf(elem) > -1); // Check selected value in each value on result 368 } else if (queryStringDropdownId1 == "dd_services"){ 369 // block enables when id is not dd_industries" 370 queryStringDropdownArray1 = services.split(",").map(item => item.trim()); 371 var servicesArray = queryStringDropdownArray1.map(function(item){ 372 return item.replace(/-and-/g, "-&-").replace(/-/g, " "); 373 }) 374 queryStringHasDropdown1 = servicesArray.some(elem => queryStringMultiValueArray.indexOf(elem) > -1); // Check selected value in each value on result 375 } 376 } 377 378 if(queryStringDropdown2 != "All"){ 379 if(queryStringDropdownId2 == "dd_resource_type"){ 380 queryStringDropdownArray2 = resourceType.split(",").map(item => item.trim()); 381 var resourcesArray = queryStringDropdownArray2.map(function(item){ 382 return item.replace(/-and-/g, "-&-").replace(/-/g, " "); 383 }) 384 queryStringHasDropdown2 = resourcesArray.some(elem => queryStringSingleValue.indexOf(elem) > -1); 385 386 } else if(queryStringDropdownId2 == "dd_industries"){ 387 queryStringDropdownArray2 = industries.split(",").map(item => item.trim()); 388 var industriesArray = queryStringDropdownArray2.map(function(item){ 389 return item.replace(/-and-/g, "-&-").replace(/-/g, " "); 390 }) 391 queryStringHasDropdown2 = industriesArray.some(elem => queryStringMultiValueArray.indexOf(elem) > -1); 392 } 393 } 394 395 396 397 if(queryStringDropdown3 != "All"){ 398 var queryStringStartDate = new Date(); 399 queryStringNumberOfDays = param3; 400 queryStringStartDate.setDate(queryStringStartDate.getDate() - queryStringNumberOfDays); //DATE which X days ago from today 401 var queryStringEndDate = new Date(); //To get today DATE 402 var queryStringPublishDate = new Date(queryStringPublishDateValue.split("-").reverse().join("-")); //DATE of formatted value 403 404 if((queryStringStartDate <= queryStringPublishDate) && (queryStringPublishDate <= queryStringEndDate)){ 405 // new if((queryStringPublishDate >= queryStringStartDate) && (queryStringPublishDate <= queryStringEndDate)){ 406 queryStringHasDropdown3 = true; 407 } else { 408 queryStringHasDropdown3 = false; 409 } 410 } 411 412 413 414 var queryStringMHeight = $(this).attr('data-match-height'); 415 $(this).removeClass(queryStringMHeight).attr('data-match-height', ''); 416 417 if( queryStringHasDropdown1 == true && queryStringHasDropdown2 == true ) { 418 // if(queryStringHasDropdown1 == true && queryStringHasDropdown2 == true && queryStringHasDropdown3 == true){ 419 $(this).removeClass("resHide"); 420 $(this).show(); 421 queryStringResultCount++; 422 } else { 423 $(this).addClass("resHide"); 424 $(this).hide(); 425 } 426 427 }); 428 429 } else if(queryStringDropdown1 =="All" && queryStringDropdown2 =="All" && queryStringDropdown3 =="All"){ 430 queryStringResultCount = $(".resource-list li").length; 431 $('#selected_value').next('p').hide(); 432 $(".resource-list li").removeClass("resHide"); 433 $(".resource-list li").show(); 434 } 435 436 if(queryStringResultCount !=0){ 437 $('#selected_value').next('p').hide(); 438 $('#results_header').show(); 439 $('#results_header h2').html('Displaying <strong>'+queryStringResultCount+'</strong> Results'); 440 } else { 441 $('#selected_value').next('p').show(); 442 $('#results_header').hide(); 443 } 444 445 $("#btnShowMore").hide(); 446 matchHeight(); 447 448 }, 500); 449 450 } 451 452 453 454 /* 455 456 //Filter checkbox click 457 $( ".resFilter li" ).on("click",function(e) { 458 e.preventDefault(); 459 460 //$('.filterHead').next('ul').find('li.focusable').removeClass('focusable'); 461 //REMOVE "ALL" CHECK 462 if( $(this).data('value') != "all" ){ 463 //IF AnYTHING OTHER THAN ALL IS CHECKED UNCHECK ALL 464 $(this).parent('ul').children('li:first-child').removeClass("selected"); 465 } else { 466 //IF ALL IS CHECKED CLEAR ALL OTHERS 467 $(this).parent('ul').children('li').removeClass("selected"); 468 } 469 470 if( $(this).hasClass('selected') ){ 471 $(this).removeClass('selected'); 472 if( ! $(this).parent('ul').children('li').hasClass("selected") ){ 473 //IF NOTHING IS SELECTED CHECK ALL 474 $(this).parent('ul').children('li:first-child').addClass("selected"); 475 } 476 } else { 477 478 //Enabled single click for DATE filter 479 if($(this).parent('ul').attr('id') == 'dd_date') { 480 $(this).parent('ul').children('li').removeClass("selected"); 481 } 482 483 $(this).addClass('selected'); 484 485 } 486 487 488 var dropdown1, dropdown2, dropdown3, dropdown4, singleValue, multiValue , publishDateValue, numberOfDays= ""; 489 var dropdownArray1, dropdownArray2, dropdownArray3, multiValueArray = []; 490 var hasDropdown1 = true; 491 var hasDropdown2 = true; 492 var hasDropdown3 = true; 493 var hasDropdown4 = true; 494 var resultCount = 0; 495 var dropdownId1 = $('.filterlist:nth-child(1) ul').attr('id'); //ID name differ page to page 496 var dropdownId2 = $('.filterlist:nth-child(2) ul').attr('id'); //ID name differ page to page 497 var dropdownId3 = $('.filterlist:nth-child(3) ul').attr('id'); //ID name differ page to page 498 var dropdownId4 = $('.filterlist:nth-child(4) ul').attr('id'); //ID name differ page to page 499 var filterbyResourceType = true; 500 var filterbyResourceType2 = false; 501 502 dropdown1 = getSelectedValues('#'+dropdownId1); 503 dropdown2 = getSelectedValues('#'+dropdownId2); 504 dropdown3 = getSelectedValues('#'+dropdownId3); 505 dropdown4 = getSelectedValues('#'+dropdownId4); 506 //CHECK TO SEE IF SINGLEVALUE OR MULTIVALUE IS NEEDED FOR FILTER 507 if( dropdownId2 != "dd_resource_type"){ filterbyResourceType = false; } 508 if( dropdownId3 == "dd_resource_type"){ filterbyResourceType2 = true;} 509 510 511 512 if(dropdown1 != "") { 513 dropdownArray1 = dropdown1.toLowerCase().split(", ");//Convert drop down values to array 514 } else { 515 dropdown1 = "All"; 516 } 517 518 if(dropdown2 != "") { 519 dropdownArray2 = dropdown2.toLowerCase().split(", "); //Convert drop down values to array 520 } else { 521 dropdown2 = "All"; 522 } 523 524 if(dropdown3 != "") { 525 numberOfDays = dropdown3; // Selected checkbox value - its a number 30, 60, 90, 365 days 526 } else { 527 dropdown3 = "All"; 528 } 529 530 if( dropdown3 != "" && dropdownId3 == "dd_resource_type" ){ 531 dropdownArray3 = dropdown3.toLowerCase().split(", "); //Convert drop down values to array 532 } 533 534 if( dropdown4 != "" && dropdownId4 == "dd_date"){ 535 numberOfDays = dropdown4; // Selected checkbox value - its a number 30, 60, 90, 365 days 536 } 537 538 539 540 $('#locload').show(); 541 setTimeout(function() { 542 543 $('#locload').hide(); 544 $('#result1 span').text(dropdown1); //top header VALUE 545 $('#result2 span').text(dropdown2); //top header VALUE 546 $('#result3 span').text(dropdown3 + " days"); // top header date Value 547 548 549 if(dropdown1 !="All" || dropdown2 !="All" || dropdown3 !="All" || dropdown4 !="All"){ 550 551 $(".resource-list li").each(function () { 552 553 singleValue = $(this).attr('data-type').toLowerCase(); //Single value 554 multiValue = $(this).attr('data-services').toLowerCase();//Multiple value with divider 555 multiValueArray = multiValue.split("|"); //Multiple values to array 556 publishDateValue = $(this).attr('data-publishdate').toLowerCase(); //Actual date value of resource list 557 558 559 560 if(dropdown1 != "All") { 561 hasDropdown1 = dropdownArray1.some(elem => multiValueArray.indexOf(elem) > -1);
561 // Check selected value in each value on result 562 console.log("hasDropdown1", hasDropdown1) 563 } 564 565 if(dropdown2 != "All") { 566 if(filterbyResourceType){ 567 hasDropdown2 = dropdownArray2.indexOf(singleValue) >= 0; //Check selected value inside each result 568 //console.log("one") 569 } else { 570 //console.log("Two") 571 hasDropdown2 = dropdownArray2.some(elem => multiValueArray.indexOf(elem) > -1); // Check selected value in each value on result 572 } 573 } 574 575 if(dropdown3 != "All"){ 576 if(filterbyResourceType2){ 577 console.log("check here", "filterbyResourceType2" ) 578 console.log(singleValue, "singleValue") 579 hasDropdown3 = dropdownArray3.indexOf(singleValue) >= 0; //Check selected value inside each result 580 581 } else { 582 if(dropdownId3 != "dd_resource_type"){} 583 var startDate = new Date(); 584 startDate.setDate(startDate.getDate() - numberOfDays); //DATE which X days ago from today 585 var endDate = new Date(); //To get today DATE 586 var publishDate = new Date(publishDateValue.split("-").reverse().join("-")); //DATE of formatted value 587 588 if((startDate <= publishDate) && (publishDate <= endDate)){ 589 hasDropdown3 = true; 590 } else { 591 hasDropdown3 = false; 592 } 593 console.log(hasDropdown3+" "+"START:"+startDate+" "+"PUBLISH:"+publishDate) 594 } 595 } 596 597 598 if(dropdown4 != "All" ){ 599 let startDate = new Date(); 600 startDate.setDate(startDate.getDate() - numberOfDays); //DATE which X days ago from today 601 let endDate = new Date(); //To get today DATE 602 let publishDate = new Date(publishDateValue.split("-").reverse().join("-")); //DATE of formatted value 603 604 if((startDate <= publishDate) && (publishDate <= endDate)){ 605 hasDropdown4 = true; 606 } else { 607 hasDropdown4 = false; 608 } 609 console.log(hasDropdown4+" "+"START:"+startDate+" "+"PUBLISH:"+publishDate) 610 } 611 612 var mHeight = $(this).attr('data-match-height'); 613 $(this).removeClass(mHeight).attr('data-match-height', ''); 614 615 if(hasDropdown1 && hasDropdown2 && hasDropdown3 && hasDropdown4){ 616 $(this).removeClass("resHide"); 617 $(this).show(); 618 resultCount++; 619 } else if(hasDropdown1 && hasDropdown2 && hasDropdown3 ){ 620 $(this).removeClass("resHide"); 621 $(this).show(); 622 resultCount++; 623 } 624 else{ 625 $(this).addClass("resHide"); 626 $(this).hide(); 627 } 628 629 }); 630 631 632 } else if(dropdown1 =="All" && dropdown2 =="All" && dropdown3 =="All" && dropdown4 =="All" || dropdown1 =="All" && dropdown2 =="All" && dropdown3 =="All") { 633 resultCount = $(".resource-list li").length; 634 $('#selected_value').next('p').hide(); 635 $(".resource-list li").removeClass("resHide"); 636 $(".resource-list li").show(); 637 } 638 639 if(resultCount !=0){ 640 $('#selected_value').next('p').hide(); 641 $('#results_header').show(); 642 //$('#results_header h2').html('Displaying <strong>'+1+'</strong> - <strong>'+resultCount+'</strong> of <strong>'+resultCount+'</strong> Results'); 643 $('#results_header h2').html('Displaying <strong>'+resultCount+'</strong> Results'); 644 }else { 645 $('#selected_value').next('p').show(); 646 $('#results_header').hide(); 647 } 648 649 //setShowMore(); 650 $("#btnShowMore").hide(); 651 matchHeight(); 652 653 654 }, 500); 655 656 }); 657 658 /* old code* / 659 660 */ 661 662 663 664 665 $( ".resFilter li" ).on("click",function(e) { 666 e.preventDefault(); 667 668 // UI Selection Logic 669 if( $(this).data('value') != "all" ){ 670 $(this).parent('ul').children('li:first-child').removeClass("selected"); 671 } else { 672 $(this).parent('ul').children('li').removeClass("selected"); 673 } 674 675 if( $(this).hasClass('selected') ){ 676 $(this).removeClass('selected'); 677 if( ! $(this).parent('ul').children('li').hasClass("selected") ){ 678 $(this).parent('ul').children('li:first-child').addClass("selected"); 679 } 680 } else { 681 if($(this).parent('ul').attr('id') == 'dd_date') { 682 $(this).parent('ul').children('li').removeClass("selected"); 683 } 684 $(this).addClass('selected'); 685 } 686 687 // Get Dropdown IDs 688 var dropdownId1 = $('.filterlist:nth-child(1) ul').attr('id'); 689 var dropdownId2 = $('.filterlist:nth-child(2) ul').attr('id'); 690 var dropdownId3 = $('.filterlist:nth-child(3) ul').attr('id'); 691 var dropdownId4 = $('.filterlist:nth-child(4) ul').attr('id'); 692 693 // Get Values 694 var dropdown1 = getSelectedValues('#'+dropdownId1) || "All"; 695 var dropdown2 = getSelectedValues('#'+dropdownId2) || "All"; 696 var dropdown3 = getSelectedValues('#'+dropdownId3) || "All"; 697 var dropdown4 = getSelectedValues('#'+dropdownId4) || "All"; 698 699 var dropdownArray1 = (dropdown1 !== "All") ? dropdown1.toLowerCase().split(", ") : []; 700 var dropdownArray2 = (dropdown2 !== "All") ? dropdown2.toLowerCase().split(", ") : []; 701 var dropdownArray3 = (dropdown3 !== "All" && dropdownId3 == "dd_resource_type") ? dropdown3.toLowerCase().split(", ") : []; 702 703 var filterbyResourceType = (dropdownId2 == "dd_resource_type"); 704 var filterbyResourceType2 = (dropdownId3 == "dd_resource_type"); 705 706 $('#locload').show(); 707 setTimeout(function() { 708 $('#locload').hide(); 709 var resultCount = 0; 710 711 $(".resource-list li").each(function () { 712 // F1: Variables must be INSIDE the loop to reset for each item 713 var hasDropdown1 = true; 714 var hasDropdown2 = true; 715 var hasDropdown3 = true; 716 var hasDropdown4 = true; 717 718 var singleValue = $(this).attr('data-type').toLowerCase(); 719 var multiValue = $(this).attr('data-services').toLowerCase(); 720 var multiValueArray = multiValue.split("|"); 721 var publishDateValue = $(this).attr('data-publishdate').toLowerCase(); 722 var itemDate = new Date(publishDateValue.split("-").reverse().join("-")); 723 var today = new Date(); 724 725 // Filter 1 Logic 726 if(dropdown1 !== "All") { 727 hasDropdown1 = dropdownArray1.some(elem => multiValueArray.indexOf(elem) > -1); 728 } 729 730 // Filter 2 Logic (Resource Type OR other) 731 if(dropdown2 !== "All") { 732 hasDropdown2 = filterbyResourceType ? (dropdownArray2.indexOf(singleValue) >= 0) : (dropdownArray2.some(elem => multiValueArray.indexOf(elem) > -1)); 733 } 734 735 // Filter 3 Logic (Resource Type OR Date) 736 if(dropdown3 !== "All") { 737 if(filterbyResourceType2) { 738 hasDropdown3 = dropdownArray3.indexOf(singleValue) >= 0; 739 } else { 740 var start3 = new Date(); 741 start3.setDate(today.getDate() - parseInt(dropdown3)); 742 hasDropdown3 = (itemDate >= start3 && itemDate <= today); 743 } 744 } 745 746 // Filter 4 Logic (Date) 747 if(dropdown4 !== "All") { 748 var start4 = new Date(); 749 start4.setDate(today.getDate() - parseInt(dropdown4)); 750 hasDropdown4 = (itemDate >= start4 && itemDate <= today); 751 } 752 753 // F2: Clear MatchHeight 754 var mHeight = $(this).attr('data-match-height'); 755 $(this).removeClass(mHeight).attr('data-match-height', ''); 756 757 // F3: Strict AND logic. All active filters must be true. 758 if(hasDropdown1 && hasDropdown2 && hasDropdown3 && hasDropdown4) { 759 console.log("check here"); 760 $(this).removeClass("resHide").show(); 761 resultCount++; 762 } else { 763 $(this).addClass("resHide").hide(); 764 } 765 }); 766 767 // Update Results UI 768 $('#result1 span').text(dropdown1); 769 $('#result2 span').text(dropdown2); 770 //$('#result3 span').text(dropdown3 + (isNaN(dropdown3) ? "" : " days")); 771 772 // Header Result 3 (Handles either Resource Type or Date) 773 var display3 = (dropdown3 === "All") ? "All" : (isNaN(dropdown3) ? dropdown3 : dropdown3 + " days"); 774 $('#result3 span').text(display3); 775 776 // Header Result 4 (Handles Date Result) 777 if ($('#result4').length > 0) { 778 var display4 = (dropdown4 === "All") ? "All" : (isNaN(dropdown4) ? dropdown4 : dropdown4 + " days"); 779 $('#result4 span').text(display4); 780 } 781 782 783 if(resultCount != 0) { 784 $('#selected_value').next('p').hide(); 785 $('#results_header').show().find('h2').html('Displaying <strong>
785'+resultCount+'</strong> Results'); 786 } else { 787 $('#selected_value').next('p').show(); 788 $('#results_header').hide(); 789 } 790 791 $("#btnShowMore").hide(); 792 matchHeight(); 793 }, 500); 794}); 795 796 797 798 799 800 $('.locclear').on('click', function (e) { 801 e.preventDefault(); 802 $('.filterlist ul li:first-child').trigger('click'); 803 }); 804 805 //Keyboard accessibility 806 $('.filterHead').on('keydown', function (e) { 807 var keyCode = (e.keyCode ? e.keyCode : e.which); 808 //Spacebar to open filterbox 809 if (keyCode == '32' && !($('.filterHead').next('ul').is(':visible'))) { 810 e.preventDefault(); 811 $(this).trigger( 'click'); 812 $(this).next('ul').find('li.focusable').removeClass('focusable'); 813 $(this).next('ul').find('li:first').addClass('focusable'); 814 } else if (keyCode == '32' && $('.filterHead').next('ul').is(':visible')){ 815 e.preventDefault(); 816 $(this).next('ul').find('li.focusable').trigger('click'); 817 } 818 //Up arrow key to move filter list hover effect 819 if (keyCode == '38') { 820 e.preventDefault(); 821 var length = $(this).next('ul').find('li.focusable').prev('li').length; 822 if(length > 0){ 823 $(this).next('ul').find('li.focusable').removeClass('focusable').prev('li').addClass('focusable'); 824 } 825 } 826 //Down arrow key to move filter list hover effect 827 if (keyCode == '40') { 828 e.preventDefault(); 829 var length = $(this).next('ul').find('li.focusable').next('li').length; 830 if(length > 0){ 831 $(this).next('ul').find('li.focusable').removeClass('focusable').next('li').addClass('focusable'); 832 } 833 } 834 //TAB keydown 835 if (keyCode == '9') { 836 $('.filterHead').removeClass('active'); 837 $('.filterHead').next('ul').slideUp(); 838 } 839 }); 840 841 //Show more button 842 $("#btnShowMore").on("click",function(e) { 843 e.preventDefault(); 844 $(this).blur(); 845 846 847 //var currentPosition = $(document).scrollTop(); 848 //console.log(currentPosition); 849 850 $('ul.resource-list li').removeClass("shown"); 851 var listCount = $('ul.resource-list li').length; 852 $('ul.resource-list li:hidden').each(function(index){ 853 //if(index >= listCount){ $("#btnShowMore").hide(); } 854 if(index + 1 <= showMoreCount){ 855 $(this).addClass("shown"); 856 $(this).show(); 857 }else{ 858 return false; 859 } 860 }); 861 862 //HIDE BUTTON IF COMPLETE 863 if( $('ul.resource-list li:hidden').length == 0 ){ $("#btnShowMore").hide();} 864 865 866 //$(document).scrollTop(currentPosition); 867 matchHeightShowMore(); 868 869 870 }); 871 872 $("#btnGateAccess").on("click",function(e) { 873 e.preventDefault(); 874 var isValidForm = 1; 875 876 $('#txtGateFName').parent('.required').removeClass('invalid'); 877 if( $('#txtGateFName').val() == "" ){ 878 $('#txtGateFName').parent('.required').addClass('invalid'); 879 isValidForm = 0; 880 } 881 882 $('#txtGateLName').parent('.required').removeClass('invalid'); 883 if( $('#txtGateLName').val() == "" ){ 884 $('#txtGateLName').parent('.required').addClass('invalid'); 885 isValidForm = 0; 886 } 887 888 $('#txtGateEmail').parent('.required').removeClass('invalid'); 889 if( $('#txtGateEmail').val() == "" ){ 890 $('#txtGateEmail').parent('.required').addClass('invalid'); 891 isValidForm = 0; 892 } 893 if( !validEmail($('#txtGateEmail').val()) ){ 894 $('#txtGateEmail').parent('.required').addClass('invalid validEmail'); 895 isValidForm = 0; 896 } 897 898 $('#txtGateCompany').parent('.required').removeClass('invalid'); 899 if( $('#txtGateCompany').val() == "" ){ 900 $('#txtGateCompany').parent('.required').addClass('invalid'); 901 isValidForm = 0; 902 } 903 904 if(isValidForm){ 905 var cookieName = $('#article_gate').data('gate'); 906 setCookie(cookieName,1,30); 907 908 //SUBMIT FORM HANDLER 909 //location.reload(); 910 var form = document.createElement("form"); 911 form.id = "frm_articlegate"; 912 form.method = "POST"; 913 form.action = "https://experience.rrd.com/l/516441/2023-07-27/b2jccv"; 914 915 //GENERATE FORM FIELDS 916 form.appendChild( createFormElement('Email', 'txtGateEmail') ); 917 form.appendChild( createFormElement('First Name', 'txtGateFName') ); 918 form.appendChild( createFormElement('Last Name', 'txtGateLName') ); 919 form.appendChild( createFormElement('Company', 'txtGateCompany') ); 920 form.appendChild( createFormElement('Email Opt-In', 'radOptIn') ); 921 form.appendChild( createFormElement('Title', 'hidTitle') ); 922 923 //ADD FORM TO PAGE AND SUBMIT 924 document.body.appendChild(form); 925 form.submit(); 926 } 927 928 929 }); 930 931 932}); 933 934 935/*SHOW MORE BUTTON*/ 936var showMoreCount = 12; 937function setShowMore(){ 938 if( $('#btnShowMore').length ){ 939 var listCount = $('ul.resource-list li').length; 940 941 942 $('ul.resource-list li').hide(); 943 $("ul.resource-list li").each(function(index){ 944 945 if(index + 1 <= showMoreCount){ 946 $(this).show(); 947 $(this).focus; 948 }else{ 949 return false; 950 } 951 }); 952 953 //HIDE BUTTON IF COMPLETE 954 955 if( $('ul.resource-list li:hidden').length == 0 ){ 956 $("#btnShowMore").hide(); 957 958 } 959 960 } 961} 962 963 964 965function setRows(){ 966 967 968 //DETERMINE ROW LENGTH AND ADJUST 969 var rowLength = 4; 970 if (window.matchMedia('(max-width: 1024px)').matches){rowLength = 3;} 971 if (window.matchMedia('(max-width: 760px)').matches){rowLength = 2;} 972 if (window.matchMedia('(max-width: 500px)').matches){rowLength = 1;} 973
974 //LOOP ALL VISIBLE AND SET ROWCOUNT 975 $('ul.resource-list li:visible').each(function(index){ 976 $(this).removeClassStartingWith("row"); 977 var rowClass = "row" + Math.floor(index / rowLength); 978 979 if (window.matchMedia('(min-width: 1024px)').matches){ 980 if( $(this).parent("ul.resource-list").hasClass("custom") ){ 981 if(index == 0){ rowClass = "row0" } 982 if(index == 1){ rowClass = "row0" } 983 if(index == 2){ rowClass = "row0" } 984 if(index == 3){ rowClass = "row1" } 985 if(index == 7){ rowClass = "row2" } 986 if(index == 11){ rowClass = "row3" } 987 if(index == 15){ rowClass = "row4" } 988 if(index == 19){ rowClass = "row5" } 989 if(index == 23){ rowClass = "row6" } 990 } 991 } 992 993 $(this).attr("data-match-height",rowClass); 994 $(this).addClass(rowClass); 995 }); 996 997} 998 999 1000 1001//Get selected values from filter list 1002function getSelectedValues(id){ 1003 var selectedValues = "" 1004 $(id).children('li').each(function () { 1005 if ($(this).hasClass('selected')) { 1006 var selectedValue = $(this).find("input[type='checkbox']").val(); 1007 if (selectedValue != 'all') { 1008 selectedValues += selectedValue + ", "; 1009 } 1010 } 1011 }); 1012 selectedValues = selectedValues.substring(0, selectedValues.length - 1).slice(0, -1); //REMOVE TRAILING DIVIDER 1013 return selectedValues; 1014} 1015 1016/*MATCH VERTICAL HEIGHT FOR COLUMNS*/ 1017function matchHeight(){ 1018 1019 1020 1021 setRows(); 1022 1023 1024 //CLEAR CURRENT MATCHHEIGHT 1025 $("[data-match-height]:visible").css('height',''); 1026 1027 var currentElement = ''; 1028 $("[data-match-height]:visible").each(function(){ 1029 if(currentElement != $(this).attr('data-match-height') ){ 1030 currentElement = $(this).attr('data-match-height'); 1031 var tallestElement = 0; 1032 $("."+currentElement).each(function(){ 1033 if( $(this).height() >= tallestElement ){ tallestElement = $(this).height(); } 1034 }); 1035 $("."+currentElement).height(tallestElement); 1036 } 1037 currentElement = $(this).attr('data-match-height'); 1038 }); 1039 1040} 1041 1042function matchHeightShowMore(){ 1043 1044 //DETERMINE ROW LENGTH AND ADJUST 1045 /*var rowLength = 4; 1046 if (window.matchMedia('(max-width: 1024px)').matches){ rowLength = 3;} 1047 if (window.matchMedia('(max-width: 760px)').matches){ rowLength = 2;} 1048 if (window.matchMedia('(max-width: 500px)').matches){ rowLength = 1;} 1049 1050 1051 $('ul.resource-list li:visible').each(function(index){ 1052 $(this).removeClassStartingWith("row"); 1053 var rowClass = "row" + Math.floor(index / rowLength); 1054 $(this).attr("data-match-height",rowClass); 1055 $(this).addClass(rowClass); 1056 });*/ 1057 1058 //SET MATCHEIGHT 1059 1060 $(".shown[data-match-height]:visible").css('height',''); 1061 1062 var currentElement = ''; 1063 $(".shown[data-match-height]:visible").each(function(){ 1064 if(currentElement != $(this).attr('data-match-height') ){ 1065 currentElement = $(this).attr('data-match-height'); 1066 var tallestElement = 0; 1067 $("."+currentElement).each(function(){ 1068 if( $(this).height() >= tallestElement ){ tallestElement = $(this).height(); } 1069 }); 1070 $("."+currentElement).height(tallestElement); 1071 } 1072 currentElement = $(this).attr('data-match-height'); 1073 }); 1074 1075} 1076 1077 1078function setCookie(cname, cvalue, exdays) { 1079 const d = new Date(); 1080 d.setTime(d.getTime() + (exdays*24*60*60*1000)); 1081 let expires = "expires="+ d.toUTCString(); 1082 document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/"; 1083} 1084 1085function validEmail(email) { 1086 var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; 1087 return re.test(email); 1088} 1089 1090function createFormElement(pFieldName, myFieldName){ 1091 var myElement = document.createElement("input"); 1092 myElement.name = pFieldName; 1093 myElement.ID = pFieldName; 1094 1095 if ( $('#'+myFieldName).length ) { 1096 myElement.value = $('#'+myFieldName).val(); 1097 }else { 1098 myElement.value = ''; 1099 1100 } 1101 1102 //CHECK IF RADIO ELEMENT 1103 if (myFieldName.indexOf("rad") >= 0){ 1104 myElement.value = $('input[name="' + myFieldName + '"]:checked').val(); 1105 } 1106 1107 1108 1109 myElement.setAttribute("type", "hidden"); 1110 return myElement; 1111} 1112 1113 1114//USE FOR CLASS WILDCARDS 1115 $.fn.removeClassStartingWith = function (filter) { 1116 $(this).removeClass(function (index, className) { 1117 return (className.match(new RegExp("\\S*" + filter + "\\S*", 'g')) || []).join(' ') 1118 });
1119 return this; 1120};
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.