mirror of
https://github.com/whoswhip/Sharpbin.git
synced 2026-12-06 02:48:43 +00:00
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:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user