function addWordSearch(hoverEvent) {
  const el = hoverEvent.target;
  // hover events are also fired by the parent
  // plays and sonnets use <li> for each line; poems use <p>
  if (el.nodeName === 'DIV' || el.nodeName === 'LI' || el.nodeName === 'P') {
    el.innerHTML = el.innerText.replace(/([\w]+)/g, '<span>$1</span>');
    el.onclick = spanClickEvent => {
      const word = spanClickEvent.target.textContent;
      history.pushState({isSearchResults: true}, null,
        `${window.location.origin}#${word}`);
      queryInput.value = word;
      doSearch(word);
      window.scrollTo(0, 127); // to display search input
    };
  }
}
// so they can click on a word to search for it.
so they can click on a word to search for it.
so they can click on a word to search for it .
function addWordSearch(hoverEvent) {
  const el = hoverEvent.target;
  if (el.nodeName === 'DIV' || el.nodeName === 'LI' || el.nodeName === 'P') {
    el.innerHTML = el.innerText.replace(/([\w]+)/g, '<span>$1</span>');
    el.onclick = spanClickEvent => {
      const word = spanClickEvent.target.textContent;
      history.pushState({isSearchResults: true}, null,
        `${window.location.origin}#${word}`);
      queryInput.value = word;
      doSearch(word);
      window.scrollTo(0, 127); 
    };
  }
}
function addWordSearch ( hoverEvent ) { const el = hoverEvent . target ; if ( el . nodeName === 'DIV' || el . nodeName === 'LI' || el . nodeName === 'P' ) { el . innerHTML = el . innerText . replace ( / ([\w]+) / g , '<span>$1</span>' ) ; el . onclick = spanClickEvent => { const word = spanClickEvent . target . textContent ; history . pushState ( { isSearchResults : true } , null , ` ${ window . location . origin } ${ word } ` ) ; queryInput . value = word ; doSearch ( word ) ; window . scrollTo ( 0 , 127 ) ; } ; } }
so they can click on a word to search for it.
so they can click on a word to search for it .
// hover events are also fired by the parent // plays and sonnets use <li> for each line; poems use <p> // to display search input