-
Notifications
You must be signed in to change notification settings - Fork 0
/
gatherDailyHabits.js
43 lines (36 loc) · 1.23 KB
/
gatherDailyHabits.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
if(dailies === null)
{
dailies = [];
}
let initval3 = localStorage.getItem(dailies);
console.log(initval3);
document.getElementById("button3").onclick = addNewHabit;
function addNewHabit()
{
tasks.push(document.getElementById('habit').value);
localStorage.setItem("dailies", JSON.stringify(dailies));
var para = document.createElement("div");
para.id = `deleteDiv${dailies.length-1}`
console.log(para);
para.innerHTML = `<p>${dailies[dailies.length-1]}</p>
<button type="button" id = "deleteHabit${dailies.length-1}">X</button>`
document.getElementById("updDH").appendChild(para);
document.getElementById(`deleteHabit${dailies.length-1}`).onclick = () => {
var elem = document.querySelector(`#deleteDiv${dailies.length-1}`);
elem.parentNode.removeChild(elem);
deletedTasks.push(dailies.length-1);
localStorage.setItem("deletedHabits", JSON.stringify(deletedHabits));
}
}
/*
let key3 = 'dailies';
let initval3 = localStorage.getItem('dailies');
console.log(initval3);
document.getElementById("button3").onclick = addNewTask;
function addNewTask()
{
localStorage.setItem('dailies', document.getElementById('habit').value);
let updval3 = localStorage.getItem('dailies');
console.log(updval3);
}
*/