From 4bd54f096ddecacaacb061e74eb4766bc9152848 Mon Sep 17 00:00:00 2001 From: glax Date: Tue, 23 May 2023 18:28:27 +0200 Subject: [PATCH] WIP Better Task-Adder --- Website/index.html | 1 + Website/interaction.js | 29 +++++++++++++++++++---------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/Website/index.html b/Website/index.html index 62e8ea6..ff20bb1 100644 --- a/Website/index.html +++ b/Website/index.html @@ -68,6 +68,7 @@ Pandemic love comedy! Delete Task ❌ + Add Task ➕ diff --git a/Website/interaction.js b/Website/interaction.js index 6735175..1e21e3c 100644 --- a/Website/interaction.js +++ b/Website/interaction.js @@ -20,7 +20,7 @@ const slideOutRightTiming = { let publications = []; let tasks = []; -let toRemoveId; +let toEditId; const taskTypesSelect = document.querySelector("#taskTypes") const searchPublicationQuery = document.querySelector("#searchPublicationQuery"); @@ -38,12 +38,14 @@ const publicationViewerName = document.querySelector("#publicationViewerName"); const publicationViewerAuthor = document.querySelector("#publicationViewerAuthor"); const pubviewcover = document.querySelector("#pubviewcover"); const publicationDelete = document.querySelector("publication-delete"); +const publicationAdd = document.querySelector("publication-add"); const closetaskpopup = document.querySelector("#closePopupImg"); settingsCog.addEventListener("click", () => slide()); closetaskpopup.addEventListener("click", () => HidePopup()); document.querySelector("blur-background").addEventListener("click", () => HidePopup()); publicationDelete.addEventListener("click", () => DeleteTaskClick()); +publicationAdd.addEventListener("click", () => CreateTask("DownloadNewChapters", selectRecurrence.value, connectorSelect.value, toEditId, "en")); /* let availableTaskTypes; @@ -79,9 +81,7 @@ searchPublicationQuery.addEventListener("keypress", (event) => { json.forEach(publication => { var option = CreatePublication(publication, connectorSelect.value); option.addEventListener("click", () => { - CreateTask("DownloadNewChapters", selectRecurrence.value, connectorSelect.value, publication.internalId, "en"); - HidePopup(); - selectPublication.replaceChildren(); + ShowPublicationViewerWindow(publication.internalId, event, true); }); selectPublication.appendChild(option); } @@ -110,8 +110,8 @@ function CreatePublication(publication, connector){ } function DeleteTaskClick(){ - taskToDelete = tasks.filter(tTask => tTask.publication.internalId === toRemoveId)[0]; - DeleteTask("DownloadNewChapters", taskToDelete.connectorName, toRemoveId); + taskToDelete = tasks.filter(tTask => tTask.publication.internalId === toEditId)[0]; + DeleteTask("DownloadNewChapters", taskToDelete.connectorName, toEditId); HidePopup(); } @@ -140,7 +140,7 @@ function ShowPopup(){ generalPopup.animate(fadeIn, fadeInTiming); } -function ShowPublicationViewerWindow(publicationId, event){ +function ShowPublicationViewerWindow(publicationId, event, add){ publicationViewer.style.top = `${event.clientY - 60}px`; publicationViewer.style.left = `${event.clientX}px`; var publication = publications.filter(pub => pub.internalId === publicationId)[0]; @@ -149,9 +149,18 @@ function ShowPublicationViewerWindow(publicationId, event){ publicationViewerDescription.innerText = publication.description; publicationViewerAuthor.innerText = publication.author; pubviewcover.src = publication.posterUrl; - toRemoveId = publicationId; + toEditId = publicationId; - toRemoveId = publicationId; + if(add){ + publicationAdd.style.display = "none"; + publicationDelete.style.display = "block"; + } + else{ + publicationAdd.style.display = "block"; + publicationDelete.style.display = "none"; + } + + toEditId = publicationId; publicationViewer.style.display = "block"; ShowPopup(); } @@ -198,7 +207,7 @@ setInterval(() => { ResetContent(); cTasks.forEach(task => { var publication = CreatePublication(task.publication, task.connectorName); - publication.addEventListener("click", (event) => ShowPublicationViewerWindow(task.publication.internalId, event)); + publication.addEventListener("click", (event) => ShowPublicationViewerWindow(task.publication.internalId, event, true)); tasksContent.appendChild(publication); })