PageSourceSearch

https://esquisses.netlify.app/js/code-copy.js

js esquisses.netlify.app collected 2026-10-03 10:42:34 UTC 926 bytes, 36 lines download raw bytes

1(() => {
2
3  function createCopyButton(codeNode) {
4    const copyBtn = document.createElement('button')
5    copyBtn.className = 'code-copy-btn'
6    copyBtn.type = 'button'
7    copyBtn.innerText = 'copy'
8
9    let resetTimer
10    copyBtn.addEventListener('click', () => {
11      navigator.clipboard.writeText(codeNode.innerText).then(() => {
12        copyBtn.innerText = 'copied!'
13      }).then(() => {
14        clearTimeout(resetTimer)
15        resetTimer = setTimeout(() => {
16          copyBtn.innerText = 'copy'
17        }, 1000)
18      })
19    })
20
21    return copyBtn
22  }
23
24  document.querySelectorAll('pre > code')
25  .forEach((codeNode) => {
26    const copyBtn = createCopyButton(codeNode);
27    const preNode = codeNode.parentNode
28    codeNode.parentNode.insertBefore(copyBtn, codeNode)
29  })
30
31  document.querySelectorAll('.highlight table > tbody > tr > td:first-child .code-copy-btn')
32  .forEach((btn) => {
33    btn.remove()
34  })
35
36})()

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.