TheBin/views/paste.ejs

58 lines
2.3 KiB
Plaintext

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="../style.css">
<title>Paste #<%= id %></title>
<script>
function alert(text) {
var alert = document.createElement("div");
alert.className = "alert";
alert.innerHTML = text;
document.body.appendChild(alert);
setTimeout(function() {
document.body.removeChild(alert);
}, 3000);
}
function copyPaste() {
/* Get the text field */
var copyText = document.getElementById("editor");
/* Select the text field */
copyText.select();
copyText.setSelectionRange(0, 99999); /* For mobile devices */
/* Copy the text inside the text field */
navigator.clipboard.writeText(copyText.value);
alert("Copied text to clipboard!");
}
function copyLink() {
/* Get the text field */
var copyText = window.location.href;
/* Copy the text inside the text field */
navigator.clipboard.writeText(copyText);
alert("Copied link to clipboard!");
}
function goToHome() {
window.location.href = "/";
}
</script>
</head>
<body style="overflow-y:hidden">
<div class="editor-box">
<div class="editor-header">
<div class="button-custom-box"><button type="button" class="button-custom" onclick="copyPaste()" id="save-button">Copy</button></div>
<div class="button-custom-box"><button type="button" class="button-custom" onclick="goToHome()" id="save-button">Home</button></div>
<div class="button-custom-box"><button type="button" class="button-custom" onclick="copyLink()" id="save-button">Copy Link</button></div>
<div class="name-box"><input placeholder="<Empty>" value="<%= name %>" readonly></input></div>
</div>
<div class="editor">
<textarea id="editor" spellcheck="false" autofocus="true" autocomplete="false" readonly><%= text %></textarea>
</div>
</div>
</body>
</html>