From 2692ca14caa2b5de1a84c4019722da41b754fa22 Mon Sep 17 00:00:00 2001 From: azivner Date: Tue, 22 Aug 2017 21:32:03 -0400 Subject: [PATCH] noteId is now in the URL hash. When this is present during notecase startup, then this note will be loaded --- TODO | 2 ++ static/js/note.js | 2 ++ static/js/tree.js | 8 +++++--- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/TODO b/TODO index 79bd283e6..973db8640 100644 --- a/TODO +++ b/TODO @@ -1,5 +1,7 @@ - when loading the app, open last viewed note - link to individual notes (and changing the URL to current one, probably through # anchor) +- logout detection +- conflict detection Later: - drag and drop for notes (currently only keyboard) diff --git a/static/js/note.js b/static/js/note.js index 8202f18c3..00764a6f0 100644 --- a/static/js/note.js +++ b/static/js/note.js @@ -157,6 +157,8 @@ function loadNote(noteId) { $('#noteDetail').summernote('code', noteText); + document.location.hash = noteId; + $(window).resize(); // to trigger resizing of editor noteChangeDisabled = false; diff --git a/static/js/tree.js b/static/js/tree.js index de65e7d51..8b9cbd8c0 100644 --- a/static/js/tree.js +++ b/static/js/tree.js @@ -1,7 +1,11 @@ $(function(){ $.get(baseUrl + 'tree').then(resp => { const notes = resp.notes; - const startNoteId = resp.start_note_id; + let startNoteId = resp.start_note_id; + + if (document.location.hash) { + startNoteId = document.location.hash.substr(1); // strip initial # + } function copyTitle(notes) { for (let note of notes) { @@ -52,8 +56,6 @@ $(function(){ setExpanded(data.node.key, false); }, init: function(event, data) { - console.log("Activating..."); - if (startNoteId) { data.tree.activateKey(startNoteId); }