SHARE
TWEET

Untitled

a guest Mar 26th, 2020 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function generateAuthors() {
  2.     let allAuthors = {};
  3.     const authorsList = document.querySelector(optAuthorsListSelector);
  4.     const films = document.querySelectorAll(optFilmSelector);
  5.     let html = '';
  6.  
  7.     for(let film of films){
  8.         const author = film.getAttribute('data-author');
  9.    
  10.         if(!allAuthors.hasOwnProperty(author)){
  11.           allAuthors[author] = 1;
  12.         } else {
  13.           allAuthors[author]++;
  14.       }
  15.     }
  16.  
  17.     for(let author in allAuthors){
  18.       html += '<li><a href="#author-' + author + '">' + author + '</a></li>'
  19.     }
  20.     authorsList.innerHTML = html;
  21.  
  22.     const authors = document.querySelectorAll('.authors a')
  23.  
  24.     for(let author of authors){
  25.       author.addEventListener('click', authorClickHandler);
  26.     }
  27.  
  28. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top