diff --git a/main b/main index d651120..b3da86f 100644 --- a/main +++ b/main @@ -309,6 +309,28 @@ def apiremovenote(): return {}, 422 +@app.route("/api/deleteaccount", methods=("GET", "POST")) +def apideleteaccount(): + if request.method == "POST": + data = request.get_json() + secretKey = data["secretKey"] + + userCookie = get_session(secretKey) + user = get_user(userCookie["id"]) + + conn = get_db_connection() + conn.execute("DELETE FROM notes WHERE creator = ?", (userCookie["id"],)) + conn.commit() + conn.close() + + conn = get_db_connection() + conn.execute("DELETE FROM users WHERE id = ?", (userCookie["id"],)) + conn.commit() + conn.close() + + return {}, 200 + + @app.route("/listusers/", methods=("GET", "POST")) def listusers(secretkey): if secretkey == SECRET_KEY: diff --git a/static/css/style.css b/static/css/style.css index ae02aaf..1f08b4a 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -97,10 +97,11 @@ body { position: fixed; right: 0; bottom: 0; + padding: 4px; border: none; font-size: 16px; - width: calc(100% - 180px - 7px); - height: calc(100% - 50px - 6px); + width: calc(100% - 180px - 7px - 6px); + height: calc(100% - 50px - 6px - 8px); font-family: "Inter", sans-serif; } @@ -137,9 +138,23 @@ body { border-radius: 8px; } +.optionsDiv progress { + width: 100%; + background-color: #d8d8d8; + border: none; + border-radius: 99px; + height: 7px; +} +.optionsDiv progress::-moz-progress-bar { + background: #157efb; +} +.optionsDiv progresss::-webkit-progress-value { + background: #157efb; +} + .optionsDiv .exit { position: absolute; - right: 10px; + right: 5px; width: 40px; height: 40px; font-size: 16px; @@ -225,7 +240,7 @@ body { box-shadow: 0px 8px 16px 0px rgba(0, 0, 0, 0.2); } -/* dark theme from my ass */ +/* dark theme, slightly modified */ @media (prefers-color-scheme: dark) { :root { @@ -244,32 +259,24 @@ body { body { color: white; - background-color: var(--gray-900); + background-color: #030303; } .topBar { - background-color: var(--gray-800); - backdrop-filter: blur(0px); - -webkit-backdrop-filter: blur(20px); - border: none; - border-color: transparent; - border-width: 0px; - border-bottom-width: 0px; + background-color: rgba(18, 18, 18, 0.5); + border-color: #303030; } .notesBar { - background-color: var(--gray-800); - backdrop-filter: none; - -webkit-backdrop-filter: none; - border: none; - border-color: #dadada00; - border-width: 0px; - border-top-width: 0px; - border-right-width: 0px; + background-color: #030303; + border: solid; + border-width: 0px; + border-right-width: 1px; + border-color: #303030; } .noteBox { - background-color: var(--gray-900); + background-color: #030303; color: white; } @@ -282,8 +289,8 @@ body { } .notesBar button { - background-color: var(--gray-700); - border-color: var(--gray-600); + background-color: #141414; + border: none; } .notesBar .selected { @@ -297,18 +304,15 @@ body { } .optionsDiv .exit { - background-color: crimson; + background-color: var(--gray-700); color: white; } - .mainDiv .green { - background-color: var(--gray-800); - border: 1px solid #00b100; - } - - .mainDiv .yellow { - background-color: var(--gray-800); - border: 1px solid #FFD700; + .mainDiv .feature { + background-color: #141414; + border: solid; + border-width: 1px; + border-color: #303030; } .inoutdiv { diff --git a/static/js/login.js b/static/js/login.js index 02557e5..4fd9862 100644 --- a/static/js/login.js +++ b/static/js/login.js @@ -1,9 +1,11 @@ if (localStorage.getItem("DONOTSHARE-secretkey") !== null) { window.location.replace("/app") + document.body.innerHTML = "Redirecting.." throw new Error(); } if (localStorage.getItem("DONOTSHARE-password") !== null) { window.location.replace("/app") + document.body.innerHTML = "Redirecting.." throw new Error(); } diff --git a/static/js/main.js b/static/js/main.js index f230659..bdb5b3f 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -1,13 +1,15 @@ if (localStorage.getItem("DONOTSHARE-secretkey") === null) { window.location.replace("/") + document.body.innerHTML = "Redirecting.." throw new Error(); } if (localStorage.getItem("DONOTSHARE-password") === null) { window.location.replace("/") + document.body.innerHTML = "Redirecting.." throw new Error(); } -function formatBytes(a, b = 2) { if (!+a) return "0 Bytes"; const c = 0 > b ? 0 : b, d = Math.floor(Math.log(a) / Math.log(1024)); return `${parseFloat((a / Math.pow(1024, d)).toFixed(c))} ${["Bytes", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"][d]}` } +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]}` } let secretkey = localStorage.getItem("DONOTSHARE-secretkey") let password = localStorage.getItem("DONOTSHARE-password") @@ -15,7 +17,9 @@ let password = localStorage.getItem("DONOTSHARE-password") let usernameBox = document.getElementById("usernameBox") let optionsCoverDiv = document.getElementById("optionsCoverDiv") let exitThing = document.getElementById("exitThing") +let deleteMyAccountButton = document.getElementById("deleteMyAccountButton") let storageThing = document.getElementById("storageThing") +let storageProgressThing = document.getElementById("storageProgressThing") let usernameThing = document.getElementById("usernameThing") let logOutButton = document.getElementById("logOutButton") let notesBar = document.getElementById("notesBar") @@ -77,34 +81,62 @@ if (/Android|iPhone/i.test(navigator.userAgent)) { noteBox.value = "" noteBox.readOnly = true -fetch("/api/userinfo", { - method: "POST", - body: JSON.stringify({ - secretKey: secretkey - }), - headers: { - "Content-type": "application/json; charset=UTF-8" - } -}) - .then((response) => response) - .then((response) => { - async function doStuff() { - let responseData = await response.json() - usernameBox.innerText = responseData["username"] - usernameBox.addEventListener("click", (event) => { - optionsCoverDiv.classList.remove("hidden") +function updateUserInfo() { + fetch("/api/userinfo", { + method: "POST", + body: JSON.stringify({ + secretKey: secretkey + }), + headers: { + "Content-type": "application/json; charset=UTF-8" + } + }) + .then((response) => response) + .then((response) => { + async function doStuff() { + let responseData = await response.json() + usernameBox.innerText = responseData["username"] usernameThing.innerText = "logged in as " + responseData["username"] storageThing.innerText = "you've used " + formatBytes(responseData["storageused"]) + " out of " + formatBytes(responseData["storagemax"]) - }); - logOutButton.addEventListener("click", (event) => { + storageProgressThing.value = responseData["storageused"] + storageProgressThing.max = responseData["storagemax"] + } + doStuff() + }); +} +usernameBox.addEventListener("click", (event) => { + optionsCoverDiv.classList.remove("hidden") + updateUserInfo() +}); +logOutButton.addEventListener("click", (event) => { + window.location.href = "/api/logout" +}); +exitThing.addEventListener("click", (event) => { + optionsCoverDiv.classList.add("hidden") +}); +deleteMyAccountButton.addEventListener("click", (event) => { + if (confirm("are you REALLY sure that you want to delete your account? there's no going back.") == true) { + fetch("/api/deleteaccount", { + method: "POST", + body: JSON.stringify({ + secretKey: secretkey + }), + headers: { + "Content-type": "application/json; charset=UTF-8" + } + }) + .then((response) => response) + .then((response) => { + if (response.status == 200) { window.location.href = "/api/logout" - }); - exitThing.addEventListener("click", (event) => { - optionsCoverDiv.classList.add("hidden") - }); - } - doStuff() - }); + } else { + alert("failed to delete account (" + String(response.status) + ")") + } + }) + } +}); + +updateUserInfo() function selectNote(nameithink) { document.querySelectorAll(".noteButton").forEach((el) => el.classList.remove("selected")); diff --git a/static/js/signup.js b/static/js/signup.js index 90c882b..7bbcab5 100644 --- a/static/js/signup.js +++ b/static/js/signup.js @@ -1,9 +1,11 @@ if (localStorage.getItem("DONOTSHARE-secretkey") !== null) { window.location.replace("/app") + document.body.innerHTML = "Redirecting.." throw new Error(); } if (localStorage.getItem("DONOTSHARE-password") !== null) { window.location.replace("/app") + document.body.innerHTML = "Redirecting.." throw new Error(); } diff --git a/static/mainimg.png b/static/mainimg.png new file mode 100644 index 0000000..c576833 Binary files /dev/null and b/static/mainimg.png differ diff --git a/templates/app.html b/templates/app.html index d347639..6d42dd8 100644 --- a/templates/app.html +++ b/templates/app.html @@ -29,9 +29,10 @@

manage your account

+

- + diff --git a/templates/main.html b/templates/main.html index 9d19865..318f3db 100644 --- a/templates/main.html +++ b/templates/main.html @@ -13,19 +13,22 @@

burgernotes

-

minimal note taking app

+

simple note taking app


sign up log in


+ + +

secure

all your notes are fully end-to-end encrypted. only you can read your notes, not anyone else.

always up-to-date

-

your notes automatically sync across your devices.

+

your notes seamlessly sync across your devices.