Skip to content

Commit 69d14d6

Browse files
Revert "Feat/issue 1886/revamp note app"
1 parent e8e57a6 commit 69d14d6

19 files changed

Lines changed: 565 additions & 969 deletions

File tree

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
11
# SmartNotezz-WebApp
2-
32
SmartNotezz is a web based notes making and editing app. It enables users to keep track of their tasks and other to-do lists. The notes are stored into the local storage so that users need not worry about losing their data on exiting the page. By default, the notes are stored from most recent to oldest. A search option is made available to users for searching the title and locating their notes to avoid the hassle of scrolling down or up looking for a note.
43

54
# Technologies Used
6-
7-
- HTML5
8-
- CSS3
9-
- CSS Animations
10-
- CSS Media Queries
11-
- Javascript
12-
- Netlify
13-
- Editorjs
14-
- Vite
5+
* HTML5
6+
* CSS3
7+
* CSS Animations
8+
* CSS Media Queries
9+
* Javascript
10+
* Netlify

Projects/Notes App/index.html

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
7+
<link rel="stylesheet" href="style.css">
8+
<title>SmartNotezz</title>
9+
<link rel="stylesheet" href="https://unicons.iconscout.com/release/v4.0.0/css/line.css">
10+
</head>
11+
<body>
12+
<header>
13+
<div class="title">
14+
SmartNotezz
15+
</div>
16+
<img src="assets/S.svg" href="/">
17+
</header>
18+
<nav>
19+
<form class="form">
20+
<input type="search" id="searchTxt"class="search" placeholder="Search your Notes">
21+
<button class="btn" type="submit"><i class="uil uil-search"></i></button>
22+
</form>
23+
</nav>
24+
<div class="your-notes">
25+
Your Notes
26+
<ul id="notesContainer"></ul>
27+
</div>
28+
<div class="popup-box">
29+
<div class="popup">
30+
<div class="content">
31+
<header>
32+
<p>Add a New Note</p>
33+
<i class="ui uil-times"></i>
34+
</header>
35+
<form action="#">
36+
<div class="row-title">
37+
<label>Title</label>
38+
<input type="text">
39+
</div>
40+
<div class="row-description">
41+
<label>Description</label>
42+
<textarea></textarea>
43+
</div>
44+
<button>Add Note</button>
45+
<input type="file" id="file">
46+
</form>
47+
</div>
48+
</div>
49+
</div>
50+
<div class="wrapper">
51+
<li class="add-box">
52+
<div class="icon">
53+
<img src="assets/add.svg" alt="Add">
54+
</div>
55+
<p>Add New Note</p>
56+
</li>
57+
</div>
58+
<script src="script.js"></script>
59+
</body>
60+
</html>

