converted event log to module

This commit is contained in:
azivner 2017-11-04 14:02:43 -04:00
parent 1d0e96a314
commit fd48a97c6d
2 changed files with 38 additions and 32 deletions

View File

@ -1,5 +1,9 @@
async function showEventLog() { const eventLog = (function() {
$("#event-log-dialog").dialog({ const dialogEl = $("#event-log-dialog");
const listEl = $("#event-log-list");
async function showDialog() {
dialogEl.dialog({
modal: true, modal: true,
width: 800, width: 800,
height: 700 height: 700
@ -11,8 +15,7 @@ async function showEventLog() {
error: () => error("Error getting event log.") error: () => error("Error getting event log.")
}); });
const eventLogList = $("#event-log-list"); listEl.html('');
eventLogList.html('');
for (const event of result) { for (const event of result) {
const dateTime = formatDateTime(getDateFromTS(event.date_added)); const dateTime = formatDateTime(getDateFromTS(event.date_added));
@ -23,19 +26,22 @@ async function showEventLog() {
text: getFullName(event.note_id) text: getFullName(event.note_id)
}).prop('outerHTML'); }).prop('outerHTML');
console.log(noteLink);
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 => { $(document).on('click', '#event-log-dialog a', e => {
goToInternalNote(e, () => { goToInternalNote(e, () => {
$("#event-log-dialog").dialog('close'); dialogEl.dialog('close');
}); });
}); });
return {
showDialog
};
})();

View File

@ -15,7 +15,7 @@
<button class="btn btn-xs" onclick="recentChanges.showDialog();">Recent changes</button> <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="recentNotes.showDialog();">Recent notes</button>
<button class="btn btn-xs" onclick="jumpToNote.showDialog();">Jump to note</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>
<div> <div>