-
Notifications
You must be signed in to change notification settings - Fork 0
/
paste.hbs
40 lines (39 loc) · 1.5 KB
/
paste.hbs
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0;">
<title>Pastebin</title>
<link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="/highlight.min.css">
<script src="/highlight.min.js"></script>
<script>hljs.highlightAll();</script>
</head>
<body>
<a href="/"><h2 id="name"></h2></a>
<pre><code class="hljs">{{c}}</code></pre>
<a href="{{r}}"><button name="raw">RAW</button></a>
<button name="copy" onclick="copyToClipboard()">Copy</button>
<button name="share" onclick="shareURL()">Share</button>
<p name="paste-info">{{{d}}}</p>
<script>
document.getElementById("name").innerHTML = window.location.hostname;
function copyToClipboard() {
navigator.clipboard.writeText(document.getElementsByClassName("hljs")[0].innerText)
let copyButton = document.getElementsByName("copy")[0];
copyButton.innerHTML = "Copied!";
setTimeout(() => {
copyButton.innerHTML = "Copy";
}, 700)
}
function shareURL() {
try {
navigator.share({"url": window.location.href})
} catch {
navigator.clipboard.writeText(window.location.href)
alert("Your browser does not support sharing. So the link copied to your clipboard.")
}
}
</script>
</body>
</html>