Split code into classes to make the codebase look cleaner

Added a new favicon/icon
Add more checks before uploading a paste, changed alert to use the showNotification function
Added password modal for private pastes instead of using alert
Fix a paste page navigation in dashboard
Improve auth css
This commit is contained in:
whoswhip
2025-05-23 18:54:29 -04:00
parent 2126c3a078
commit 73743399f1
17 changed files with 1027 additions and 491 deletions
+23 -1
View File
@@ -1,6 +1,9 @@
const siteInfo = [];
document.addEventListener("DOMContentLoaded", async function () {
var visibility = document.getElementById("visibility");
visibility.value = "0";
getSiteInfo();
});
@@ -13,11 +16,20 @@ document.getElementById("create-form").addEventListener("submit", async function
var password = document.getElementById("password").value;
var syntax = document.getElementById("syntax").value;
if (content.length > siteInfo.maxFileSize) {
showNotification("Content exceeds maximum size.", "error");
return;
}
if (content.length === 0) {
showNotification("Content cannot be empty.", "error");
return;
}
if (visibility === "2" && password !== "" && password.length >= 6) {
content = await encryptAES(content, password);
}
else if (visibility === "2") {
alert("Password must be at least 6 characters long");
showNotification("Password must be at least 6 characters long.", "error");
return;
}
@@ -42,6 +54,16 @@ function changeVisibility() {
}
}
function getSiteInfo() {
fetch("/api/site/info")
.then(response => response.json())
.then(data => {
siteInfo = data.info;
var content = document.getElementById("content")
content.setAttribute("maxlength", siteInfo.maxFileSize);
});
}
async function encryptAES(content, password) {
const enc = new TextEncoder();
const keyMaterial = await window.crypto.subtle.importKey(