mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 18:36:30 +01:00 
			
		
		
		
	basic functionality of history now working
This commit is contained in:
		| @@ -44,7 +44,7 @@ def updateNote(note_id): | |||||||
|  |  | ||||||
|     now = math.floor(time.time()) |     now = math.floor(time.time()) | ||||||
|  |  | ||||||
|     history_cutoff = now - 3600 |     history_cutoff = now - 600 | ||||||
|  |  | ||||||
|     history = getSingleResult("select id from notes_history where note_id = ? and date_modified >= ?", [note_id, history_cutoff]) |     history = getSingleResult("select id from notes_history where note_id = ? and date_modified >= ?", [note_id, history_cutoff]) | ||||||
|  |  | ||||||
|   | |||||||
| @@ -173,10 +173,13 @@ | |||||||
|  |  | ||||||
|     <div id="noteHistoryDialog" title="Note history" style="display: none;"> |     <div id="noteHistoryDialog" title="Note history" style="display: none;"> | ||||||
|       <div style="display: flex;"> |       <div style="display: flex;"> | ||||||
|         <select id="noteHistoryList" size="25" style="flex-grow: 1;"> |         <select id="noteHistoryList" size="25" style="flex-grow: 1; height: 630px;"> | ||||||
|         </select> |         </select> | ||||||
|  |  | ||||||
|         <div id="noteHistoryContent" style="flex-grow: 3;"> |         <div id="noteHistoryContentWrapper" style="flex-grow: 3; margin-left: 20px;"> | ||||||
|  |           <h1 id="noteHistoryTitle" style="margin-top: 5px;"></h1> | ||||||
|  |  | ||||||
|  |           <div id="noteHistoryContent"></div> | ||||||
|         </div> |         </div> | ||||||
|       </div> |       </div> | ||||||
|     </div> |     </div> | ||||||
|   | |||||||
| @@ -20,14 +20,14 @@ $(function() { | |||||||
| jQuery.hotkeys.options.filterInputAcceptingElements = true; | jQuery.hotkeys.options.filterInputAcceptingElements = true; | ||||||
| jQuery.hotkeys.options.filterContentEditable = true; | jQuery.hotkeys.options.filterContentEditable = true; | ||||||
|  |  | ||||||
| // $(document).bind('keydown', 'alt+h', function() { | $(document).bind('keydown', 'alt+m', function() { | ||||||
| //     const toggle = $(".hide-toggle"); |     const toggle = $(".hide-toggle"); | ||||||
| //     const hidden = toggle.css('display') === 'none'; |     const hidden = toggle.css('display') === 'none'; | ||||||
| // |  | ||||||
| //     toggle.css('display', hidden ? 'block' : 'none'); |     toggle.css('display', hidden ? 'block' : 'none'); | ||||||
| // |  | ||||||
| //     $("#noteDetailWrapper").css("width", hidden ? "750px" : "100%"); |     $("#noteDetailWrapper").css("width", hidden ? "750px" : "100%"); | ||||||
| // }); | }); | ||||||
|  |  | ||||||
| $(document).bind('keydown', 'alt+s', function() { | $(document).bind('keydown', 'alt+s', function() { | ||||||
|     $("input[name=search]").focus(); |     $("input[name=search]").focus(); | ||||||
|   | |||||||
| @@ -1,3 +1,5 @@ | |||||||
|  | let globalHistoryItems = null; | ||||||
|  |  | ||||||
| $(document).bind('keydown', 'alt+h', function() { | $(document).bind('keydown', 'alt+h', function() { | ||||||
|     $("#noteHistoryDialog").dialog({ |     $("#noteHistoryDialog").dialog({ | ||||||
|         modal: true, |         modal: true, | ||||||
| @@ -12,17 +14,31 @@ $(document).bind('keydown', 'alt+h', function() { | |||||||
|         url: baseUrl + 'notes-history/' + globalCurrentNote.detail.note_id, |         url: baseUrl + 'notes-history/' + globalCurrentNote.detail.note_id, | ||||||
|         type: 'GET', |         type: 'GET', | ||||||
|         success: function (result) { |         success: function (result) { | ||||||
|             if (result.length > 0) { |             globalHistoryItems = result; | ||||||
|                 $("#noteHistoryContent").html(result[0]["note_text"]); |  | ||||||
|  |             for (const row of result) { | ||||||
|  |                 const dateModified = new Date(row.date_modified * 1000); | ||||||
|  |  | ||||||
|  |                 $("#noteHistoryList").append($('<option>', { | ||||||
|  |                     value: row.id, | ||||||
|  |                     text: formatDate(dateModified) | ||||||
|  |                 })); | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             for (row of result) { |             if (result.length > 0) { | ||||||
|                 const dateModified = new Date(row['date_modified'] * 1000); |                 const firstOptionValue = $("#noteHistoryList option:first").val(); | ||||||
|                 const optionHtml = '<option value="' + row['note_id'] + '">' + formatDate(dateModified) + '</option>'; |  | ||||||
|  |  | ||||||
|                 $("#noteHistoryList").append(optionHtml); |                 $("#noteHistoryList").val(firstOptionValue).trigger('change'); | ||||||
|             } |             } | ||||||
|         }, |         }, | ||||||
|         error: () => alert("Error getting note history.") |         error: () => alert("Error getting note history.") | ||||||
|     }); |     }); | ||||||
| }); | }); | ||||||
|  |  | ||||||
|  | $("#noteHistoryList").on('change', () => { | ||||||
|  |     const optVal = $("#noteHistoryList").find(":selected").val(); | ||||||
|  |     const historyItem = globalHistoryItems.find(r => r.id == optVal); // non-strict comparison is important here!!!s | ||||||
|  |  | ||||||
|  |     $("#noteHistoryTitle").html(historyItem.note_title); | ||||||
|  |     $("#noteHistoryContent").html(historyItem.note_text); | ||||||
|  | }); | ||||||
		Reference in New Issue
	
	Block a user