const isTag = ele => ele.classList.contains('tag') const links = [...document.querySelectorAll('a')] // Set statistics {{{ const counter = document.querySelector('#counter') counter.textContent = links.length // }}} // Modal for links {{{ // click links to open modal links.forEach(a => a.onclick = e => { e.preventDefault() modalForLink(a) }) // create modal for display details of links const modal = document.createElement('dialog') modal.id = 'modal' document.body.append(modal) modal.onclick = event => event.target == modal && modal.close() modal.innerHTML = `

` const heading = modal.querySelector('#heading') const qrcode = modal.querySelector('#qrcode') const copy = modal.querySelector('#copy') const link = modal.querySelector('#link a') link.onclick = e => e.stopPropagation() function modalForLink (a) { const url = a.href qrcode.innerHTML = '' new QRCode(qrcode, url) link.href = url link.textContent = url heading.textContent = a.textContent copy.textContent = '📋COPY' modal.showModal() } const copyLink = (ele) => { navigator.clipboard.writeText(link.href) ele.textContent = '👌COPIED' } // }}} // Filter by text {{{ const searchInput = document.querySelector('#searchInput') searchInput.value = '' // get only text from inline children function inlineText (el) { let result = '' for (const child of el.childNodes) { if (child.nodeType === Node.TEXT_NODE) { result += child.textContent } else if (child.nodeType === Node.ELEMENT_NODE) { const style = window.getComputedStyle(child) if (child.tagName === 'SUMMARY' || style.display === 'inline' || style.display === 'inline-block') { result += inlineText(child) } } } return result } function search (ele, text) { ele.style.display = 'none' // TODO consider elements other than