generated from GeekyHacks/WebPackTemplate
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from GeekyHacks/statusUpdate
Status update
- Loading branch information
Showing
13 changed files
with
296 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
186 changes: 137 additions & 49 deletions
186
dist/bundle55df76a2dc1d3425b0a3.js → dist/bundle0a4d8217c7af776c267d.js
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,27 @@ | ||
import TaskObject from './userInput.js'; | ||
// import { renderList } from './displayList.js'; | ||
import { TaskObject, saveData } from './userInput.js'; | ||
|
||
export const taskarr = JSON.parse(localStorage.getItem('taskarr')) || []; | ||
|
||
export const addTask = (description, index) => { | ||
index = taskarr.length; | ||
const newTask = new TaskObject(description, index); | ||
taskarr.push(newTask); | ||
// this will sort out the user input index | ||
// // this will sort out the user input index | ||
const sortedArr = [...taskarr]; | ||
sortedArr.sort((a, b) => a.index - b.index); | ||
|
||
localStorage.setItem('taskarr', JSON.stringify(sortedArr)); | ||
saveData(taskarr); | ||
return taskarr; | ||
}; | ||
|
||
|
||
|
||
var checkboxValues = JSON.parse(localStorage.getItem('checkboxValues')) || {}; | ||
var $checkboxes = $("#checkbox-container :checkbox"); | ||
|
||
$checkboxes.on("change", function(){ | ||
$checkboxes.each(function(){ | ||
checkboxValues[this.id] = this.checked; | ||
}); | ||
localStorage.setItem("checkboxValues", JSON.stringify(checkboxValues)); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
const sortArray = (array) => { | ||
// this will sort out the index when removing Items | ||
const sortedArr = [...array]; | ||
sortedArr.sort((a, b) => a.index - b.index); | ||
}; | ||
export default { sortArray }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import { taskarr } from './addTask.js'; | ||
import { saveData } from './userInput.js'; | ||
|
||
// const checkboxValues = localStorage.getItem('checkboxValues') || {}; | ||
|
||
export class TaskStatus { | ||
static updateStatus = () => { | ||
const checkB = document.querySelectorAll('.checkB'); | ||
|
||
checkB.forEach((checkbox, i) => { | ||
checkbox.addEventListener('change', () => { | ||
if (!taskarr[i].completed) { | ||
taskarr[i].completed = true; | ||
|
||
// checkboxValues[checkbox.key] = checkbox.checked; | ||
// localStorage.setItem('checkboxValues', JSON.stringify(checkboxValues)); | ||
saveData(taskarr); | ||
// recallChecked(); | ||
} else { | ||
taskarr[i].completed = false; | ||
checkbox['checked'] = false; | ||
saveData(taskarr); | ||
// checkbox.nextElementSibling.classList.remove('completed'); | ||
} | ||
}); | ||
}); | ||
}; | ||
|
||
// static recallChecked = () => { | ||
// [...checkboxValues.children].forEach((child) => { | ||
// console.log(child); | ||
// const checkbox = document.getElementById(key); | ||
// checkbox['checked'] = value; | ||
// }); | ||
|
||
// Object.entries(checkboxValues).forEach(([key, value]) => { | ||
// const checkbox = document.getElementById(key); | ||
// checkbox['checked'] = value; | ||
// console.log(key + ' - ' + value); | ||
// }); | ||
// }; | ||
|
||
static clearCompleted = () => { | ||
const clearAllBtn = document.querySelector('#clearAllBtn'); | ||
clearAllBtn.addEventListener('click', () => { | ||
const notCompleted = taskarr.filter((task) => task.completed !== true); | ||
notCompleted.forEach((e, i) => { | ||
e.index = i + 1; | ||
}); | ||
saveData(notCompleted); | ||
window.location.reload(); | ||
}); | ||
}; | ||
} | ||
|
||
// export const recallChecked = () => { | ||
// Object.entries(checkboxValues).forEach((key, value) => { | ||
// const checkbox = document.getElementById(key); | ||
// checkbox['checked'] = value; | ||
// }); | ||
// }; | ||
// const checkboxValues = localStorage.getItem("checkboxValues") || {}; | ||
// const checkboxes = document.querySelectorAll(".checkbox"); | ||
|
||
// checkboxes.forEach((checkbox) => { | ||
// checkbox.addEventListener("change", () => { | ||
// checkboxValues[checkbox.id] = checkbox.checked; | ||
// localStorage.setItem("checkboxValues", JSON.stringify(checkboxValues)); | ||
// }); | ||
// }); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
export default class TaskObject { | ||
export class TaskObject { | ||
constructor(description, index) { | ||
this.description = description; | ||
this.completed = false; | ||
this.index = index; | ||
} | ||
} | ||
|
||
export const saveData = (data) => { | ||
localStorage.setItem('taskarr', JSON.stringify(data)); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters