function renderAliases(data) { const dataContainer = document.getElementById('container'); const template = Handlebars.compile(okHandlebarsTemplate); const html = template({ data: data.sort((a, b) => new Date(a.created) - new Date(b.created)) }); dataContainer.innerHTML = html; } function createAlias() { const tags = document.getElementById('tags').value?.split(',') || []; fetch('/aliases', { method: 'POST', body: JSON.stringify({ tags }), headers: { 'Content-Type': 'application/json' } }) .then(res => res.json()) .then(data => { renderAliases(data) }) } function deleteAlias(id) { fetch(`/aliases/${id}`, { method: 'DELETE' }) .then(res => res.json()) .then(data => { renderAliases(data) }) } function copyToClipboard(text) { navigator.clipboard.writeText(text) } const okHandlebarsTemplate = `
Address | Tags | Created | Action |
---|---|---|---|
{{address}} | {{#each tags}}{{this}} {{/each}} | {{created}} |
Delete
|