diff --git a/www/js/home.js b/www/js/home.js
index 9b2a118..ae24e8c 100644
--- a/www/js/home.js
+++ b/www/js/home.js
@@ -52,6 +52,7 @@ $(".view-main").on("click", ".parsedown-task-list", function (e) {
});
function loadNotesToCards(notes, oldnotes, callback) {
+ var reloadCards = true;
if (force_card_refresh != true && notes.length == oldnotes.length) {
var allSame = true;
var allPresent = true;
@@ -64,18 +65,16 @@ function loadNotesToCards(notes, oldnotes, callback) {
}
}
if (allSame && allPresent) {
- window.shuffleInstance.layout();
- if (typeof callback == 'function') {
- callback();
- }
- return;
+ reloadCards = false;
}
}
force_card_refresh = false;
- for (i in window.shuffleInstance.items) {
- window.shuffleInstance.remove(window.shuffleInstance.items[i]);
+ if (reloadCards) {
+ for (i in window.shuffleInstance.items) {
+ window.shuffleInstance.remove(window.shuffleInstance.items[i]);
+ }
+ $(".notecard-col").remove();
}
- $(".notecard-col").remove();
var trayitems = [];
for (n in notes) {
var note = notes[n];
@@ -83,37 +82,41 @@ function loadNotesToCards(notes, oldnotes, callback) {
if (note.getSyncStatus() == "LOCAL_DELETED") {
continue;
}
- $("#notecards-bin").append('
'
- + '
'
- + '
'
- + 'edit'
- + '
'
- + ''
- + '
'
- + '
'
- + '
');
+ if (reloadCards) {
+ $("#notecards-bin").append(''
+ + '
'
+ + '
'
+ + 'edit'
+ + '
'
+ + ''
+ + '
'
+ + '
'
+ + '
');
+ }
trayitems.push({
title: note.getTitle(),
id: note.getID()
});
}
- $(".notecard .card-content ul li:has(input[type=checkbox])").addClass("parsedown-task-list");
- $(".notecard .card-content ul li:has(input[type=checkbox]:checkbox:not(:checked))").addClass("parsedown-task-list-open");
- $(".notecard .card-content ul li:has(input[type=checkbox]:checkbox:checked)").addClass("parsedown-task-list-close");
- $(".parsedown-task-list input[type=checkbox]").removeAttr("disabled");
- var noteElements = document.getElementsByClassName("notecard-col");
- window.shuffleInstance.add(noteElements);
- window.shuffleInstance.sort({
- reverse: true,
- by: function (el) {
- if (el.getAttribute("id") == "offline-indicator") {
- return "999999999";
+ if (reloadCards) {
+ $(".notecard .card-content ul li:has(input[type=checkbox])").addClass("parsedown-task-list");
+ $(".notecard .card-content ul li:has(input[type=checkbox]:checkbox:not(:checked))").addClass("parsedown-task-list-open");
+ $(".notecard .card-content ul li:has(input[type=checkbox]:checkbox:checked)").addClass("parsedown-task-list-close");
+ $(".parsedown-task-list input[type=checkbox]").removeAttr("disabled");
+ var noteElements = document.getElementsByClassName("notecard-col");
+ window.shuffleInstance.add(noteElements);
+ window.shuffleInstance.sort({
+ reverse: true,
+ by: function (el) {
+ if (el.getAttribute("id") == "offline-indicator") {
+ return "999999999";
+ }
+ return el.getAttribute("data-favorite");
}
- return el.getAttribute("data-favorite");
- }
- });
+ });
+ }
setTrayMenu(trayitems);
// Make sure gutters and stuff work
setTimeout(function () {
@@ -180,7 +183,7 @@ function deleteNote(id) {
window.shuffleInstance.remove(document.getElementById("notecard-col-" + id));
$("#notecard-col-" + id).remove();
window.shuffleInstance.layout();
- NOTES.syncAll();
+ loadCards();
});
}