You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

20 lines
721 B

const escape = require('escape-html');
const badgeLinkUrl = username => `https://tippin.me/@${username}`;
const badgeImageUrl = username => `https://badgen.net/badge/%E2%9A%A1%EF%B8%8Ftippin.me/@${username}/F0918E`;
const badgeHtml = username => `
<a href="${badgeLinkUrl(username)}" rel="noopener noreferrer" target="_blank">
<img src="${badgeImageUrl(username)}" alt="@${username} on tippin.me"/>
</a>
`;
const username = document.querySelector('input[name="username"]');
const badgePreview = document.querySelector('.badge-preview');
const generateBadge = () => {
badgePreview.innerHTML = badgeHtml(escape(username.value) || 'username');
};
generateBadge();
username.addEventListener('input', generateBadge);