Queue checking/unchecking multiple items

This commit is contained in:
Trevor Slocum 2019-04-08 23:41:29 -07:00
parent 63cb6fbcd3
commit 5915a8bc2a
1 changed files with 11 additions and 1 deletions

View File

@ -8,12 +8,13 @@ var NoteMode = "view";
var NoteTitle = "";
var NoteBody = "";
var NoteCheckbox = 0;
var NoteCheckingItem = false;
var NoteHideChecked = true;
var markdownRenderer = new marked.Renderer();
markdownRenderer.checkbox = function (chkd) {
var checked = chkd ? ' checked' : '';
var ret = '<input type="checkbox" id="chk_' + NoteCheckbox + '" onclick="checkItem(' + NoteCheckbox + ')"' + checked + '> ';
var ret = '<input type="checkbox" id="chk_' + NoteCheckbox + '" onclick="checkItem(' + NoteCheckbox + ');return false;"' + checked + '> ';
NoteCheckbox++;
return ret;
@ -175,11 +176,19 @@ function saveNote() {
function checkItem(item) {
//$('#status').css('display', 'block');
if (NoteCheckingItem) {
setTimeout(function () {
checkItem(item);
}, 250);
return;
}
NoteCheckingItem = true;
var notebook = Notebooks[ViewNotebook];
var note = Notebooks[ViewNotebook].Notes[ViewNote];
if (!notebook || !note) {
$('#status').css('display', 'none');
NoteCheckingItem = false;
alert('Failed to ' + (checked ? 'check' : 'uncheck') + ' ' + $('#chk_' + item).closest('li').text());
return;
}
@ -201,6 +210,7 @@ function checkItem(item) {
})
.always(function () {
$('#status').css('display', 'none');
NoteCheckingItem = false;
});
}