Add js to copy git commit hash

Julien LepillerSun Mar 07 15:40:40+0100 2021

cca4eb8

Add js to copy git commit hash

assets/js/gitile.js unknown status 1

1+
window.onload = function() {
2+
  buttons = document.getElementsByClassName('copy')
3+
4+
  function mycopy(button) {
5+
    alert(button)
6+
    data = button.dataset.clipboardCopy
7+
    while(data == undefined) {
8+
          button = button.parentElement
9+
          data = button.dataset.clipboardCopy
10+
    }
11+
    alert(data)
12+
    i = document.createElement('input')
13+
    i.type = 'text'
14+
    i.value = data
15+
    i.display = 'none'
16+
    button.appendChild(i)
17+
    i.select()
18+
    i.setSelectionRange(0, 99999); /* For mobile devices */
19+
    document.execCommand("copy")
20+
    button.removeChild(i)
21+
  }
22+
23+
24+
  for(i=0;i<buttons.length;i++) {
25+
    buttons[i].addEventListener('click', function(e) {
26+
      mycopy(e.target)
27+
    })
28+
  }
29+
}

gitile/handler.scm

4444
       (meta (@ (name "viewport") (content "width=device-width, initial-scale=1")))
4545
       (link (@ (rel "stylesheet") (href "/css/gitile.css")))
4646
       (link (@ (rel "icon") (href "/images/icon.png") (sizes "32x32")))
47+
       (script (@ (href "/js/gitile.css")))
4748
       (title ,project))
4849
     (body
4950
       (header