Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function generateAuthors() {
- let allAuthors = {};
- const authorsList = document.querySelector(optAuthorsListSelector);
- const films = document.querySelectorAll(optFilmSelector);
- let html = '';
- for(let film of films){
- const author = film.getAttribute('data-author');
- if(!allAuthors.hasOwnProperty(author)){
- allAuthors[author] = 1;
- } else {
- allAuthors[author]++;
- }
- }
- for(let author in allAuthors){
- html += '<li><a href="#author-' + author + '">' + author + '</a></li>'
- }
- authorsList.innerHTML = html;
- const authors = document.querySelectorAll('.authors a')
- for(let author of authors){
- author.addEventListener('click', authorClickHandler);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement