Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTRL+D, CTRL+S, CTRL+X, and Alt+RightArrow -- Enables a "Due Date", Regular "Date Stamp", Quick Note Deletion Action, Tab Indention, and a Bonus Ability to Visualize Past Due Notes (and overdue visual removal if placed in a 'Done' or 'Complete' named List). #98

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
74 changes: 73 additions & 1 deletion nullboard.html
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,11 @@
padding-bottom: 6px;
}

.board .note.overdue {
background: url("data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjxzdmcgYmFzZVByb2ZpbGU9InRpbnkiIGhlaWdodD0iMjRweCIgaWQ9IkxheWVyXzEiIHZlcnNpb249IjEuMiIgdmlld0JveD0iMCAwIDI0IDI0IiB3aWR0aD0iMjRweCIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+PHBhdGggZD0iTTIxLjE3MSwxNS4zOThsLTUuOTEyLTkuODU0QzE0LjQ4Myw0LjI1MSwxMy4yOTYsMy41MTEsMTIsMy41MTFzLTIuNDgzLDAuNzQtMy4yNTksMi4wMzFsLTUuOTEyLDkuODU2ICBjLTAuNzg2LDEuMzA5LTAuODcyLDIuNzA1LTAuMjM1LDMuODNDMy4yMywyMC4zNTQsNC40NzIsMjEsNiwyMWgxMmMxLjUyOCwwLDIuNzctMC42NDYsMy40MDYtMS43NzEgIEMyMi4wNDMsMTguMTA0LDIxLjk1NywxNi43MDgsMjEuMTcxLDE1LjM5OHogTTEyLDE3LjU0OWMtMC44NTQsMC0xLjU1LTAuNjk1LTEuNTUtMS41NDljMC0wLjg1NSwwLjY5NS0xLjU1MSwxLjU1LTEuNTUxICBzMS41NSwwLjY5NiwxLjU1LDEuNTUxQzEzLjU1LDE2Ljg1NCwxMi44NTQsMTcuNTQ5LDEyLDE3LjU0OXogTTEzLjYzMywxMC4xMjVjLTAuMDExLDAuMDMxLTEuNDAxLDMuNDY4LTEuNDAxLDMuNDY4ICBjLTAuMDM4LDAuMDk0LTAuMTMsMC4xNTYtMC4yMzEsMC4xNTZzLTAuMTkzLTAuMDYyLTAuMjMxLTAuMTU2bC0xLjM5MS0zLjQzOEMxMC4yODksOS45MjIsMTAuMjUsOS43MTIsMTAuMjUsOS41ICBjMC0wLjk2NSwwLjc4NS0xLjc1LDEuNzUtMS43NXMxLjc1LDAuNzg1LDEuNzUsMS43NUMxMy43NSw5LjcxMiwxMy43MTEsOS45MjIsMTMuNjMzLDEwLjEyNXoiLz48L3N2Zz4=")no-repeat, linear-gradient(to right, #ffffff, #f5071f);
background-position: right;
}

.board .note.collapsed .text,
.note-dragster.collapsed .text {
max-height: calc( var(--lh) * 1px );
Expand Down Expand Up @@ -3270,6 +3275,16 @@ <h3>Auto-backup</h3>
var n = l.addNote( getText($note.find('.text')) );
n.raw = $note.hasClass('raw');
n.min = $note.hasClass('collapsed');

//Search for overdue dates and highlight them red via a new class 'overdue'
var noteDate = new Date(n.text.substring(0, n.text.indexOf(']')).split('[').pop().split(']')[0]).toLocaleDateString();
var todayDate = new Date().toLocaleDateString();
if (new Date(todayDate).getTime() > new Date(noteDate).getTime()) $note.addClass('overdue');

//remove the coloring if its in a list with "done" or "complete"
var listTitle = $note.closest('.list, .head').find('.text').attr('_text');
if (listTitle.toLowerCase().includes("done") || listTitle.toLowerCase().includes("complete"))
$note.removeClass('overdue')
});
});

Expand Down Expand Up @@ -3372,6 +3387,16 @@ <h3>Auto-backup</h3>
list.notes.forEach(function(n){
var $n = $ndiv.clone();
setText( $n.find('.text'), n.text );

//Search for overdue dates and highlight them red via a new class 'overdue'
var noteDate = new Date(n.text.substring(0, n.text.indexOf(']')).split('[').pop().split(']')[0]).toLocaleDateString();
var todayDate = new Date().toLocaleDateString();
if (new Date(todayDate).getTime() > new Date(noteDate).getTime()) $n.addClass('overdue');

//remove the coloring if its in a list with "done" or "complete"
if (list.title.toLowerCase().includes("done") || list.title.toLowerCase().includes("complete"))
$n.removeClass('overdue')

if (n.raw) $n.addClass('raw');
if (n.min) $n.addClass('collapsed');
$l_notes.append($n);
Expand Down Expand Up @@ -4157,6 +4182,14 @@ <h3>Auto-backup</h3>
if ($item.parent().hasClass('board'))
NB.board.title = text_now;

//Search for overdue dates and highlight them red via a new class 'overdue' (when editing a note)
var noteDate = new Date(text_now.substring(0, text_now.indexOf(']')).split('[').pop().split(']')[0]).toLocaleDateString();
var todayDate = new Date().toLocaleDateString();
if (new Date(todayDate).getTime() > new Date(noteDate).getTime())
$item.addClass('overdue');
else
$item.removeClass('overdue');

updatePageTitle();
saveBoard();
}
Expand Down Expand Up @@ -4704,6 +4737,45 @@ <h3>Auto-backup</h3>
return false;
}

// ctrl + d for auto due date insert (any date in the [] will update the note ui if past due -- defaults to today)
if (isNote && ev.ctrlKey && ev.keyCode == '68')
{
var have = this.value;
var want = '[' + new Date().toLocaleDateString() + '] ' + have;
$this.val(want);
this.selectionStart = this.selectionEnd = this.value.length;
return false;
}

// ctrl + s for auto stamp date (stamps the current date and will not affect note ui if past due)
if (isNote && ev.ctrlKey && ev.keyCode == '83')
{
var have = this.value;
var want = new Date().toLocaleDateString() + ': ' + have;
$this.val(want);
this.selectionStart = this.selectionEnd = this.value.length;
return false;
}

// ctrl + x to delete note
if (isNote && ev.ctrlKey && ev.keyCode == '88')
{
stopEditing($this, false, false);
deleteNote( $(this).closest('.note') );
return false;
}

// alt/option + rightarrow to tab
if (isNote && ev.altKey && ev.key == 'ArrowRight')
{
var have = this.value;
var pos = this.selectionStart;
var want = have.substr(0, pos) + '\u0009' + have.substr(this.selectionEnd);
$this.val(want);
this.selectionStart = this.selectionEnd = pos + 1;
return false;
}

// tab
if (ev.keyCode == 9)
{
Expand Down Expand Up @@ -4779,7 +4851,7 @@ <h3>Auto-backup</h3>
}

// ctrl-shift-8
if (isNote && ev.key == '*' && ev.ctrlKey)
if (isNote && ev.key == '*' && ev.ctrlKey || isNote && ev.key == '8' && ev.metaKey && ev.shiftKey)
{
var have = this.value;
var pos = this.selectionStart;
Expand Down