forked from Saigenix/Study-planner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index2.js
55 lines (48 loc) · 1.34 KB
/
index2.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
44
45
46
47
48
49
50
51
52
53
54
55
const showNotes = (e) => {
let notesave = localStorage.getItem("notesave");
if (notesave == null) {
notesO = [];
} else {
notesO = JSON.parse(notesave);
// console.log(notesObj);
}
let html = "";
for (var i = 0; i < notesO.length; i++) {
html += ` <div class="card">
<h2 class="head">plan ${i+1} </h2>
<hr />
<p id='text'class="p">${notesO[i]}
</p>
</div>
`;
}
let notesElm = document.getElementById("savedetails");
if (notesO.length != 0) {
notesElm.innerHTML = html;
} else {
notesElm.innerHTML = `Nothing to show!`;
}
}
showNotes();
const go = () => {
window.location.pathname = "Study-planner/Form.html";
// use this in local machine
//window.location.pathname = "/Form.html";
}
// to search function
let search = document.getElementById('searchTxt');
search.addEventListener("input", function() {
let inputVal = search.value.toLowerCase();
// console.log('Input event fired!', inputVal);
let noteCards = document.getElementsByClassName('card');
Array.from(noteCards).forEach(function(element) {
let cardTxt = element.getElementsByTagName("p")[0].innerText;
if (cardTxt.includes(inputVal)) {
element.style.display = "block";
}
else {
element.style.display = "none";
}
// console.log(cardTxt);
})
})