Sha256: d58c3e89acfe08a260f94d768179a2853bb2a955c4ce8600f502049b09b42d29

Contents?: true

Size: 664 Bytes

Versions: 13

Compression:

Stored size: 664 Bytes

Contents

const form = document.getElementById('SearchTermForm');
const searchURL = 'https://www.kcc.edu/search';

function submissionHandler(e) {
  const target = e.target;
  const searchString = encodeURIComponent(target.querySelector('#searchTermInput').value); // user enter search term into input element
  // Google Custom Search can be triggered using a query string on the search page e.g. `?q=my-search`
  const searchQuery = `?q=${searchString}`;

  e.preventDefault();
  return window.location = new URL(searchURL + searchQuery);
}

function watchForWebsiteSearch() {
  form.addEventListener('submit', submissionHandler);
}

export default watchForWebsiteSearch;

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
kcc-gem-theme-original-1.2.3 assets/js/src/watchForWebsiteSearch.js
kcc-gem-theme-original-1.2.2 assets/js/src/watchForWebsiteSearch.js
kcc-gem-theme-original-1.2.1 assets/js/src/watchForWebsiteSearch.js
kcc-gem-theme-original-1.2.0 assets/js/src/watchForWebsiteSearch.js
kcc-gem-theme-original-1.1.0 assets/js/src/watchForWebsiteSearch.js
kcc-gem-theme-original-1.0.8 assets/js/src/watchForWebsiteSearch.js
kcc-gem-theme-original-1.0.7 assets/js/src/watchForWebsiteSearch.js
kcc-gem-theme-original-1.0.6 assets/js/src/watchForWebsiteSearch.js
kcc-gem-theme-original-1.0.5 assets/js/src/watchForWebsiteSearch.js
kcc-gem-theme-original-1.0.4 assets/js/src/watchForWebsiteSearch.js
kcc-gem-theme-original-1.0.3 assets/js/src/watchForWebsiteSearch.js
kcc-gem-theme-original-1.0.2 assets/js/src/watchForWebsiteSearch.js
kcc-gem-theme-original-1.0.1 assets/js/src/watchForWebsiteSearch.js