function addMatch(match) {
  const matchElement = document.createElement('li');
  matchElement.dataset.location = match.l; // location used to find match
  matchElement.dataset.citation = formatCitation(match); // displayed location
  if (match.i) {
    // stage direction matches have an index
    matchElement.dataset.index = match.i;
  } else if (match.s) {
    // add speaker name and gender, as used for search options
    matchElement.dataset.speaker = match.s;
    matchElement.dataset.gender = match.g;
  } else if (match.r && match.r === 's') {
    // add classes for stage directions and scene titles (just for text styling)
    matchElement.classList.add('stage-direction');
  } else if (match.r && match.r === 't') {
    matchElement.classList.add('scene-title');
  }
  matchElement.innerHTML = match.t;
  matchElement.onclick = function() {
    displayText(match);
  };
  matchesList.appendChild(matchElement);
}
// Add an individual match element to the list of matches
Add an individual match element to the list of matches
Add an individual match element to the list of matches
function addMatch(match) {
  const matchElement = document.createElement('li');
  matchElement.dataset.location = match.l; 
  matchElement.dataset.citation = formatCitation(match); 
  if (match.i) {
    matchElement.dataset.index = match.i;
  } else if (match.s) {
    matchElement.dataset.speaker = match.s;
    matchElement.dataset.gender = match.g;
  } else if (match.r && match.r === 's') {
    matchElement.classList.add('stage-direction');
  } else if (match.r && match.r === 't') {
    matchElement.classList.add('scene-title');
  }
  matchElement.innerHTML = match.t;
  matchElement.onclick = function() {
    displayText(match);
  };
  matchesList.appendChild(matchElement);
}
function addMatch ( match ) { const matchElement = document . createElement ( 'li' ) ; matchElement . dataset . location = match . l ; matchElement . dataset . citation = formatCitation ( match ) ; if ( match . i ) { matchElement . dataset . index = match . i ; } else if ( match . s ) { matchElement . dataset . speaker = match . s ; matchElement . dataset . gender = match . g ; } else if ( match . r && match . r === 's' ) { matchElement . classList . add ( 'stage-direction' ) ; } else if ( match . r && match . r === 't' ) { matchElement . classList . add ( 'scene-title' ) ; } matchElement . innerHTML = match . t ; matchElement . onclick = function ( ) { displayText ( match ) ; } ; matchesList . appendChild ( matchElement ) ; }
Add an individual match element to the list of matches
Add an individual match element to the list of matches
// location used to find match // displayed location // stage direction matches have an index // add speaker name and gender, as used for search options // add classes for stage directions and scene titles (just for text styling)