mirror of
https://github.com/gigirassy/plaster.git
synced 2024-12-23 10:29:07 +00:00
Update client.js
This commit is contained in:
parent
71fc7aab22
commit
0328c8fb4b
@ -23,11 +23,12 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Redirect to raw paste page
|
const frontendUrl = `/${pasteId}`;
|
||||||
const rawPasteUrl = `/${pasteId}`;
|
|
||||||
|
// If auto-copy is enabled, fetch and copy the paste contents
|
||||||
if (autoCopyCheckbox.checked) {
|
if (autoCopyCheckbox.checked) {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(rawPasteUrl);
|
const response = await fetch(frontendUrl);
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
const pasteContents = await response.text();
|
const pasteContents = await response.text();
|
||||||
await navigator.clipboard.writeText(pasteContents);
|
await navigator.clipboard.writeText(pasteContents);
|
||||||
@ -39,7 +40,9 @@ document.addEventListener('DOMContentLoaded', async () => {
|
|||||||
alert('Error copying to clipboard: ' + error.message);
|
alert('Error copying to clipboard: ' + error.message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.location.href = `/${pasteId}`
|
|
||||||
|
// Redirect to the frontend paste URL
|
||||||
|
window.location.href = frontendUrl;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -73,3 +76,4 @@ function setCookie(name, value, days) {
|
|||||||
function getCookie(name) {
|
function getCookie(name) {
|
||||||
const match = document.cookie.match(new RegExp(`(?:^|; )${name}=([^;]*)`));
|
const match = document.cookie.match(new RegExp(`(?:^|; )${name}=([^;]*)`));
|
||||||
return match ? decodeURIComponent(match[1]) : null;
|
return match ? decodeURIComponent(match[1]) : null;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user