From 2f698b192249d6a77a6ac64a8a0d3636d4c624e6 Mon Sep 17 00:00:00 2001 From: maaa Date: Mon, 11 Mar 2024 21:45:22 +0100 Subject: [PATCH] meow --- APIDOCS.md | 2 +- static/js/main.js | 30 ++++++++++++------------------ 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/APIDOCS.md b/APIDOCS.md index 1d38020..e6a2da3 100644 --- a/APIDOCS.md +++ b/APIDOCS.md @@ -67,7 +67,7 @@ note content will have to be decrypted. POST - /api/editnote - edit notes, provide "secretKey", "noteId", "title", and "content" "content" should be encrypted. -"title" is the first line of the note content, and should be encrypted. the title should be truncated if it's above 16 characters, meaning "sillyburgermuncher" -> "sillyburgermunch.." +"title" is the first line of the note content, and should be encrypted. **(Deprecated ⚠️)** POST - /api/editnotetitle - edit note titles, provide "secretKey", "noteId", and "content" "content" should be encrypted. diff --git a/static/js/main.js b/static/js/main.js index 44795cc..0269445 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -198,6 +198,15 @@ textMinusBox.addEventListener("click", (event) => { }); +function truncateString(str, num) { + if (str.length > num) { + return str.slice(0, num) + ".."; + } else { + return str; + } +} + + function updateUserInfo() { fetch(remote + "/api/userinfo", { method: "POST", @@ -259,7 +268,6 @@ deleteMyAccountButton.addEventListener("click", (event) => { "Content-Type": "application/json; charset=UTF-8" } }) - .then((response) => response) .then((response) => { if (response.status == 200) { window.location.href = "../logout/index.html" @@ -282,7 +290,6 @@ sessionManagerButton.addEventListener("click", (event) => { "Content-Type": "application/json; charset=UTF-8" } }) - .then((response) => response) .then((response) => { async function doStuff() { let responseData = await response.json() @@ -294,9 +301,9 @@ sessionManagerButton.addEventListener("click", (event) => { let sessionRemoveButton = document.createElement("button") sessionText.classList.add("w300") if (responseData[i]["thisSession"] == true) { - sessionText.innerText = "(current) " + truncateString(responseData[i]["device"], 18) + sessionText.innerText = "(current) " + responseData[i]["device"] } else { - sessionText.innerText = truncateString(responseData[i]["device"], 27) + sessionText.innerText = responseData[i]["device"] } sessionText.title = responseData[i]["device"] sessionRemoveButton.innerText = "x" @@ -323,7 +330,6 @@ sessionManagerButton.addEventListener("click", (event) => { "Content-Type": "application/json; charset=UTF-8" } }) - .then((response) => response) .then((response) => { if (responseData[i]["thisSession"] == true) { window.location.replace("../logout/index.html") @@ -359,14 +365,6 @@ function updateWordCount() { wordCountBox.innerText = wordCount + " words" } -function truncateString(str, num) { - if (str.length > num) { - return str.slice(0, num) + ".."; - } else { - return str; - } -} - function selectNote(nameithink) { document.querySelectorAll(".noteButton").forEach((el) => el.classList.remove("selected")); let thingArray = Array.from(document.querySelectorAll(".noteButton")).find(el => el.id == nameithink); @@ -388,7 +386,6 @@ function selectNote(nameithink) { noteBox.placeholder = "" displayError("Something went wrong... Please try again later!") }) - .then((response) => response) .then((response) => { selectedNote = nameithink noteBox.readOnly = false @@ -429,7 +426,6 @@ function selectNote(nameithink) { "Content-Type": "application/json; charset=UTF-8" } }) - .then((response) => response) .then((response) => { if (response.status == 418) { displayError("You've ran out of storage... Changes will not be saved until you free up storage!") @@ -476,7 +472,7 @@ function updateNotes() { let originalTitle = bytes.toString(CryptoJS.enc.Utf8); noteButton.id = responseData[i]["id"] - noteButton.innerText = originalTitle + noteButton.innerText = truncateString(originalTitle, 15) noteButton.addEventListener("click", (event) => { if (event.ctrlKey) { @@ -555,7 +551,6 @@ function exportNotes() { "Content-Type": "application/json; charset=UTF-8" } }) - .then((response) => response) .then((response) => { async function doStuff() { let responseData = await response.json() @@ -615,7 +610,6 @@ removeBox.addEventListener("click", (event) => { "Content-Type": "application/json; charset=UTF-8" } }) - .then((response) => response) .then((response) => { updateNotes() })