|
|
|
@ -19,6 +19,55 @@ $(".view-main").on("input change", "#searchbar-input", function () {
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$(".view-main").on("click", ".parsedown-task-list", function (e) {
|
|
|
|
|
var noteid = $(this).closest(".notecard").data("id");
|
|
|
|
|
var note = NOTES.get(noteid);
|
|
|
|
|
var checkbox = $(this).find("input[type=checkbox]");
|
|
|
|
|
var line = $(this);
|
|
|
|
|
var text = line.text().trim();
|
|
|
|
|
// The checkbox has already changed by itself if it was clicked directly
|
|
|
|
|
var checked = checkbox.prop("checked");
|
|
|
|
|
if (e.target.nodeName != "INPUT") {
|
|
|
|
|
checked = !checked;
|
|
|
|
|
}
|
|
|
|
|
console.log(checkbox);
|
|
|
|
|
console.log(line);
|
|
|
|
|
console.log(checked);
|
|
|
|
|
|
|
|
|
|
var lines = note.content.split("\n");
|
|
|
|
|
var newcontent = "";
|
|
|
|
|
|
|
|
|
|
for (i in lines) {
|
|
|
|
|
var li = lines[i].trim();
|
|
|
|
|
if (!li.match(/^- \[[x ]\] .*/i)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
var linecleaned = li.replace(/^- \[[x ]\] /i, '').trim();
|
|
|
|
|
if (text != linecleaned) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (li.match(/^- \[[x]\] .*/i)) {
|
|
|
|
|
lines[i] = li.replace(/^- \[[x]\] /i, "- [ ] ");
|
|
|
|
|
line.addClass("parsedown-task-list-open");
|
|
|
|
|
line.removeClass("parsedown-task-list-close");
|
|
|
|
|
checkbox.prop("checked", false);
|
|
|
|
|
} else if (li.match(/^- \[[ ]\] .*/i)) {
|
|
|
|
|
lines[i] = li.replace(/^- \[[ ]\] /i, "- [x] ");
|
|
|
|
|
line.addClass("parsedown-task-list-close");
|
|
|
|
|
line.removeClass("parsedown-task-list-open");
|
|
|
|
|
checkbox.prop("checked", true);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
note.content = lines.join("\n");
|
|
|
|
|
note.modified = null;
|
|
|
|
|
note.html = null;
|
|
|
|
|
|
|
|
|
|
NOTES.set(NOTES.fix(note));
|
|
|
|
|
|
|
|
|
|
NOTES.sync();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function loadCards(callback) {
|
|
|
|
|
// Do it twice as a workaround for the stupid sync issue
|
|
|
|
|
NOTES.sync(function () {
|
|
|
|
@ -46,7 +95,10 @@ function loadCards(callback) {
|
|
|
|
|
id: note.noteid
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
console.log(trayitems);
|
|
|
|
|
$(".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({
|
|
|
|
|