forked from joshbuchea/HEAD
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdefault.html
More file actions
67 lines (62 loc) · 2.16 KB
/
Copy pathdefault.html
File metadata and controls
67 lines (62 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
---
<!doctype html>
<html lang="en">
{% include head.html %}
<body>
{% include announcement.html %}
{% include header.html %}
<div class="site__main">
<div class="container">
{{ content }}
</div>
</div>
<script>
// open external links in new tab
var links = document.links;
var linksLength = links.length;
var i;
for (i = 0; i < linksLength; i++) {
if (links[i].hostname != window.location.hostname) {
links[i].rel = 'noopener noreferrer';
links[i].target = '_blank';
}
}
</script>
<script>
// copy to clipboard button on code blocks
var statusRegion = document.createElement('div');
statusRegion.className = 'visually-hidden';
statusRegion.setAttribute('aria-live', 'polite');
statusRegion.setAttribute('role', 'status');
document.body.appendChild(statusRegion);
var preBlocks = document.querySelectorAll('pre');
var preBlocksLength = preBlocks.length;
var j;
for (j = 0; j < preBlocksLength; j++) {
(function (pre) {
if (!navigator.clipboard || typeof navigator.clipboard.writeText !== 'function') return;
var button = document.createElement('button');
button.className = 'copy-btn';
button.type = 'button';
button.textContent = 'Copy';
button.addEventListener('click', function () {
var code = pre.querySelector('code');
var text = code ? code.innerText : pre.innerText;
navigator.clipboard.writeText(text).then(function () {
button.textContent = 'Copied';
statusRegion.textContent = 'Copied to clipboard';
setTimeout(function () { button.textContent = 'Copy'; }, 1500);
}).catch(function () {
button.textContent = 'Failed';
statusRegion.textContent = 'Copy to clipboard failed';
setTimeout(function () { button.textContent = 'Copy'; }, 1500);
});
});
pre.appendChild(button);
})(preBlocks[j]);
}
</script>
{% include analytics.html %}
</body>
</html>