@@ -360,20 +360,8 @@ $(document).ready(function(){
360
360
}
361
361
} ) ;
362
362
db . notes . where ( "Notebook" ) . equals ( notebook ) . each ( function ( item , cursor ) {
363
- var content = item . Content ;
364
- if ( item . Title != "Untitled" ) {
365
- try {
366
- content = content . replace ( "<h1>" + item . Title + "</h1>" , "" ) . replace ( / ( < ( [ ^ > ] + ) > ) / ig, "" ) ;
367
- } catch ( e ) {
368
- console . log ( e ) ;
369
- }
370
- } else {
371
- content = content . replace ( / ( < ( [ ^ > ] + ) > ) / ig, "" ) ;
372
- }
373
-
374
- content = content . length >= 40 ? content . substring ( 0 , 40 ) : content . substring ( 0 , content . length ) ;
375
363
376
- $ ( ".note-container" ) . append ( "<article data-color='" + item . Color + "' draggable='true' data-nid='" + item . id + "'><div class='content' ><h2>" + item . Title + "</h2><span>" + content + "</span>< /div><div class='note-actions'><span class='fa fa-eye' data-view='" + item . id + "'></span><span class='fa-pencil fa' data-note-id='" + item . id + "' data-action='edit'></span><span class='fa-trash fa' data-note-id='" + item . id + "' data-action='delete'></span></div></article>" ) ;
364
+ $ ( ".note-container" ) . append ( "<article data-color='" + item . Color + "' draggable='true' data-nid='" + item . id + "'><div class='content' ><h2>" + item . Title + "</h2></div><div class='note-actions'><span class='fa fa-eye' data-view='" + item . id + "'></span><span class='fa-pencil fa' data-note-id='" + item . id + "' data-action='edit'></span><span class='fa-trash fa' data-note-id='" + item . id + "' data-action='delete'></span></div></article>" ) ;
377
365
378
366
$ ( ".list article" ) . each ( function ( ) {
379
367
$ ( this ) . css ( "border-color" , $ ( this ) . data ( "color" ) ) ;
@@ -516,22 +504,7 @@ $(document).ready(function(){
516
504
db . transaction ( 'r' , db . notes , function ( ) {
517
505
db . notes . where ( "Notebook" ) . equals ( notebook ) . each ( function ( item , cursor ) {
518
506
if ( item . Content . toLowerCase ( ) . indexOf ( $ ( ".notebook-nav input" ) . val ( ) . toLowerCase ( ) ) > - 1 ) {
519
- var content = item . Content ;
520
- if ( item . Title != "Untitled" ) {
521
- try {
522
- content = content . replace ( "<h1>" + item . Title + "</h1>" , "" ) . replace ( / ( < ( [ ^ > ] + ) > ) / ig, "" ) ;
523
- } catch ( e ) {
524
- console . log ( e ) ;
525
- }
526
- } else {
527
- content = content . replace ( / ( < ( [ ^ > ] + ) > ) / ig, "" ) ;
528
- }
529
- if ( content . length >= 40 ) {
530
- content = content . substring ( 0 , 40 ) ;
531
- } else {
532
- content = content . substring ( 0 , content . length ) ;
533
- }
534
- $ ( ".note-container" ) . append ( "<article data-color='" + item . Color + "' ><div class='content' data-view='" + item . id + "'><h2>" + item . Title + "</h2><span>" + content + "</span></div><div class='note-actions'><span class='fa fa-eye' data-view='" + item . id + "'></span><span class='fa-pencil fa' data-note-id='" + item . id + "' data-action='edit'></span><span class='fa-trash fa' data-note-id='" + item . id + "' data-action='delete'></span></div></article>" ) ;
507
+ $ ( ".note-container" ) . append ( "<article data-color='" + item . Color + "' ><div class='content' data-view='" + item . id + "'><h2>" + item . Title + "</h2></div><div class='note-actions'><span class='fa fa-eye' data-view='" + item . id + "'></span><span class='fa-pencil fa' data-note-id='" + item . id + "' data-action='edit'></span><span class='fa-trash fa' data-note-id='" + item . id + "' data-action='delete'></span></div></article>" ) ;
535
508
536
509
$ ( ".list article" ) . each ( function ( ) {
537
510
$ ( this ) . css ( "border-color" , $ ( this ) . data ( "color" ) ) ;
@@ -627,7 +600,6 @@ $(document).ready(function(){
627
600
$ ( ".side-nav" ) . removeClass ( "active" ) ;
628
601
$ ( ".view-nav" ) . removeClass ( "active" ) ;
629
602
$ ( ".notebook-nav" ) . addClass ( "active" ) ;
630
- loadNotes ( ) ;
631
603
$ ( "nav" ) . show ( ) ;
632
604
$ ( ".note-container" ) . show ( ) ;
633
605
} ) ;
@@ -790,6 +762,7 @@ $(document).ready(function(){
790
762
db . transaction ( 'rw' , db . notes , function ( ) {
791
763
var h1 = $ ( "#editor h1" ) . first ( ) . text ( ) . trim ( ) ;
792
764
h1 = h1 != "" ? h1 : "Untitled" ;
765
+ $ ( "[data-nid='" + id + "'] h2" ) . text ( h1 ) ;
793
766
if ( html && h1 && date ) {
794
767
db . notes . where ( "id" ) . equals ( id ) . modify ( { Content : html , Title : h1 , ModificationDate : date } ) ;
795
768
}
@@ -972,53 +945,45 @@ $(document).ready(function(){
972
945
$ ( ".delete-confirmation .ok" ) . click ( function ( ) {
973
946
db . transaction ( 'rw' , db . notes , function ( ) {
974
947
db . notes . where ( "id" ) . equals ( deltempid ) . delete ( ) ;
948
+ $ ( "[data-nid='" + deltempid + "']" ) . remove ( ) ;
975
949
deltempid = null ;
976
- loadNotes ( ) ;
977
950
$ ( ".delete-confirmation" ) . removeClass ( "active" ) ;
978
951
} ) ;
979
952
} ) ;
980
953
981
954
$ ( ".notebook-delete-confirmation .ok" ) . click ( function ( ) {
982
955
switch ( $ ( ".notebook-delete-confirmation select" ) . val ( ) ) {
983
956
case "Move" :
984
- db . transaction ( 'rw' , db . notebooks , function ( ) {
985
- db . notebooks . where ( "id" ) . equals ( parseInt ( notebook ) ) . delete ( ) . then ( function ( ) {
986
- loadNotebooks ( ) ;
987
- } ) ;
957
+ db . transaction ( 'rw' , db . notebooks , db . notes , function ( ) {
958
+ db . notebooks . where ( "id" ) . equals ( parseInt ( notebook ) ) . delete ( ) ;
959
+ db . notes . where ( "Notebook" ) . equals ( notebook ) . modify ( { Notebook : "Inbox" } ) ;
960
+
988
961
} ) . then ( function ( ) {
989
- db . transaction ( 'rw' , db . notes , function ( ) {
990
- db . notes . where ( "Notebook" ) . equals ( notebook ) . modify ( { Notebook : "Inbox" } ) . then ( function ( ) {
991
- notebook = "Inbox" ;
992
- $ ( ".notebook-nav h1" ) . text ( "Inbox" ) ;
993
- $ ( ".notebook-nav small" ) . text ( "A place for any note" ) ;
994
- $ ( "[data-action='edit-notebook']" ) . hide ( ) ;
995
- $ ( "[data-action='delete-notebook']" ) . hide ( ) ;
996
- loadNotes ( ) ;
997
- $ ( ".notebook-delete-confirmation" ) . removeClass ( "active" ) ;
998
- } ) ;
999
- } ) ;
962
+ notebook = "Inbox" ;
963
+ $ ( ".notebook-nav h1" ) . text ( "Inbox" ) ;
964
+ $ ( ".notebook-nav small" ) . text ( "A place for any note" ) ;
965
+ $ ( "[data-action='edit-notebook']" ) . hide ( ) ;
966
+ $ ( "[data-action='delete-notebook']" ) . hide ( ) ;
967
+ loadNotebooks ( ) ;
968
+ loadNotes ( ) ;
969
+ $ ( ".notebook-delete-confirmation" ) . removeClass ( "active" ) ;
1000
970
} ) ;
1001
971
break ;
1002
972
1003
973
case "Delete" :
1004
- db . transaction ( 'rw' , db . notebooks , function ( ) {
1005
- db . notebooks . where ( "id" ) . equals ( parseInt ( notebook ) ) . delete ( ) . then ( function ( ) {
1006
- loadNotebooks ( ) ;
1007
-
1008
- } ) ;
974
+ db . transaction ( 'rw' , db . notebooks , db . notes , function ( ) {
975
+ db . notebooks . where ( "id" ) . equals ( parseInt ( notebook ) ) . delete ( ) ;
976
+ db . notes . where ( "Notebook" ) . equals ( notebook ) . delete ( ) ;
1009
977
1010
978
} ) . then ( function ( ) {
1011
- db . transaction ( 'rw' , db . notes , function ( ) {
1012
- db . notes . where ( "Notebook" ) . equals ( notebook ) . delete ( ) . then ( function ( ) {
1013
- notebook = "Inbox" ;
1014
- $ ( ".notebook-nav h1" ) . text ( "Inbox" ) ;
1015
- $ ( ".notebook-nav small" ) . text ( "A place for any note" ) ;
1016
- $ ( "[data-action='edit-notebook']" ) . hide ( ) ;
1017
- $ ( "[data-action='delete-notebook']" ) . hide ( ) ;
1018
- loadNotes ( ) ;
1019
- $ ( ".notebook-delete-confirmation" ) . removeClass ( "active" ) ;
1020
- } ) ;
1021
- } ) ;
979
+ notebook = "Inbox" ;
980
+ $ ( ".notebook-nav h1" ) . text ( "Inbox" ) ;
981
+ $ ( ".notebook-nav small" ) . text ( "A place for any note" ) ;
982
+ $ ( "[data-action='edit-notebook']" ) . hide ( ) ;
983
+ $ ( "[data-action='delete-notebook']" ) . hide ( ) ;
984
+ loadNotebooks ( ) ;
985
+ loadNotes ( ) ;
986
+ $ ( ".notebook-delete-confirmation" ) . removeClass ( "active" ) ;
1022
987
} ) ;
1023
988
break ;
1024
989
}
0 commit comments