1const cx = '001912136203379195774:c8pjud2lumc'; 2 3const gcse = document.createElement('script'); 4gcse.type = 'text/javascript'; 5gcse.async = true; 6gcse.src = 'https://cse.google.com/cse/cse.js?cx=' + cx; 7 8const firstDOMScript = document.getElementsByTagName('script')[0]; 9firstDOMScript.parentNode.insertBefore(gcse, firstDOMScript); 10 11 12document.addEventListener('DOMContentLoaded', function () { 13 const $searchButton = $('#searchButton'); 14 const $mobileSearchbarBtn = $('#mobileSearchbarBtn'); 15 const $mobileSearchbarBtnImg = $('#mobileSearchbarBtn img'); 16 const $divGoogleProgSearch = $('#divGoogleProgSearch'); 17 18 const $controls = { 19 searchBtn: $searchButton, 20 mobileSearchBtn: $mobileSearchbarBtn, 21 mobileSearchBtnImg: $mobileSearchbarBtnImg, 22 GPSearchContainer: $divGoogleProgSearch 23 }; 24 25 setTimeout(function () { 26 const searchInput = document.getElementById('gsc-i-id1'); 27 28 if (searchInput) { 29 // 1. Get the target button 30 31 // 2. Attach the keydown listener to the input 32 searchInput.addEventListener('keydown', (event) => { 33 if (event.key === 'Enter' || event.keyCode === 13) { 34 setTimeout(() => { 35 const closeButton = document.querySelector('.gsc-results-close-btn'); 36 37 if (closeButton) { 38 console.log("Found close button and attempting focus:", closeButton); 39 40 // Now call focus() after a slight delay 41 closeButton.focus(); 42 } else { 43 console.warn("Close button not found after Enter press delay."); 44 } 45 }, 500); 46 } 47 }); 48 } 49 }, 500); 50 51 52 53 $("#divGoogleProgSearch").off('keydown').on('keydown', function (event) { 54 // Recalculate on every keydown 55 const focusableElements = $(this).find('a, button, input').filter(':visible'); 56 const firstElement = focusableElements.get(0); 57 const lastElement = focusableElements.get(focusableElements.length - 1); 58 //if ($('.gsc-results-wrapper-visible').length <= 0) { 59 // lastElement = $('gsc-search-button-v2'); 60 //} 61 62 if (event.key === 'Escape') { 63 // ... your closing logic ... 64 } 65 66 if (window.innerWidth < 1025) { 67 68 if (event.key === 'Tab' && document.activeElement === lastElement && !event.shiftKey) { 69 closeAllFlyouts(); 70 $('button.hamburger-button.button[data-toggle="offCanvas"]').focus(); 71 event.preventDefault(); 72 } else if (event.shiftKey && event.key === 'Tab' && document.activeElement === firstElement) { 73 closeAllFlyouts(); 74 $('button.hamburger-button.button[data-toggle="offCanvas"]').focus(); 75 event.preventDefault(); 76 } 77 78 } else { 79 80 if (event.key === 'Tab' && document.activeElement === lastElement && !event.shiftKey) { 81 closeAllFlyouts(); 82 if ($('#offCanvas').is(':visible')) { 83 $mobileSearchbarBtn.focus(); 84 } 85 else { 86 $searchButton.focus(); 87 } 88 event.preventDefault(); 89 } 90 // If the user presses Shift + Tab from the first focusable element 91 if (event.shiftKey && event.key === 'Tab' && document.activeElement === firstElement) { 92 closeAllFlyouts(); 93 if ($('#offCanvas').is(':visible')) { 94 $mobileSearchbarBtn.focus(); 95 } 96 else { 97 $searchButton.focus(); 98 } 99 event.preventDefault(); 100 } 101 } 102 103 }); 104 105 $searchButton.on('click', function (e) { 106 e.stopPropagation(); 107 108 // Check if the search bar is already active 109 if ($('.wsu-googleprogsearch').hasClass('active')) { 110 // If it is, close all flyouts (including the search bar) 111 closeAllFlyouts(); 112 } else { 113 // If it's not active, close all other flyouts and open the search bar 114 closeAllFlyouts('divGoogleProgSearch'); 115 $('.wsu-googleprogsearch').addClass('active'); 116 $('#gsc-i-id1').focus(); 117 } 118 });
119 120 $mobileSearchbarBtn.on('click', (e) => { 121 //e.stopPropagation(); 122 123 // Check if the search bar is already active 124 if ($('.wsu-googleprogsearch').hasClass('active')) { 125 // If it is, close all flyouts (including the search bar) 126 closeAllFlyouts(); 127 } else { 128 // If it's not active, close all other flyouts and open the search bar 129 closeAllFlyouts('divGoogleProgSearch'); 130 $('.wsu-googleprogsearch').addClass('active'); 131 $('#gsc-i-id1').focus(); 132 } 133 }); 134 135 $(document).on('click', function (event) { 136 137 const $searchResBackdrop = $('.gsc-modal-background-image'); 138 const $searchResCloseBtn = $('.gsc-results-close-btn'); 139 140 if ( 141 shouldCloseSearchbar(event.target, $controls) || 142 $(event.target).is($searchResBackdrop) || 143 $(event.target).is($searchResCloseBtn) 144 ) { 145 $divGoogleProgSearch.removeClass('active'); 146 $('#searchButton').focus(); 147 } 148 }); 149 150 //$(document).on('keydown', function (event) { 151 // // Check if the key pressed is 'Enter' (key code 13) 152 // if (event.key === 'Enter' || event.keyCode === 13) { 153 // if ($divGoogleProgSearch.hasClass('active')) { 154 // $divGoogleProgSearch.removeClass('active'); 155 // $('#searchButton').focus(); 156 // } 157 // } 158 //}); 159 160 document.addEventListener('keydown', function (event) { 161 if (window.innerWidth < 1025) { 162 if (event.key === 'Enter' || event.keyCode === 13) { 163 const activeElement = document.activeElement; 164 if (activeElement && activeElement.classList.contains("gsc-results-close-btn")) { 165 166 $divGoogleProgSearch.removeClass('active'); 167 168 const googleSearchModal = document.querySelector('.gsc-results-wrapper-overlay'); 169 googleSearchModal.classList.remove('gsc-results-wrapper-visible'); 170 171 const googleSearchModalOverlay = document.querySelector('.gsc-modal-background-image'); 172 googleSearchModalOverlay.classList.remove('gsc-modal-background-image-visible'); 173 174 175 $('#mobileSearchbarBtn').focus(); 176 177 event.stopImmediatePropagation(); 178 event.preventDefault(); 179 } 180 } 181 } 182 else { 183 if (event.key === 'Enter' || event.keyCode === 13) { 184 const activeElement = document.activeElement; 185 if (activeElement && activeElement.classList.contains("gsc-results-close-btn")) { 186 187 $divGoogleProgSearch.removeClass('active'); 188 189 const googleSearchModal = document.querySelector('.gsc-results-wrapper-overlay'); 190 googleSearchModal.classList.remove('gsc-results-wrapper-visible'); 191 192 const googleSearchModalOverlay = document.querySelector('.gsc-modal-background-image'); 193 googleSearchModalOverlay.classList.remove('gsc-modal-background-image-visible'); 194 195 $('#searchButton').focus(); 196 197 event.stopImmediatePropagation(); 198 event.preventDefault(); 199 } 200 } 201 } 202 }, true); 203 204}); 205 206function shouldCloseSearchbar(target, $controls) { 207 return ( 208 $controls.GPSearchContainer.hasClass('active') && 209 !$(target).is($controls.searchBtn) && 210 !$(target).is($controls.mobileSearchBtn) && 211 !$(target).is($controls.mobileSearchBtnImg) && 212 !$(target).closest($controls.GPSearchContainer).length && 213 !$(target).closest('div.gsq_a').length && 214 !$(target).closest('table.gsc-completion-container').length 215 ); 216}
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.