From 58e54282d36d54c2be0e50f78fbc500772a3b762 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 2 Dec 2018 15:30:07 +0300 Subject: prefs: move more global functions into matching classes --- classes/pref/system.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'classes/pref/system.php') diff --git a/classes/pref/system.php b/classes/pref/system.php index 2099ebb9c..f86fc7b0b 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -26,7 +26,7 @@ class Pref_System extends Handler_Protected { function index() { print "
"; - print "
"; + print "
"; if (LOG_DESTINATION == "sql") { @@ -40,7 +40,7 @@ class Pref_System extends Handler_Protected { onclick=\"updateSystemList()\">".__('Refresh')." "; print "  "; + class=\"btn-danger\" onclick=\"Prefs.clearEventLog()\">".__('Clear')." "; print "

"; -- cgit v1.2.3-54-g00ecf From 3a6dae92034791c199f9ddb4c60b8298b22c1d47 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 2 Dec 2018 16:29:00 +0300 Subject: prefs: more of the same, really --- classes/pref/system.php | 2 +- js/PrefFilterTree.js | 20 +++++++++++++++----- js/PrefLabelTree.js | 14 ++++++++++---- js/functions.js | 4 ++-- js/prefs.js | 36 ++++++++++-------------------------- 5 files changed, 38 insertions(+), 38 deletions(-) (limited to 'classes/pref/system.php') diff --git a/classes/pref/system.php b/classes/pref/system.php index f86fc7b0b..17dfb10ca 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -37,7 +37,7 @@ class Pref_System extends Handler_Protected { LIMIT 100"); print " "; + onclick=\"Prefs.updateEventLog()\">".__('Refresh')." "; print "  "; diff --git a/js/PrefFilterTree.js b/js/PrefFilterTree.js index 9940372dd..37a99be89 100644 --- a/js/PrefFilterTree.js +++ b/js/PrefFilterTree.js @@ -86,11 +86,21 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio return rv; }, + reload: function() { + const user_search = $("filter_search"); + let search = ""; + if (user_search) { search = user_search.value; } + + xhrPost("backend.php", { op: "pref-filters", search: search }, (transport) => { + dijit.byId('filterConfigTab').attr('content', transport.responseText); + notify(""); + }); + }, resetFilterOrder: function() { notify_progress("Loading, please wait..."); xhrPost("backend.php", {op: "pref-filters", method: "filtersortreset"}, () => { - updateFilterList(); + this.reload(); }); }, joinSelectedFilters: function() { @@ -105,7 +115,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio notify_progress("Joining filters..."); xhrPost("backend.php", {op: "pref-filters", method: "join", ids: rows.toString()}, () => { - updateFilterList(); + this.reload(); }); } }, @@ -187,7 +197,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio const query = {op: "pref-filters", method: "remove", ids: this.attr('value').id}; xhrPost("backend.php", query, () => { - updateFilterList(); + dijit.byId("filterTree").reload(); }); } }, @@ -214,7 +224,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio xhrPost("backend.php", dojo.formToObject("filter_edit_form"), () => { dialog.hide(); - updateFilterList(); + dijit.byId("filterTree").reload(); }); } }, @@ -236,7 +246,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio }; xhrPost("backend.php", query, () => { - updateFilterList(); + this.reload(); }); } } else { diff --git a/js/PrefLabelTree.js b/js/PrefLabelTree.js index ba052eb07..45edb34a1 100644 --- a/js/PrefLabelTree.js +++ b/js/PrefLabelTree.js @@ -48,6 +48,12 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f return rv; }, + reload: function() { + xhrPost("backend.php", { op: "pref-labels" }, (transport) => { + dijit.byId('labelConfigTab').attr('content', transport.responseText); + notify(""); + }); + }, editLabel: function(id) { const query = "backend.php?op=pref-labels&method=edit&id=" + param_escape(id); @@ -87,7 +93,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f }; xhrPost("backend.php", query, () => { - updateFilterList(); // maybe there's labels in there + dijit.byId("filterTree").reload(); // maybe there's labels in there }); }, @@ -102,7 +108,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f this.hide(); xhrPost("backend.php", this.attr('value'), () => { - updateFilterList(); // maybe there's labels in there + dijit.byId("filterTree").reload(); // maybe there's labels in there }); } }, @@ -123,7 +129,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f }; xhrPost("backend.php", query, () => { - updateLabelList(); + this.reload(); }); } @@ -144,7 +150,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f }; xhrPost("backend.php", query, () => { - updateLabelList(); + this.reload(); }); } } else { diff --git a/js/functions.js b/js/functions.js index 673e0e8f1..3a9a26f9b 100755 --- a/js/functions.js +++ b/js/functions.js @@ -739,7 +739,7 @@ const CommonDialogs = { if (callback) { callback(transport); } else if (App.isPrefs()) { - updateLabelList(); + dijit.byId("labelTree").reload(); } else { Feeds.reload(); } @@ -1442,7 +1442,7 @@ const Filters = { xhrPost("backend.php", query, () => { if (App.isPrefs()) { - updateFilterList(); + dijit.byId("filterTree").reload(); } dialog.hide(); diff --git a/js/prefs.js b/js/prefs.js index 2245f518f..771120048 100755 --- a/js/prefs.js +++ b/js/prefs.js @@ -131,6 +131,7 @@ const App = { } }; +// noinspection JSUnusedGlobalSymbols const Prefs = { clearFeedAccessKeys: function() { if (confirm(__("This will invalidate all previously generated feed URLs. Continue?"))) { @@ -143,13 +144,19 @@ const Prefs = { return false; }, + updateEventLog: function() { + xhrPost("backend.php", { op: "pref-system" }, (transport) => { + dijit.byId('systemConfigTab').attr('content', transport.responseText); + notify(""); + }); + }, clearEventLog: function() { if (confirm(__("Clear event log?"))) { notify_progress("Loading, please wait..."); xhrPost("backend.php", {op: "pref-system", method: "clearLog"}, () => { - updateSystemList(); + this.updateEventLog(); }); } }, @@ -160,6 +167,7 @@ const Prefs = { const query = "backend.php?op=pref-prefs&method=editPrefProfiles"; + // noinspection JSUnusedGlobalSymbols const dialog = new dijit.Dialog({ id: "profileEditDlg", title: __("Settings Profiles"), @@ -275,6 +283,7 @@ const Prefs = { } }; +// noinspection JSUnusedGlobalSymbols const Users = { reload: function(sort) { const user_search = $("user_search"); @@ -434,31 +443,6 @@ function opmlImport() { } } -function updateFilterList() { - const user_search = $("filter_search"); - let search = ""; - if (user_search) { search = user_search.value; } - - xhrPost("backend.php", { op: "pref-filters", search: search }, (transport) => { - dijit.byId('filterConfigTab').attr('content', transport.responseText); - notify(""); - }); -} - -function updateLabelList() { - xhrPost("backend.php", { op: "pref-labels" }, (transport) => { - dijit.byId('labelConfigTab').attr('content', transport.responseText); - notify(""); - }); -} - -function updateSystemList() { - xhrPost("backend.php", { op: "pref-system" }, (transport) => { - dijit.byId('systemConfigTab').attr('content', transport.responseText); - notify(""); - }); -} - function opmlRegenKey() { if (confirm(__("Replace current OPML publishing address with a new one?"))) { notify_progress("Trying to change address...", true); -- cgit v1.2.3-54-g00ecf From 4d4034091af3d5f7308cc794cf38f654bbe3083f Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 3 Dec 2018 12:46:00 +0300 Subject: prefs: Prefs global -> Helpers --- classes/dlg.php | 2 +- classes/pref/feeds.php | 8 ++++---- classes/pref/prefs.php | 10 +++++----- classes/pref/system.php | 4 ++-- js/PrefHelpers.js | 17 ++++++++--------- js/prefs.js | 2 +- 6 files changed, 21 insertions(+), 22 deletions(-) (limited to 'classes/pref/system.php') diff --git a/classes/dlg.php b/classes/dlg.php index 6617dfe07..7ac18bb90 100644 --- a/classes/dlg.php +++ b/classes/dlg.php @@ -49,7 +49,7 @@ class Dlg extends Handler_Protected { print "
"; - print " "; print ""; print ""; @@ -1295,7 +1295,7 @@ class Pref_Feeds extends Handler_Protected { print "
"; print ""; print "
"; - print " "; - print ""; print " "; @@ -756,7 +756,7 @@ class Pref_Prefs extends Handler_Protected { if (count($tmppluginhost->get_all($plugin)) > 0) { if (in_array($name, $system_enabled)) { - print "
"; } } @@ -816,7 +816,7 @@ class Pref_Prefs extends Handler_Protected { if (count($tmppluginhost->get_all($plugin)) > 0) { if (in_array($name, $system_enabled) || in_array($name, $user_enabled)) { - print ""; + print ""; } } diff --git a/classes/pref/system.php b/classes/pref/system.php index 17dfb10ca..d60b419cf 100644 --- a/classes/pref/system.php +++ b/classes/pref/system.php @@ -37,10 +37,10 @@ class Pref_System extends Handler_Protected { LIMIT 100"); print " "; + onclick=\"Helpers.updateEventLog()\">".__('Refresh')." "; print "  "; + class=\"btn-danger\" onclick=\"Helpers.clearEventLog()\">".__('Clear')." "; print "

".__("Clear data")."".__("Clear data")."".__("Clear data")."
"; diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js index df42547b2..e4ffb04ef 100644 --- a/js/PrefHelpers.js +++ b/js/PrefHelpers.js @@ -1,5 +1,5 @@ define(["dojo/_base/declare"], function (declare) { - Prefs = { + Helpers = { clearFeedAccessKeys: function() { if (confirm(__("This will invalidate all previously generated feed URLs. Continue?"))) { Notify.progress("Clearing URLs..."); @@ -56,7 +56,7 @@ define(["dojo/_base/declare"], function (declare) { xhrPost("backend.php", query, () => { Notify.close(); - Prefs.editProfiles(); + Helpers.editProfiles(); }); } @@ -88,7 +88,7 @@ define(["dojo/_base/declare"], function (declare) { xhrPost("backend.php", query, () => { Notify.close(); - Prefs.editProfiles(); + Helpers.editProfiles(); }); } @@ -128,7 +128,7 @@ define(["dojo/_base/declare"], function (declare) { confirmReset: function() { if (confirm(__("Reset to defaults?"))) { xhrPost("backend.php", {op: "pref-prefs", method: "resetconfig"}, (transport) => { - Prefs.refresh(); + Helpers.refresh(); Notify.info(transport.responseText); }); } @@ -138,7 +138,7 @@ define(["dojo/_base/declare"], function (declare) { Notify.progress("Loading, please wait..."); xhrPost("backend.php", {op: "pref-prefs", method: "clearplugindata", name: name}, () => { - Prefs.refresh(); + Helpers.refresh(); }); } }, @@ -150,7 +150,7 @@ define(["dojo/_base/declare"], function (declare) { } }; - Prefs.OPML = { + Helpers.OPML = { import: function() { const opml_file = $("opml_file"); @@ -225,8 +225,7 @@ define(["dojo/_base/declare"], function (declare) { } return false; }, + }; -}; - - return Prefs; + return Helpers; }); diff --git a/js/prefs.js b/js/prefs.js index 4bdfb45ef..dafdbcdee 100755 --- a/js/prefs.js +++ b/js/prefs.js @@ -5,7 +5,7 @@ let App; let CommonDialogs; let Filters; let Users; -let Prefs; +let Helpers; const Plugins = {}; -- cgit v1.2.3-54-g00ecf