|
|
|
@ -50,7 +50,26 @@ $(".view-main").on("click", ".parsedown-task-list", function (e) {
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function loadNotesToCards(notes, callback) {
|
|
|
|
|
function loadNotesToCards(notes, oldnotes, callback) {
|
|
|
|
|
if (notes.length == oldnotes.length) {
|
|
|
|
|
var allSame = true;
|
|
|
|
|
var allPresent = true;
|
|
|
|
|
for (var n in notes) {
|
|
|
|
|
if (!notes[n].compareTo(oldnotes[n])) {
|
|
|
|
|
allSame = false;
|
|
|
|
|
}
|
|
|
|
|
if (document.getElementById('notecard-col-' + notes[n].getID()) === null) {
|
|
|
|
|
allPresent = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (allSame && allPresent) {
|
|
|
|
|
window.shuffleInstance.layout();
|
|
|
|
|
if (typeof callback == 'function') {
|
|
|
|
|
callback();
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (i in window.shuffleInstance.items) {
|
|
|
|
|
window.shuffleInstance.remove(window.shuffleInstance.items[i]);
|
|
|
|
|
}
|
|
|
|
@ -100,6 +119,7 @@ function loadNotesToCards(notes, callback) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function loadCards(callback) {
|
|
|
|
|
var oldnotes = NOTES.getAll().slice();
|
|
|
|
|
NOTES.syncAll(function (notes) {
|
|
|
|
|
if ($("#offline-indicator").css("display") != "none") {
|
|
|
|
|
app.toast.create({
|
|
|
|
@ -108,10 +128,11 @@ function loadCards(callback) {
|
|
|
|
|
}).open();
|
|
|
|
|
}
|
|
|
|
|
$("#offline-indicator").css("display", "none");
|
|
|
|
|
loadNotesToCards(notes, callback);
|
|
|
|
|
console.log("Comparing: ", notes, oldnotes);
|
|
|
|
|
loadNotesToCards(notes, oldnotes, callback);
|
|
|
|
|
}, function (notes) {
|
|
|
|
|
$("#offline-indicator").css("display", "");
|
|
|
|
|
loadNotesToCards(notes, callback);
|
|
|
|
|
loadNotesToCards(notes, oldnotes, callback);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -133,10 +154,15 @@ function favoriteNote(id) {
|
|
|
|
|
note.setModified();
|
|
|
|
|
$("#notecard-" + id).attr("data-favorite", note.getFavorite() ? "1" : "0");
|
|
|
|
|
note.saveNote();
|
|
|
|
|
NOTES.syncAll();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function makeList(id) {
|
|
|
|
|
|
|
|
|
|
var note = NOTES.get(id);
|
|
|
|
|
note.toChecklist();
|
|
|
|
|
note.setModified();
|
|
|
|
|
note.saveNote();
|
|
|
|
|
app.ptr.refresh();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function deleteNote(id) {
|
|
|
|
@ -144,8 +170,10 @@ function deleteNote(id) {
|
|
|
|
|
var note = NOTES.get(id);
|
|
|
|
|
note.deleteme();
|
|
|
|
|
NOTES.set(note);
|
|
|
|
|
window.shuffleInstance.remove(document.getElementById("notecard-" + id));
|
|
|
|
|
loadCards();
|
|
|
|
|
window.shuffleInstance.remove(document.getElementById("notecard-col-" + id));
|
|
|
|
|
$("#notecard-col-" + id).remove();
|
|
|
|
|
window.shuffleInstance.layout();
|
|
|
|
|
NOTES.syncAll();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -190,6 +218,7 @@ $("#app").on("click", "#colorpicker .colorpicker-color", function () {
|
|
|
|
|
note.setColor(color);
|
|
|
|
|
note.setModified();
|
|
|
|
|
note.saveNote();
|
|
|
|
|
NOTES.syncAll();
|
|
|
|
|
$("#notecard-" + noteid).data("bg", note.getColor());
|
|
|
|
|
$("#notecard-" + noteid).data("fg", note.getTextColor());
|
|
|
|
|
$("#notecard-" + noteid).attr("data-bg", note.getColor());
|
|
|
|
@ -226,13 +255,13 @@ function openNoteActionMenu(notecard) {
|
|
|
|
|
favoriteNote(noteid);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// {
|
|
|
|
|
// text: "Make a List",
|
|
|
|
|
// icon: '<i class="fas fa-tasks fa-fw"></i>',
|
|
|
|
|
// onClick: function () {
|
|
|
|
|
// makeList(noteid);
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
{
|
|
|
|
|
text: "Make a List",
|
|
|
|
|
icon: '<i class="fas fa-tasks fa-fw"></i>',
|
|
|
|
|
onClick: function () {
|
|
|
|
|
makeList(noteid);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
text: "Delete",
|
|
|
|
|
color: "red",
|
|
|
|
@ -256,7 +285,7 @@ function openNoteActionMenu(notecard) {
|
|
|
|
|
'<li><a class="list-button item-link edit-note-btn" data-note="' + noteid + '"><i class="fas fa-edit fa-fw"></i> Edit</a></li>' +
|
|
|
|
|
'<li><a class="list-button item-link color-note-btn" data-note="' + noteid + '"><i class="fas fa-palette fa-fw"></i> Color</a></li>' +
|
|
|
|
|
'<li><a class="list-button item-link favorite-note-btn" data-note="' + noteid + '"><i class="fas fa-star-half-alt fa-fw"></i> Favorite</a></li>' +
|
|
|
|
|
//'<li><a class="list-button item-link listify-note-btn" data-note="' + noteid + '"><i class="fas fa-tasks fa-fw"></i> Make a List</a></li>' +
|
|
|
|
|
'<li><a class="list-button item-link listify-note-btn" data-note="' + noteid + '"><i class="fas fa-tasks fa-fw"></i> Make a List</a></li>' +
|
|
|
|
|
'<li><a class="list-button item-link delete-note-btn text-color-red" data-note="' + noteid + '"><i class="fas fa-trash fa-fw"></i> Delete</a></li>' +
|
|
|
|
|
'</ul>' +
|
|
|
|
|
'</div>' +
|
|
|
|
@ -278,4 +307,10 @@ $(".view-main").on("click", ".notecard .editbtn", function () {
|
|
|
|
|
|
|
|
|
|
$(".view-main").on("contextmenu", ".notecard", function () {
|
|
|
|
|
return openNoteActionMenu($(this));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Re-layout notes when any images load
|
|
|
|
|
$("img").on("load", function () {
|
|
|
|
|
console.log("Image loaded, redoing layout...");
|
|
|
|
|
window.shuffleInstance.layout();
|
|
|
|
|
});
|