From b2e840944fc96ef361cb009ef14aaeeeca391cb7 Mon Sep 17 00:00:00 2001 From: ProgrammerIn-wonderland <3838shah@gmail.com> Date: Tue, 19 Dec 2023 22:10:16 -0500 Subject: [PATCH] add input validation to workstore and fix up koaku's fuckups --- apps/workstore.app/index.js | 5 ----- apps/workstore.app/repoManager.js | 29 ++++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/apps/workstore.app/index.js b/apps/workstore.app/index.js index dcc604b2..5466d8ca 100644 --- a/apps/workstore.app/index.js +++ b/apps/workstore.app/index.js @@ -8,11 +8,6 @@ const repoScreen = document.getElementById('repoScreen'); const appListScreen = document.getElementById('appListScreen') const appInstallerScreen = document.getElementById('appInstallerScreen'); -parent.document.body.querySelector(".title").style["background-color"] = "#222"; -parent.document.body.querySelector(".title").style["background-image"] = "radial-gradient(#666 1px, transparent 0)"; -parent.document.body.querySelector(".title").style["background-size"] = "20px 20px"; -parent.document.body.querySelector(".title").style["background-position"] = "-19px -19px"; - // background-image: radial-gradient(#666 1px, transparent 0); // background-size: 20px 20px; diff --git a/apps/workstore.app/repoManager.js b/apps/workstore.app/repoManager.js index ac1406c1..d4002c9b 100644 --- a/apps/workstore.app/repoManager.js +++ b/apps/workstore.app/repoManager.js @@ -7,6 +7,21 @@ async function loadMainScreen() { for (repo in repos) { const repoItem = document.createElement('div') repoItem.innerText = repo + repoItem.oncontextmenu = (e) => { + const newcontextmenu = new anura.ContextMenu(); + newcontextmenu.addItem("Delete Repo", async function() { + delete repos[repoItem.innerText]; + await anura.settings.set('workstore-repos', repos) + location.reload() + }); + newcontextmenu.show(e.clientX, e.clientY) + document.onclick = (e) => { + document.onclick = null; + newcontextmenu.hide(); + e.preventDefault(); + } + e.preventDefault() + } repoItem.onclick = function() { loadappListScreen(repoItem.innerText) // Weird hack to work around the fact that repo doesn't work but the innertext of the repoitem does } @@ -23,10 +38,22 @@ async function loadMainScreen() { newRepoButton.type = 'submit' newRepoButton.value = 'add repo' newRepoButton.onclick = function() { + if (!newRepoName.value.endsWith("/")) { + anura.notifications.add({ + title: "Workstore", + description: "URL does not end with a \"/\" character", + timeout: 5000, + }); + return; + } const repoItem = document.createElement('div') repoItem.innerText = newRepoName.value if (repos[newRepoName.value]) { - // send anura notification that repo already exists + anura.notifications.add({ + title: "Workstore", + description: "Repo is already added", + timeout: 5000, + }); return; } repos[newRepoName.value] = newRepoURL.value;