diff --git a/src/js/add-to-favorites.js b/src/js/add-to-favorites.js index 972d8de..1b5c00b 100644 --- a/src/js/add-to-favorites.js +++ b/src/js/add-to-favorites.js @@ -20,6 +20,7 @@ function getIDModul(e) { } } } + if (!localStorage.getItem('addKeyID')) { const emptyArrayAdd = []; localStorage.setItem('addKeyID', JSON.stringify(emptyArrayAdd)); @@ -28,6 +29,7 @@ if (!localStorage.getItem('removeKeyID')) { const emptyArrayRemove = []; localStorage.setItem('removeKeyID', JSON.stringify(emptyArrayRemove)); } + addToFavoritesBtn.addEventListener('click', getIdFavorites); function getIdFavorites() { removeFromFavoritesBtn.classList.remove('hidden-btn'); @@ -37,6 +39,7 @@ function getIdFavorites() { storedArrayFavorites.push(cardID); localStorage.setItem('addKeyID', JSON.stringify(storedArrayFavorites)); } + removeFromFavoritesBtn.addEventListener('click', removeIdFavorites) function removeIdFavorites() { removeFromFavoritesBtn.classList.add('hidden-btn'); diff --git a/src/js/modal-window.js b/src/js/modal-window.js index f1a4e46..1e9cc0f 100644 --- a/src/js/modal-window.js +++ b/src/js/modal-window.js @@ -4,22 +4,6 @@ const backdrop = document.querySelector('.backdrop-thumb'); const closeIcon = document.querySelector('.js-modal-window'); const galleryWindow = document.querySelector('.js-gallery'); -const link = document.querySelector('.link-home'); -const isActiveLink = link.getAttribute('href'); -const currentPage = window.location.pathname; -const removeCards = document.querySelector('.buttons-modal'); - -// Якщо поточна сторінка - index.html, то показуємо блок з кнопкою -if (currentPage.includes('index.html') || isActiveLink === './index.html') { - removeCards.classList.remove('visually-hidden'); -} - -if ( - currentPage.includes('favorites.html') || - isActiveLink === './favorites.html' -) { - removeCards.classList.add('visually-hidden'); -} galleryWindow.addEventListener('click', openModal); // Відкриття модалки diff --git a/src/partials/modal-window.html b/src/partials/modal-window.html index 5430557..50a422a 100644 --- a/src/partials/modal-window.html +++ b/src/partials/modal-window.html @@ -64,7 +64,7 @@

Burned Calories

-
+