Skip to content

Commit

Permalink
#36 아티스트 클릭 이벤트
Browse files Browse the repository at this point in the history
  • Loading branch information
stories2 committed Jun 23, 2021
1 parent e1c2f3d commit 5c50144
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions public/src/artist.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,26 @@ function init() {
artistItem.ele.querySelector('#desc').textContent = artistItem.desc;
artistItem.ele.querySelector('div.artist-img').style.backgroundImage = `url('${artistItem.img}')`
artistItem.ele.querySelector('div.artist-img').setAttribute('data-url', artistItem.href);

artistItem.ele.addEventListener('click', (e) => {
const currentEle = artistItem.ele
const url = currentEle.querySelector('div.artist-img').getAttribute('data-url')
const artistName = currentEle.querySelector('#name').textContent
if (artistName) {
analytics.logEvent('artist-clicked', {
status: 'ok',
artist: artistName
});
} else {
analytics.logEvent('artist-clicked', {
status: 'warn',
artist: 'Undefined artist name'
});
}
if (url) {
window.open(url, '_blank');
}
})
}
})
}
Expand Down

0 comments on commit 5c50144

Please sign in to comment.