Add -> add project
This commit is contained in:
38
public/assets/js/app.js
Normal file
38
public/assets/js/app.js
Normal file
@@ -0,0 +1,38 @@
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
|
||||
const form = document.getElementById("pasteForm");
|
||||
const resultBox = document.getElementById("result");
|
||||
|
||||
form.addEventListener("submit", async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const formData = new FormData(form);
|
||||
|
||||
const response = await fetch("/index.php?action=save", {
|
||||
method: "POST",
|
||||
body: formData
|
||||
});
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (!data.success) {
|
||||
resultBox.innerHTML = "<div class='error'>" + data.message + "</div>";
|
||||
return;
|
||||
}
|
||||
|
||||
resultBox.innerHTML = `
|
||||
<h3>Paste Created</h3>
|
||||
|
||||
<input type="text" id="pasteLink" value="${data.url}" readonly style="width:100%; padding:8px;">
|
||||
|
||||
<button id="copyBtn">Copy Link</button>
|
||||
`;
|
||||
|
||||
document.getElementById("copyBtn").addEventListener("click", () => {
|
||||
const input = document.getElementById("pasteLink");
|
||||
navigator.clipboard.writeText(input.value);
|
||||
alert("Link copied!");
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user