Projects/Notes App/script.js

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
const addBox = document.querySelector(".add-box"),
2+
popupBox = document.querySelector(".popup-box"),
3+
search = document.getElementById('searchTxt'),
4+
popupTitle = popupBox.querySelector("header p"),
5+
titleTag = popupBox.querySelector("input"),
6+
closeIcon = popupBox.querySelector("header i"),
7+
descTag = popupBox.querySelector("textarea"),
8+
addBtn = popupBox.querySelectorAll("button");
9+
10+
const months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
11+
12+
const notesContainer = document.getElementById("notesContainer");
13+
14+
const notes = JSON.parse(localStorage.getItem("notes") || "[]");
15+
let isUpdate = false, updateId;
16+
17+
addBox.addEventListener("click", () => {
18+
titleTag.focus();
19+
popupBox.classList.add("show");
20+
})
21+
closeIcon.addEventListener("click", () => {
22+
isUpdate=false;
23+
titleTag.value="";
24+
descTag.value="";
25+
addBtn[0].innerText="Add Note";
26+
popupTitle.innerText="Add a New Note";
27+
popupBox.classList.remove("show");
28+
})
29+
30+
function showNote() {
31+
32+
notesContainer.innerHTML = "";
33+
document.querySelectorAll(".note").forEach(note =>note.remove());
34+
notes.forEach((note, index) => {
35+
const liClass = note.isImportant ? "note starred" : "note";
36+
37+
const liTag = `<li class="${liClass}" style="background-color: ${note.isImportant ? 'gold' : ''}; color:${note.isImportant ? 'black' : 'white'}">
38+
<div class="details">
39+
<p>${note.title}</p>
40+
<span>${note.description}</span>
41+
</div>
42+
<div class="bottom-content">
43+
<span>${note.date}</span>
44+
<div class="settings">
45+
<i onclick="showMenu(this)" class="uil uil-ellipsis-h"></i>
46+
<ul class="menu">
47+
<li onclick="updateNote(${index},'${note.title}','${note.description}')"> <i class="uil uil-pen"></i>Edit</li>
48+
<li onclick="deleteNote(${index})"> <i class="uil uil-trash"></i>Delete</li>
49+
<li onclick="importantNote(${index})"> <i class="uil uil-heart${note.isImportant ? '-break' : ''}"></i>${note.isImportant ? 'Unstar' : 'Star'}</li>
50+
</ul>
51+
</div>
52+
</div>
53+
</li>`;
54+
addBox.insertAdjacentHTML("afterend", liTag);
55+
});
56+
}
57+
showNote();
58+
59+
function showMenu(elem){
60+
elem.parentElement.classList.add("show");
61+
document.addEventListener("click",e =>{
62+
63+
if(e.target.tagName != "I" || e.target != elem){
64+
elem.parentElement.classList.remove("show");
65+
}
66+
})
67+
}
68+
function deleteNote(noteId){
69+
let confirmDel= confirm("Are you sure you want to delete this note?");
70+
if(!confirmDel) return;
71+
notes.splice(noteId,1); //deletes one note of given id
72+
localStorage.setItem("notes", JSON.stringify(notes));//saving updated notes to local storage
73+
showNote();
74+
}
75+
76+
function updateNote(noteId,title,desc){
77+
isUpdate=true;
78+
updateId = noteId;
79+
addBox.click();
80+
titleTag.value=title;
81+
descTag.value=desc;
82+
addBtn[0].innerText="Update Note";
83+
popupTitle.innerText="Update a Note";
84+
console.log(noteId,title,desc);
85+
}
86+
87+
function importantNote(noteId) {
88+
notes[noteId].isImportant = !notes[noteId].isImportant;
89+
renderNotes();
90+
}
91+
92+
function renderNotes() {
93+
notesContainer.innerHTML = "";
94+
document.querySelectorAll(".note").forEach(note =>note.remove());
95+
notes.forEach((note, index) => {
96+
const liClass = note.isImportant ? "note starred" : "note";
97+
98+
const liTag = `<li class="${liClass}" style="background-color: ${note.isImportant ? 'gold' : ''};">
99+
<div class="details">
100+
<p>${note.title}</p>
101+
<span>${note.description}</span>
102+
</div>
103+
<div class="bottom-content">
104+
<span>${note.date}</span>
105+
<div class="settings">
106+
<i onclick="showMenu(this)" class="uil uil-ellipsis-h"></i>
107+
<ul class="menu">
108+
<li onclick="updateNote(${index},'${note.title}','${note.description}')"> <i class="uil uil-pen"></i>Edit</li>
109+
<li onclick="deleteNote(${index})"> <i class="uil uil-trash"></i>Delete</li>
110+
<li onclick="importantNote(${index})"> <i class="uil uil-heart${note.isImportant ? '-break' : ''}"></i>${note.isImportant ? 'Unstar' : 'Star'}</li>
111+
</ul>
112+
</div>
113+
</div>
114+
</li>`;
115+
addBox.insertAdjacentHTML("afterend", liTag);
116+
});
117+
}
118+
119+
for (var i = 0; i < addBtn.length; i++) {
120+
addBtn[i].addEventListener("click", e => {
121+
e.preventDefault();
122+
}
123+
)}
124+
addBtn[0].addEventListener("click", e => {
125+
let noteTitle = titleTag.value.toUpperCase(),
126+
noteDesc = descTag.value;
127+
128+
if (noteTitle || noteDesc) {
129+
let dateObj = new Date(),
130+
day = dateObj.getDate(),
131+
month = months[dateObj.getMonth()],
132+
year = dateObj.getFullYear();
133+
134+
let noteInfo = {
135+
title: noteTitle, description: noteDesc,
136+
date: `${month} ${day}, ${year}`
137+
}
138+
if(! isUpdate){
139+
notes.push(noteInfo); //adding new notes
140+
}
141+
else{
142+
isUpdate=false;
143+
notes[updateId]=noteInfo;
144+
}
145+
localStorage.setItem("notes", JSON.stringify(notes));//saving notes to local storage
146+
closeIcon.click();
147+
showNote();
148+
}
149+
})
150+
151+
search.addEventListener("input",function(){
152+
153+
let inputVal = search.value.toUpperCase();
154+
let noteCard = document.getElementsByClassName('note');
155+
Array.from(noteCard).forEach(function(element){
156+
let cardTxt = element.getElementsByTagName("p")[0].innerText; //searching by title
157+
if(cardTxt.includes(inputVal)){
158+
element.style.display = "block";
159+
}
160+
else{
161+
element.style.display = "none";
162+
}
163+
//console.log(cardTxt);
164+
165+
})
166+
})
167+
168+
showNote();
169+
renderNotes();

0 commit comments

Comments
 (0)