@@ -116,14 +116,14 @@ function add_note(title_el,data_el)
116
116
main_container = document . getElementById ( 'nt' ) ;
117
117
main_container . appendChild ( note_card ) ;
118
118
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; ">
120
120
<div class="card-header row container-fluid justify-content-between" style="margin: 0px !important">
121
121
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>
122
122
123
123
</div>
124
124
<div class="card-body">
125
125
<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>
127
127
</div>
128
128
</div>` ;
129
129
@@ -136,7 +136,7 @@ function notedelete(id,title)
136
136
{
137
137
138
138
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;
140
140
el . remove ( ) ;
141
141
let notes_array = JSON . parse ( localStorage . getItem ( 'notes' ) ) ;
142
142
temp = notes_array ;
@@ -159,25 +159,51 @@ function notedelete(id,title)
159
159
///////////////////////saved notes display//////////////////////////
160
160
function saved_notes_display ( )
161
161
{
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
+
165
175
alert_shower ( "danger" , "No Notes Found" )
166
176
167
177
}
168
178
else
169
179
{
170
- notesObj = JSON . parse ( noteselm ) ;
180
+ notesObj = noteselm
181
+
182
+
171
183
notesObj . forEach ( function note_data_extractor ( note , ind )
172
184
{
185
+
173
186
for ( var title in note )
174
187
{
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
+
177
199
}
178
200
} ) ;
201
+
202
+
203
+
179
204
}
180
205
}
206
+
181
207
//////////////////this will clear your local storage////////////////////
182
208
function localStorage_clear ( )
183
209
{
0 commit comments