From 394fd6f5274a308946c784451e5e224765126d5e Mon Sep 17 00:00:00 2001 From: azivner Date: Sat, 4 Nov 2017 13:55:46 -0400 Subject: [PATCH] converted note history to module --- public/javascripts/note_history.js | 129 +++++++++++++++------------ public/javascripts/recent_changes.js | 2 +- views/index.ejs | 2 +- 3 files changed, 74 insertions(+), 59 deletions(-) diff --git a/public/javascripts/note_history.js b/public/javascripts/note_history.js index 7764ce89a..a3264cce4 100644 --- a/public/javascripts/note_history.js +++ b/public/javascripts/note_history.js @@ -1,61 +1,76 @@ -glob.historyItems = null; +const noteHistory = (function() { + const dialogEl = $("#note-history-dialog"); + const listEl = $("#note-history-list"); + const contentEl = $("#note-history-content"); + const titleEl = $("#note-history-title"); -function showCurrentNoteHistory() { - showNoteHistoryDialog(glob.currentNote.detail.note_id); -} + let historyItems = []; -function showNoteHistoryDialog(noteId, noteHistoryId) { - $("#note-history-dialog").dialog({ - modal: true, - width: 800, - height: 700 - }); - - $("#note-history-list").empty(); - $("#note-history-content").empty(); - - $.ajax({ - url: baseApiUrl + 'notes-history/' + noteId, - type: 'GET', - success: result => { - glob.historyItems = result; - - for (const row of result) { - const dateModified = getDateFromTS(row.date_modified_to); - - $("#note-history-list").append($('