diff --git a/sarah/main.js b/sarah/main.js index 70dd813..aa246f2 100644 --- a/sarah/main.js +++ b/sarah/main.js @@ -1,3 +1,6 @@ +//NOTES: testing at http-server + + const safeJSONParse = (str, defaultValue) => { //Makes sure errors aren't thrown with non parsable strings let value = defaultValue try { @@ -16,8 +19,6 @@ const getLocalStorage = (key, defaultValue) => { ) } -//NOTES: testing at http-server - //Global variables and functions and querySelectors const historyList = [] //array of history of completed tasks let displayedTask = getLocalStorage(`currentTask`, 0) //keeps track of what task is currently being displayed, for previous and next task displays @@ -73,15 +74,7 @@ const displayCurrentTask = () => { document.querySelector(`#card-description`).innerHTML = getLocalStorage(`taskStack`, [])[getLocalStorage(`currentTask`, 0)].description /* - -
-
Current Task
-
-
-
- - - + TODO flip button should only be selectable when viewing task with id = currentTask edit button selectable for all tasks when Flip is selected -> send to flipNotes function @@ -116,9 +109,12 @@ const generateTask = () => { displayCurrentTask() } -//global eventlistener on done button to generate task +//global eventlistener on edit done button to generate task document.querySelector(`#edit-done`).addEventListener("click", generateTask) +//global eventlistener on hisory back button to return to display current task +document.querySelector(`#history-back`).addEventListener("click", displayCurrentTask) + const editTask = () => { @@ -153,8 +149,25 @@ document.querySelector(`#edit`).addEventListener("click", () => { editTask() }) +//When View History is selected, send to rotationRecord +document.querySelector(`#view-history`).addEventListener("click", () => { + rotationRecord() +}) + +const rotationRecord = () => { + + //Hide previous screen and show history screen + showCorrectScreen(`#screen-history`) + + /* TODO + If task selected -> taskRecord(selected task) + If Done selected -> return to displayCurrentTask + */ +} + displayCurrentTask() + const flipNotes = () => { /* (called when a task is done and flipped, to add date and notes to current occurance of task) @@ -180,14 +193,6 @@ const deleteTask = () => { */ } -const rotationRecord = () => { - /* - Display Rotation Record - If task selected -> taskRecord(selected task) - If Done selected -> return to displayCurrentTask - */ -} - const taskRecord = () => { /* Display history/record of selected task