Browse Source

Add note deletion

tags/v1.1.0
Skylar Ittner 9 months ago
parent
commit
20dbd0a613
5 changed files with 65 additions and 24 deletions
  1. 24
    0
      www/js/NotePostNotes.class.js
  2. 13
    0
      www/js/Notes.class.js
  3. 1
    1
      www/js/editnote.js
  4. 26
    22
      www/js/home.js
  5. 1
    1
      www/pages/editnote.html

+ 24
- 0
www/js/NotePostNotes.class.js View File

@@ -13,6 +13,30 @@ class NotePostNotes extends Notes {
this.password = password;
}

del(noteid, callback) {
super.del(noteid);
var self = this;
$.ajax({
url: this.server + "/api/deletenote",
dataType: "json",
cache: false,
method: "POST",
data: {
id: noteid
},
beforeSend: function (xhr) {
xhr.setRequestHeader("Authorization", "Basic " + btoa(self.username + ":" + self.password));
}, success: function (val) {
if (val.status == "OK") {
self.notes = val.notes;
}
if (typeof callback == 'function') {
callback();
}
}
});
}

add(note, callback) {
note.norealid = true;
super.add(note, callback);

+ 13
- 0
www/js/Notes.class.js View File

@@ -36,6 +36,19 @@ class Notes {
this.notes.push(note);
}

del(noteid, callback) {
var newnotearr = [];
for (var i = 0; i < this.notes.length; i++) {
if (this.notes[i].id != noteid) {
newnotearr.push(this.notes[i]);
}
}
this.notes = newnotearr;
if (typeof callback == 'function') {
callback();
}
}

add(note, callback) {
this.notes.push(note);
if (typeof callback == 'function') {

+ 1
- 1
www/js/editnote.js View File

@@ -40,7 +40,7 @@ function saveme(callback) {
}

function exiteditor() {
if ($("note_content").val() == "" || $("note_content").val() === $("orig_content").val()) {
if ($("#note_content").val() == "" || $("#note_content").val() === $("#orig_content").val()) {
router.back({force: true, ignoreCache: true, reload: true});
} else {
saveme(function () {

+ 26
- 22
www/js/home.js View File

@@ -6,18 +6,18 @@


$(".view-main").on("ptr:refresh", ".ptr-content", function () {
router.navigate("/home");
restartApplication();
});

function editNote(id) {
var note = notes.get(id);
router.navigate("/editnote", {
context: {
noteid: id,
content: note.content,
notetitle: note.title,
}
});
context: {
noteid: id,
content: note.content,
notetitle: note.title,
}
});
console.log("Editing " + id);
}

@@ -30,7 +30,11 @@ function makeList(id) {
}

function deleteNote(id) {

app.dialog.confirm('Are you sure?', 'Delete Note', function () {
notes.del(id, function () {
app.ptr.refresh();
});
});
}

$("#app").on("click", ".edit-note-btn", function () {
@@ -66,20 +70,20 @@ function openNoteActionMenu(notecard) {
editNote(noteid);
}
},
{
text: "Favorite",
icon: '<i class="fas fa-star fa-fw"></i>',
onClick: function () {
favoriteNote(noteid);
}
},
{
text: "Make a List",
icon: '<i class="fas fa-tasks fa-fw"></i>',
onClick: function () {
makeList(noteid);
}
},
// {
// text: "Favorite",
// icon: '<i class="fas fa-star fa-fw"></i>',
// onClick: function () {
// favoriteNote(noteid);
// }
// },
// {
// text: "Make a List",
// icon: '<i class="fas fa-tasks fa-fw"></i>',
// onClick: function () {
// makeList(noteid);
// }
// },
{
text: "Delete",
icon: '<i class="fas fa-trash fa-fw"></i>',

+ 1
- 1
www/pages/editnote.html View File

@@ -28,7 +28,7 @@

<div class="page-content ptr-content">

<textarea id="note_content" data-noteid="{{noteid}}" style="z-index: 99999999;">{{content}}</textarea>
<textarea id="note_content" data-noteid="{{noteid}}">{{content}}</textarea>
<textarea id="orig_content" style="display: none;">{{content}}</textarea>

</div>

Loading…
Cancel
Save