Skip to content

Commit

Permalink
commit tree 7749e539d5ff69d2c366d200335f5970db4d266b
Browse files Browse the repository at this point in the history
  • Loading branch information
ketah committed Jul 1, 2022
1 parent 468b910 commit 59f5566
Showing 1 changed file with 23 additions and 24 deletions.
47 changes: 23 additions & 24 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,34 +34,33 @@
const EMPTY_HEART = '♡'
const FULL_HEART = '♥'

const articleHearts = document.querySelectorAll(".like-glyph");

function likeCallback(e) {
const heart = e.target;
mimicServerCall()
.then(function(){
if ( liker.innerText === EMPTY_HEART) {
liker.innerText = FULL_HEART;
liker.className = "activated-heart";
} else {
liker.innerText = EMPTY_HEART;
liker.className = "";
}
})
.catch((error)=> {
let modal = document.getElementById("modal");
//
const heartResponce = document.querySelectorAll(".like-glyph");

function likefunc(event) {
const likeHeart = event.target;
mimicServerCall()
.then(() => {
if ( likeHeart.innerText === EMPTY_HEART) {
likeHeart.innerText = FULL_HEART;
likeHeart.className = "activated-heart";
} else {
likeHeart.innerText = EMPTY_HEART;
likeHeart.className = "";
}
})
.catch((error) => {
const modal = document.getElementById("modal");
modal.className = "";
modal.innerText = error;
setTimeout(() => modal.className = "hidden", 3000);
});

}

for (const glyph of articleHearts) {
glyph.addEventListener("click", likeCallback);
}


}

for (const glyphlike of heartResponce) {
glyphlike.addEventListener("click", likefunc);
}



//------------------------------------------------------------------------------
Expand Down

0 comments on commit 59f5566

Please sign in to comment.