Skip to content

Commit

Permalink
Sarah - history button works, though history not populated yet
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyHubert committed Aug 8, 2024
1 parent 2fed194 commit 4ac87fa
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions sarah/main.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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
Expand Down Expand Up @@ -73,15 +74,7 @@ const displayCurrentTask = () => {
document.querySelector(`#card-description`).innerHTML = getLocalStorage(`taskStack`, [])[getLocalStorage(`currentTask`, 0)].description

/*
<div class="card">
<div class="card-heading">Current Task</div>
<div id="card-title"></div>
<div id="card-description"></div>
<div class="card-buttons">
<button id="check-off">✓ Check</button>
<button id="edit">Edit</button>
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
Expand Down Expand Up @@ -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 = () => {

Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 4ac87fa

Please sign in to comment.