mirror of
https://github.com/v1k45/pastepass.git
synced 2026-01-05 04:56:16 +00:00
44 lines
1.5 KiB
Plaintext
44 lines
1.5 KiB
Plaintext
package views
|
|
|
|
templ View() {
|
|
@base() {
|
|
<div style="padding-bottom: 5rem;">
|
|
<hgroup>
|
|
<h3>View Paste</h3>
|
|
<p>
|
|
<small style="color: #8891A4;">
|
|
You can only view this paste once. Make sure to copy it before you close this page.
|
|
</small>
|
|
</p>
|
|
</hgroup>
|
|
<form method="post" onsubmit="showPaste(event)">
|
|
<button type="submit" style="width: auto;">Show Paste</button>
|
|
</form>
|
|
<script>
|
|
// submit a post request and replace the current page with the response
|
|
// this is to prevent user from resubmitting the form when they refresh the page
|
|
function showPaste(event) {
|
|
event.preventDefault();
|
|
|
|
// show loading
|
|
event.target.querySelector('button').setAttribute('aria-busy', 'true');
|
|
|
|
fetch(window.location.href, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
},
|
|
body: 'submit=true',
|
|
}).then(function(response) {
|
|
return response.text();
|
|
}).then(function(body) {
|
|
document.open();
|
|
document.write(body);
|
|
document.close();
|
|
});
|
|
}
|
|
</script>
|
|
</div>
|
|
}
|
|
}
|