From 6d82a0e03f09b1fe819b829a7d4045157db22b75 Mon Sep 17 00:00:00 2001 From: azivner Date: Sat, 4 Nov 2017 13:39:26 -0400 Subject: [PATCH] converted recent changes to module --- public/javascripts/recent_changes.js | 134 ++++++++++++++------------- public/javascripts/recent_notes.js | 53 ++++++----- public/javascripts/tree_mutations.js | 3 +- views/index.ejs | 4 +- 4 files changed, 102 insertions(+), 92 deletions(-) diff --git a/public/javascripts/recent_changes.js b/public/javascripts/recent_changes.js index 246e10d60..05fe01273 100644 --- a/public/javascripts/recent_changes.js +++ b/public/javascripts/recent_changes.js @@ -1,86 +1,92 @@ -const recentChangesDialog = $("#recent-changes-dialog"); +const recentChanges = (function() { + const dialog = $("#recent-changes-dialog"); -async function showRecentChanges() { - recentChangesDialog.dialog({ - modal: true, - width: 800, - height: 700 - }); + async function showDialog() { + dialog.dialog({ + modal: true, + width: 800, + height: 700 + }); - const result = await $.ajax({ - url: baseApiUrl + 'recent-changes/', - type: 'GET', - error: () => error("Error getting recent changes.") - }); + const result = await $.ajax({ + url: baseApiUrl + 'recent-changes/', + type: 'GET', + error: () => error("Error getting recent changes.") + }); - recentChangesDialog.html(''); + dialog.html(''); - const groupedByDate = groupByDate(result); + const groupedByDate = groupByDate(result); - for (const [dateDay, dayChanges] of groupedByDate) { - const changesListEl = $('