From 56410e2b60ad4cad82a90974d413e11659cb119b Mon Sep 17 00:00:00 2001 From: Kethan Vegunta Date: Tue, 2 Mar 2021 12:17:11 -0800 Subject: [PATCH] add ability to edit tasks --- src/index.css | 3 + src/index.html | 211 +++++++++++++++++++++++++++++-------------------- src/index.js | 3 +- src/render.js | 10 ++- 4 files changed, 135 insertions(+), 92 deletions(-) diff --git a/src/index.css b/src/index.css index 8956c7f..8450601 100644 --- a/src/index.css +++ b/src/index.css @@ -1,3 +1,6 @@ +@import url('../node_modules/@fortawesome/fontawesome-free/css/all.min.css'); +@import url('../node_modules/@fortawesome/fontawesome-free/css/fontawesome.min.css'); + @font-face { font-family: "Comfortaa"; src: url(assets/fonts/Comfortaa-Regular.ttf) format("truetype"); diff --git a/src/index.html b/src/index.html index 8e5aa27..dec9929 100644 --- a/src/index.html +++ b/src/index.html @@ -1,92 +1,131 @@ - - - To-Do List - - - - - - - -

To-Do List

-
- -
+ + + To-Do List + + + + + + + +

To-Do List

+
+ +
-
- Add New List -
-
- - - + + + `; + } + function AddTaskInterfacerP2(x1) { + AddItemtoList(x1, document.getElementById(`NewInputName_${x1}`).value); + setToDoLists(); + } + function AddTaskInterfacerP3(x1) { + var to_insert_in = document.getElementById(`add_task_input_${x1}`); + to_insert_in.innerHTML = ""; + } + function EditTask(elementID, theKey, save=false, oldValue="") { + var element = document.getElementById(elementID) + var theElementChild = element.firstElementChild + if (save) { + var newValue = document.getElementById(elementID).value + element.parentElement.innerHTML = ` + ●  + ${newValue} + + + ` + EditItem(theKey, oldValue, newValue) + } else { + if (theElementChild === null) { + old_elm_val = element.innerHTML + element.parentElement.innerHTML = ` + + + Save + + ` + var element = document.getElementById(elementID) + var theElementChild = element.firstElementChild + element.firstElementChild.focus(); + var val = element.firstElementChild.value; + element.firstElementChild.value = ''; + element.firstElementChild.value = val; + } + } + + } + function setToDoLists() { + var to_do_lists = document.getElementById("to_do_lists"); + to_do_lists.innerHTML = ""; + for (var [key, value] of Object.entries(GetLists())) { + var to_do_items = ""; + if (value.length != 0) { + for (var i=0; i < value.length; i++) { + to_do_items+=` + + + ●  + ${value[i]} + + + + `; + } + } + + to_do_lists.innerHTML+=` +
+ + + + + + + + ${to_do_items} + + + +
${key}
+
`; + } + } + setToDoLists() + + + diff --git a/src/index.js b/src/index.js index 6893ec0..ac32195 100644 --- a/src/index.js +++ b/src/index.js @@ -17,9 +17,8 @@ const createWindow = () => { height: 600, icon: "../assets/app_icons/app_icon.png", webPreferences: { - enableRemoteModule: true, nodeIntegration: true, - contextIsolation: false, + contextIsolation: false }, }); diff --git a/src/render.js b/src/render.js index 7dd8c39..aab3d64 100644 --- a/src/render.js +++ b/src/render.js @@ -36,10 +36,12 @@ function RemoveItemfromList(listName, item) { get_store().set(`Simple-To-Do-App.${listName}`, tmp_array2); } -function DeleteList(listName) { - get_store().delete(`Simple-To-Do-App.${listName}`) +function EditItem(listName, item, newItem) { + var tmp_array = get_store().get(`Simple-To-Do-App.${listName}`) + tmp_array[tmp_array.indexOf(item)] = newItem; + get_store().set(`Simple-To-Do-App.${listName}`, tmp_array) } -function SaveDivPosition() { - var all_divs = document.getElementById("") +function DeleteList(listName) { + get_store().delete(`Simple-To-Do-App.${listName}`) }