From 78af91e971da8b0518a333c88b76c896c477a158 Mon Sep 17 00:00:00 2001 From: Liam Date: Sun, 2 Jun 2024 14:24:05 +0100 Subject: [PATCH] use a toast instead of alerting --- src/main/resources/static/assets/script.js | 14 ++++++++++++-- src/main/resources/templates/index.html | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/resources/static/assets/script.js b/src/main/resources/static/assets/script.js index e0d3d02..6ec7976 100644 --- a/src/main/resources/static/assets/script.js +++ b/src/main/resources/static/assets/script.js @@ -17,7 +17,7 @@ const upload = async () => { if (!paste || paste.trim() === "") { pasteInput.focus(); - alert("Your paste is empty!"); + toast("Please enter a paste to upload."); return; } @@ -35,6 +35,16 @@ const upload = async () => { window.location.href = "/" + data.id; } catch (error) { console.error("Error:", error); - alert(`${error.message || "An error occurred while uploading the paste."}`); + toast(`${error.message || "An error occurred while uploading the paste."}`); } }; + +const toast = (message, duration = 3000) => { + Toastify({ + text: message, + duration: duration, + close: true, + gravity: "bottom", + position: "right", + }).showToast(); +}; diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 540532a..2529996 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -9,6 +9,10 @@ + + + +