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
44 | 44 | (meta (@ (name "viewport") (content "width=device-width, initial-scale=1"))) | |
45 | 45 | (link (@ (rel "stylesheet") (href "/css/gitile.css"))) | |
46 | 46 | (link (@ (rel "icon") (href "/images/icon.png") (sizes "32x32"))) | |
47 | + | (script (@ (href "/js/gitile.css"))) | |
47 | 48 | (title ,project)) | |
48 | 49 | (body | |
49 | 50 | (header |