Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b8d3975

Browse files
working on duplicate note insertion
1 parent da96f0b commit b8d3975

File tree

1 file changed

+35
-9
lines changed

1 file changed

+35
-9
lines changed

‎js/script.js

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,14 @@ function add_note(title_el,data_el)
116116
main_container = document.getElementById('nt');
117117
main_container.appendChild(note_card);
118118
html = `
119-
<div id="${notes_count+1}" style=" max-width: 18rem;">
119+
<div class="card text-white bg-dark mx-1 mb-3" id="${notes_count+1}" style=" max-width: 18rem; min-width: 18rem;">
120120
<div class="card-header row container-fluid justify-content-between" style="margin: 0px !important">
121121
Note: ${notes_count+1} <i" onclick="notedelete(${notes_count+1},'${title_el}')"style="padding: 3px 0 0 0; cursor:pointer;" class="fa fa-trash" aria-hidden="true"></i>
122122
123123
</div>
124124
<div class="card-body">
125125
<h5 class="card-title">${title_el}</h5>
126-
<p class="card-text">${data_el.slice(0,25)}...</p>
126+
<p class="card-text">${data_el.slice(0,30)}...</p>
127127
</div>
128128
</div>`;
129129

@@ -136,7 +136,7 @@ function notedelete(id,title)
136136
{
137137

138138
el=document.getElementById(id);
139-
note_title = el.children[0].children[1].children[0].innerHTML;
139+
// note_title = el.children[0].children[1].children[0].innerHTML;
140140
el.remove();
141141
let notes_array = JSON.parse(localStorage.getItem('notes'));
142142
temp = notes_array;
@@ -159,25 +159,51 @@ function notedelete(id,title)
159159
///////////////////////saved notes display//////////////////////////
160160
function saved_notes_display()
161161
{
162-
let noteselm = localStorage.getItem('notes');
163-
if(noteselm==null)
164-
{
162+
let noteselm = JSON.parse(localStorage.getItem('notes'));
163+
all_notes_in_dom = document.getElementsByClassName('card-title');
164+
165+
all_note_in_dom = Array.from(all_notes_in_dom);
166+
all_dom_notes_title = [];
167+
all_note_in_dom.forEach(function(note,ind)
168+
{
169+
all_dom_notes_title.push(note.innerHTML);
170+
});
171+
172+
if(!noteselm.length)
173+
{
174+
165175
alert_shower("danger","No Notes Found")
166176

167177
}
168178
else
169179
{
170-
notesObj = JSON.parse(noteselm);
180+
notesObj = noteselm
181+
182+
171183
notesObj.forEach(function note_data_extractor(note,ind)
172184
{
185+
173186
for(var title in note)
174187
{
175-
data = note[title];
176-
add_note(title,data);
188+
all_dom_notes_title.forEach(function note_exist_in_dom_checker(domtitle,ind)
189+
{
190+
191+
if(title!=domtitle)
192+
{
193+
194+
}
195+
data = note[title];
196+
add_note(title,data);
197+
});
198+
177199
}
178200
});
201+
202+
203+
179204
}
180205
}
206+
181207
//////////////////this will clear your local storage////////////////////
182208
function localStorage_clear()
183209
{

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /