mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-30 18:05:55 +01:00 
			
		
		
		
	added "show recent notes" widget
This commit is contained in:
		| @@ -52,8 +52,11 @@ | |||||||
|       </div> |       </div> | ||||||
|     </div> |     </div> | ||||||
|      |      | ||||||
|     <script src="stat/lib/jquery.js"></script> |     <script src="stat/lib/jquery.min.js"></script> | ||||||
|     <script src="stat/lib/jqueryui/jquery-ui.js"></script> |  | ||||||
|  |     <link href="stat/lib/jqueryui/jquery-ui.min.css" rel="stylesheet"> | ||||||
|  |     <script src="stat/lib/jqueryui/jquery-ui.min.js"></script> | ||||||
|  |  | ||||||
|     <!-- Include Fancytree skin and library --> |     <!-- Include Fancytree skin and library --> | ||||||
|     <link href="stat/lib/fancytree/skin-win8/ui.fancytree.css" rel="stylesheet"> |     <link href="stat/lib/fancytree/skin-win8/ui.fancytree.css" rel="stylesheet"> | ||||||
|     <script src="stat/lib/fancytree/jquery.fancytree-all.js"></script> |     <script src="stat/lib/fancytree/jquery.fancytree-all.js"></script> | ||||||
| @@ -76,6 +79,11 @@ | |||||||
|  |  | ||||||
|     <link href="stat/style.css" rel="stylesheet"> |     <link href="stat/style.css" rel="stylesheet"> | ||||||
|  |  | ||||||
|  |     <div id="recentNotesDialog" title="Recent notes" style="display: none;"> | ||||||
|  |       <select id="recentNotesSelectBox" size="15" style="width: 100%"> | ||||||
|  |         </select> | ||||||
|  |     </div> | ||||||
|  |  | ||||||
|     <script type="text/javascript"> |     <script type="text/javascript"> | ||||||
|       const baseUrl = ''; |       const baseUrl = ''; | ||||||
|     </script> |     </script> | ||||||
|   | |||||||
| @@ -15,3 +15,42 @@ $(document).bind('keypress', 'alt+ctrl+h', function() { | |||||||
|     // use visibility instead of display so that content isn't moved around and stays set in place |     // use visibility instead of display so that content isn't moved around and stays set in place | ||||||
|     toggle.css('visibility', toggle.css('visibility') === 'hidden' ? 'visible' : 'hidden'); |     toggle.css('visibility', toggle.css('visibility') === 'hidden' ? 'visible' : 'hidden'); | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  | $(document).bind('keypress', 'ctrl+e', function() { | ||||||
|  |     $("#recentNotesDialog").dialog({ | ||||||
|  |         modal: true | ||||||
|  |     }); | ||||||
|  |  | ||||||
|  |     let recentNotesSelectBox = $('#recentNotesSelectBox'); | ||||||
|  |  | ||||||
|  |     recentNotesSelectBox.find('option').remove(); | ||||||
|  |  | ||||||
|  |     // remove the current note | ||||||
|  |     let recNotes = recentNotes.slice(1); | ||||||
|  |  | ||||||
|  |     $.each(recNotes, function(key, value) { | ||||||
|  |         let option = $("<option></option>") | ||||||
|  |                 .attr("value", value.noteId) | ||||||
|  |                 .text(value.noteTitle); | ||||||
|  |  | ||||||
|  |         // select the first one (most recent one) by default | ||||||
|  |         if (key === 0) { | ||||||
|  |             option.attr("selected", "selected"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         recentNotesSelectBox.append(option); | ||||||
|  |     }); | ||||||
|  | }); | ||||||
|  |  | ||||||
|  | $('#recentNotesSelectBox').keydown(function(e) { | ||||||
|  |     let key = e.which; | ||||||
|  |  | ||||||
|  |     if (key === 13)// the enter key code | ||||||
|  |     { | ||||||
|  |         let noteId = $("#recentNotesSelectBox option:selected").val(); | ||||||
|  |  | ||||||
|  |         $("#tree").fancytree('getNodeByKey', noteId).setActive(); | ||||||
|  |  | ||||||
|  |         $("#recentNotesDialog").dialog('close'); | ||||||
|  |     } | ||||||
|  | }); | ||||||
| @@ -139,6 +139,8 @@ function createNote(node, parentKey, target) { | |||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | recentNotes = []; | ||||||
|  |  | ||||||
| function loadNote(noteId) { | function loadNote(noteId) { | ||||||
|     $.get(baseUrl + 'notes/' + noteId).then(function(note) { |     $.get(baseUrl + 'notes/' + noteId).then(function(note) { | ||||||
|         globalNote = note; |         globalNote = note; | ||||||
| @@ -161,10 +163,22 @@ function loadNote(noteId) { | |||||||
|  |  | ||||||
|         $(window).resize(); // to trigger resizing of editor |         $(window).resize(); // to trigger resizing of editor | ||||||
|  |  | ||||||
|  |         addRecentNote(noteId, note.detail.note_title); | ||||||
|  |  | ||||||
|         noteChangeDisabled = false; |         noteChangeDisabled = false; | ||||||
|     }); |     }); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | function addRecentNote(noteId, noteTitle) { | ||||||
|  |     // if it's already there, remove the note | ||||||
|  |     recentNotes = recentNotes.filter(note => note.noteId !== noteId); | ||||||
|  |  | ||||||
|  |     recentNotes.unshift({ | ||||||
|  |        noteId: noteId, | ||||||
|  |        noteTitle: noteTitle | ||||||
|  |     }); | ||||||
|  | } | ||||||
|  |  | ||||||
| function encryptNote() { | function encryptNote() { | ||||||
|     let password = prompt("Enter password for encryption"); |     let password = prompt("Enter password for encryption"); | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										4
									
								
								static/lib/jquery.min.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										4
									
								
								static/lib/jquery.min.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							
		Reference in New Issue
	
	Block a user