mirror of
https://github.com/hamburghammer/todoApp.git
synced 2024-05-15 09:44:36 +02:00
Compare commits
5 commits
Author | SHA1 | Date | |
---|---|---|---|
e272b77b50 | |||
a3a655a15a | |||
8e6a2af136 | |||
a12ec7d19d | |||
647b5d1f24 |
9
README.md
Normal file
9
README.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# todoApp
|
||||
JavaScript To-Do Web-App
|
||||
|
||||
It is my firs JS App. The whole purpose was to get use and learn the basics.
|
||||
|
||||
The App is written in vanilla JavaScript and bearly styled.
|
||||
Through and input field you can add to-do's to the list. In the list you can check and uncheck as well delete the to-do's.
|
||||
|
||||
Special thanks to [MOINWORLD e.V.](https://moinworld.de/en/)
|
39
todoApp.js
39
todoApp.js
|
@ -4,12 +4,13 @@ var todoList = [],
|
|||
i = 0,
|
||||
storedTodoList,
|
||||
text;
|
||||
|
||||
const todoListDiv = document.getElementById("Todos");
|
||||
|
||||
if (typeof localStorage === "undefined" || localStorage === null) {
|
||||
var LocalStorage = require('node-localstorage').LocalStorage;
|
||||
localStorage = new LocalStorage('./scratch');
|
||||
}
|
||||
// if (typeof localStorage === "undefined" || localStorage === null) {
|
||||
// var LocalStorage = require('node-localstorage').LocalStorage;
|
||||
// localStorage = new LocalStorage('./scratch');
|
||||
// }
|
||||
|
||||
|
||||
function checkForStorage(){
|
||||
|
@ -33,6 +34,7 @@ function addEntry(event) {
|
|||
const myInput = document.getElementById("myInput");
|
||||
text = myInput.value;
|
||||
|
||||
//checking the submited text
|
||||
if (text === "" || typeof text === 'undefined' || text === null ) {
|
||||
return alert("Bitte gib Text ein!");
|
||||
}
|
||||
|
@ -45,21 +47,19 @@ function addEntry(event) {
|
|||
return alert("Du hast schon so ein To-Do!")
|
||||
}
|
||||
|
||||
|
||||
|
||||
//adding the text to the local list and into the storage
|
||||
addTodoToList(text);
|
||||
setLocalStorage(todoList);
|
||||
|
||||
|
||||
let lastTodo = todoList.length -1;
|
||||
|
||||
createTodoEntry(lastTodo);
|
||||
|
||||
|
||||
myInput.value = "";
|
||||
myInput.focus();
|
||||
}
|
||||
//Main function <---
|
||||
//creating the entry / element inside the HTML
|
||||
function createTodoEntry(todoEntry) {
|
||||
|
||||
todoEntryDiv = document.createElement("div");
|
||||
|
@ -109,12 +109,10 @@ function createTodoEntry(todoEntry) {
|
|||
|
||||
if (checkbox.checked === true){
|
||||
let doneTodoList = document.getElementById("doneTodos");
|
||||
doneTodoList.appendChild(todoEntryDiv);
|
||||
return
|
||||
return doneTodoList.appendChild(todoEntryDiv);
|
||||
}
|
||||
|
||||
todoListDiv.appendChild(todoEntryDiv);
|
||||
return
|
||||
return todoListDiv.appendChild(todoEntryDiv);
|
||||
}
|
||||
|
||||
function setLocalStorage(storeData) {
|
||||
|
@ -122,11 +120,10 @@ function setLocalStorage(storeData) {
|
|||
}
|
||||
|
||||
function getLocalStorage() {
|
||||
storedTodoList = JSON.parse(localStorage.getItem("savedTodoList"));
|
||||
|
||||
return storedTodoList;
|
||||
return JSON.parse(localStorage.getItem("savedTodoList"));
|
||||
}
|
||||
|
||||
//TodoList object
|
||||
function addTodoToList(todo) {
|
||||
todoList.push({
|
||||
completed: false,
|
||||
|
@ -134,18 +131,6 @@ function addTodoToList(todo) {
|
|||
})
|
||||
}
|
||||
|
||||
function setTodoList(todoList) {
|
||||
todoList = todoList;
|
||||
}
|
||||
|
||||
function getTodoList() {
|
||||
return todoList;
|
||||
}
|
||||
|
||||
function foo(bar) {
|
||||
return bar;
|
||||
}
|
||||
|
||||
function rmTodo(position) {
|
||||
todoList.splice(position, 1);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue