Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
converted event log to module
azivnerfd48a97c6dd7
diff --git a/public/javascripts/event_log.js b/public/javascripts/event_log.jsindex 8e88821140..bbc7ac8b8e 100644--- a/public/javascripts/event_log.js+++ b/public/javascripts/event_log.js@@ -1,41 +1,47 @@-async function showEventLog() {- $("#event-log-dialog").dialog({- modal: true,- width: 800,- height: 700- });+const eventLog = (function() {+ const dialogEl = $("#event-log-dialog");+ const listEl = $("#event-log-list");- const result = await $.ajax({- url: baseApiUrl + 'event-log',- type: 'GET',- error: () => error("Error getting event log.")- });+ async function showDialog() {+ dialogEl.dialog({+ modal: true,+ width: 800,+ height: 700+ });- const eventLogList = $("#event-log-list");- eventLogList.html('');+ const result = await $.ajax({+ url: baseApiUrl + 'event-log',+ type: 'GET',+ error: () => error("Error getting event log.")+ });- for (const event of result) {- const dateTime = formatDateTime(getDateFromTS(event.date_added));+ listEl.html('');- if (event.note_id) {- const noteLink = $("<a>", {- href: 'app#' + event.note_id,- text: getFullName(event.note_id)- }).prop('outerHTML');+ for (const event of result) {+ const dateTime = formatDateTime(getDateFromTS(event.date_added));- console.log(noteLink);+ if (event.note_id) {+ const noteLink = $("<a>", {+ href: 'app#' + event.note_id,+ text: getFullName(event.note_id)+ }).prop('outerHTML');- event.comment = event.comment.replace('<note>', noteLink);- }+ event.comment = event.comment.replace('<note>', noteLink);+ }- const eventEl = $('<li>').html(dateTime + " - " + event.comment);+ const eventEl = $('<li>').html(dateTime + " - " + event.comment);- eventLogList.append(eventEl);+ listEl.append(eventEl);+ }}-}-$(document).on('click', '#event-log-dialog a', e => {- goToInternalNote(e, () => {- $("#event-log-dialog").dialog('close');+ $(document).on('click', '#event-log-dialog a', e => {+ goToInternalNote(e, () => {+ dialogEl.dialog('close');+ });});-});\ No newline at end of file++ return {+ showDialog+ };+})();\ No newline at end of filediff --git a/views/index.ejs b/views/index.ejsindex 241719ef71..74257a8d5f 100644--- a/views/index.ejs+++ b/views/index.ejs@@ -15,7 +15,7 @@<button class="btn btn-xs" onclick="recentChanges.showDialog();">Recent changes</button><button class="btn btn-xs" onclick="recentNotes.showDialog();">Recent notes</button><button class="btn btn-xs" onclick="jumpToNote.showDialog();">Jump to note</button>- <button class="btn btn-xs" onclick="showEventLog();">Event log</button>+ <button class="btn btn-xs" onclick="eventLog.showDialog();">Event log</button></div><div>