From 38c0f90285f94250dc510eb93e4b442a69029ee1 Mon Sep 17 00:00:00 2001 From: maaa Date: Sat, 19 Aug 2023 19:20:37 +0200 Subject: [PATCH] burger --- APIDOCS.md | 6 +++++- static/js/main.js | 11 ++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/APIDOCS.md b/APIDOCS.md index ffe0975..a355708 100644 --- a/APIDOCS.md +++ b/APIDOCS.md @@ -60,4 +60,8 @@ POST - /api/deleteaccount - delete account, provide "secretKey" please display a warning before this action POST - /api/exportnotes - export notes, provide "secretKey" -note content and title will have to be decrypted \ No newline at end of file +note content and title will have to be decrypted + +POST - /api/sessions/list - show all sessions, provide "secretKey" + +POST - /api/sessions/remove - remove session, provide "secretKey" and "sessionId" \ No newline at end of file diff --git a/static/js/main.js b/static/js/main.js index 19ecb87..3155ed2 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -9,6 +9,10 @@ if (localStorage.getItem("DONOTSHARE-password") === null) { throw new Error(); } +if (localStorage.getItem("CACHE-username") !== null) { + document.getElementById("usernameBox").innerText = localStorage.getItem("CACHE-username") +} + function formatBytes(a, b = 2) { if (!+a) return "0 Bytes"; const c = 0 > b ? 0 : b, d = Math.floor(Math.log(a) / Math.log(1000)); return `${parseFloat((a / Math.pow(1000, d)).toFixed(c))} ${["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"][d]}` } function truncateString(str, num) { @@ -182,7 +186,7 @@ function updateUserInfo() { displayError("Something went wrong. Signing you out..") closeErrorButton.classList.add("hidden") usernameBox.innerText = "" - setTimeout(function() { + setTimeout(function () { window.location.replace("/api/logout") }, 2500); } else { @@ -193,6 +197,7 @@ function updateUserInfo() { storageProgressThing.value = responseData["storageused"] storageProgressThing.max = responseData["storagemax"] noteCount = responseData["notecount"] + localStorage.setItem("CACHE-username", responseData["username"]) } } doStuff() @@ -256,9 +261,9 @@ sessionManagerButton.addEventListener("click", (event) => { let sessionRemoveButton = document.createElement("button") sessionText.classList.add("w300") if (responseData[i]["thisSession"] == true) { - sessionText.innerHTML = "current" + truncateString(responseData[i]["device"], 18) + sessionText.innerText = "(current) " + truncateString(responseData[i]["device"], 18) } else { - sessionText.innerHTML = truncateString(responseData[i]["device"], 27) + sessionText.innerText = truncateString(responseData[i]["device"], 27) } sessionText.title = responseData[i]["device"] sessionRemoveButton.innerText = "X"