diff --git a/src/templates/app.html b/src/templates/app.html index 9f3262775..ec08d7725 100644 --- a/src/templates/app.html +++ b/src/templates/app.html @@ -109,7 +109,18 @@ - + + + + +
diff --git a/static/js/html2notecase.js b/static/js/html2notecase.js index e8e4c230e..ada8f6aee 100644 --- a/static/js/html2notecase.js +++ b/static/js/html2notecase.js @@ -84,8 +84,6 @@ function html2notecase(contents, note) { const linkMatch = /^]+?href="([^"]+?)"[^>]*?>([^<]+?)<\/a>/.exec(curContent); if (linkMatch !== null) { - console.log("matched link: ", linkMatch); - const targetUrl = linkMatch[1]; const linkText = linkMatch[2]; diff --git a/static/js/init.js b/static/js/init.js index e5fde4b7c..812c0d943 100644 --- a/static/js/init.js +++ b/static/js/init.js @@ -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; }); \ No newline at end of file