Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
KristinaHranovska committed Feb 14, 2024
1 parent 6181f05 commit 938d81b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
3 changes: 3 additions & 0 deletions src/js/add-to-favorites.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ function getIDModul(e) {
}
}
}

if (!localStorage.getItem('addKeyID')) {
const emptyArrayAdd = [];
localStorage.setItem('addKeyID', JSON.stringify(emptyArrayAdd));
Expand All @@ -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');
Expand All @@ -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');
Expand Down
16 changes: 0 additions & 16 deletions src/js/modal-window.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

// Відкриття модалки
Expand Down
2 changes: 1 addition & 1 deletion src/partials/modal-window.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h3 class="title-exer">Burned Calories</h3>
</ul>
<p class="main-parag js-description js-capital"></p>
</div>
<div class="buttons-modal visually-hidden">
<div class="buttons-modal">
<button class="add-to-favorities">
Add to favorites
<svg class="heart-btn-icon" width="18" height="18">
Expand Down

0 comments on commit 938d81b

Please sign in to comment.