added jump to note functionality

This commit is contained in:
azivner 2017-09-03 21:34:30 -04:00
parent f063d12d07
commit a54207dc07
3 changed files with 56 additions and 16 deletions

View file

@ -109,7 +109,18 @@
<input id="linkTitle" style="width: 100%;">
</div>
<button id="addLinkButton" class="btn btn-sm">Add link</button>
<button class="btn btn-sm">Add link</button>
</form>
</div>
<div id="jumpToNoteDialog" title="Jumpt to note" style="display: none;">
<form id="jumpToNoteForm">
<div class="form-group">
<label for="jumpToNoteAutocomplete">Jump to note</label>
<input id="jumpToNoteAutocomplete" style="width: 100%;">
</div>
<button class="btn btn-sm">Jump</button>
</form>
</div>

View file

@ -84,8 +84,6 @@ function html2notecase(contents, note) {
const linkMatch = /^<a[^>]+?href="([^"]+?)"[^>]*?>([^<]+?)<\/a>/.exec(curContent);
if (linkMatch !== null) {
console.log("matched link: ", linkMatch);
const targetUrl = linkMatch[1];
const linkText = linkMatch[2];

View file

@ -107,6 +107,21 @@ function getNodeIdFromLabel(label) {
return null;
}
function getAutocompleteItems() {
const autocompleteItems = [];
for (const noteId of globalAllNoteIds) {
const fullName = getFullName(noteId);
autocompleteItems.push({
value: fullName + " (" + noteId + ")",
label: fullName
});
}
return autocompleteItems;
}
$(document).bind('keydown', 'alt+l', function() {
$("#noteAutocomplete").val('');
$("#linkTitle").val('');
@ -119,17 +134,6 @@ $(document).bind('keydown', 'alt+l', function() {
width: 500
});
let autocompleteItems = [];
for (const noteId of globalAllNoteIds) {
let fullName = getFullName(noteId);
autocompleteItems.push({
value: fullName + " (" + noteId + ")",
label: fullName
});
}
function setDefaultLinkTitle(noteId) {
const note = getNodeByKey(noteId);
if (!note) {
@ -146,7 +150,7 @@ $(document).bind('keydown', 'alt+l', function() {
}
$("#noteAutocomplete").autocomplete({
source: autocompleteItems,
source: getAutocompleteItems(),
minLength: 0,
change: function () {
const val = $("#noteAutocomplete").val();
@ -166,7 +170,7 @@ $(document).bind('keydown', 'alt+l', function() {
});
});
$("#insertLinkForm").submit(function addLink() {
$("#insertLinkForm").submit(function() {
let val = $("#noteAutocomplete").val();
const noteId = getNodeIdFromLabel(val);
@ -200,4 +204,31 @@ $(document).bind('keydown', 'alt+t', function() {
date.getHours() + ":" + date.getMinutes();
$('#noteDetail').summernote('insertText', dateString);
});
$(document).bind('keydown', 'alt+j', function() {
$("#jumpToNoteAutocomplete").val('');
$("#jumpToNoteDialog").dialog({
modal: true,
width: 500
});
$("#jumpToNoteAutocomplete").autocomplete({
source: getAutocompleteItems(),
minLength: 0
});
});
$("#jumpToNoteForm").submit(function() {
const val = $("#jumpToNoteAutocomplete").val();
const noteId = getNodeIdFromLabel(val);
if (noteId) {
getNodeByKey(noteId).setActive();
$("#jumpToNoteDialog").dialog('close');
}
return false;
});