migrate a bunch of xhrPost invocations

This commit is contained in:
Andrew Dolgov 2021-02-19 11:28:14 +03:00
parent 6b43b788d9
commit bb4e4282f4
12 changed files with 64 additions and 74 deletions

View File

@ -165,8 +165,8 @@ class Pref_System extends Handler_Administrative {
<script type='dojo/method' event='onSelected' args='evt'> <script type='dojo/method' event='onSelected' args='evt'>
if (this.domNode.querySelector('.loading')) if (this.domNode.querySelector('.loading'))
window.setTimeout(() => { window.setTimeout(() => {
xhrPost("backend.php", {op: 'pref-system', method: 'getphpinfo'}, (transport) => { xhr.post("backend.php", {op: 'pref-system', method: 'getphpinfo'}, (reply) => {
this.attr('content', `<div class='phpinfo'>${transport.responseText}</div>`); this.attr('content', `<div class='phpinfo'>${reply}</div>`);
}); });
}, 200); }, 200);
</script> </script>

View File

@ -2,7 +2,7 @@
/* eslint-disable new-cap */ /* eslint-disable new-cap */
/* global __, Article, Headlines, Filters, fox */ /* global __, Article, Headlines, Filters, fox */
/* global xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, Feeds, Cookie */ /* global xhrPost, xhr, dojo, dijit, PluginHost, Notify, Feeds, Cookie */
/* global CommonDialogs, Plugins */ /* global CommonDialogs, Plugins */
const App = { const App = {
@ -362,10 +362,10 @@ const App = {
} }
}, },
hotkeyHelp: function() { hotkeyHelp: function() {
xhrPost("backend.php", {op: "rpc", method: "hotkeyHelp"}, (transport) => { xhr.post("backend.php", {op: "rpc", method: "hotkeyHelp"}, (reply) => {
const dialog = new fox.SingleUseDialog({ const dialog = new fox.SingleUseDialog({
title: __("Keyboard shortcuts"), title: __("Keyboard shortcuts"),
content: transport.responseText, content: reply,
}); });
dialog.show(); dialog.show();
@ -474,11 +474,9 @@ const App = {
PluginHost.run(PluginHost.HOOK_RUNTIME_INFO_LOADED, data); PluginHost.run(PluginHost.HOOK_RUNTIME_INFO_LOADED, data);
}, },
backendSanityCallback: function(transport) { backendSanityCallback: function(reply) {
const reply = JSON.parse(transport.responseText);
if (!reply) { if (!reply) {
this.Error.fatal(ERRORS[3], {info: transport.responseText}); this.Error.fatal(ERRORS[3]);
return; return;
} }
@ -559,14 +557,14 @@ const App = {
const message = params.message ? params.message : error.toString(); const message = params.message ? params.message : error.toString();
try { try {
xhrPost("backend.php", xhr.post("backend.php",
{op: "rpc", method: "log", {op: "rpc", method: "log",
file: params.filename ? params.filename : error.fileName, file: params.filename ? params.filename : error.fileName,
line: params.lineno ? params.lineno : error.lineNumber, line: params.lineno ? params.lineno : error.lineNumber,
msg: message, msg: message,
context: error.stack}, context: error.stack},
(transport) => { (reply) => {
console.warn("[Error.report] log response", transport.responseText); console.warn("[Error.report] log response", reply);
}); });
} catch (re) { } catch (re) {
console.error("[Error.report] exception while saving logging error on server", re); console.error("[Error.report] exception while saving logging error on server", re);
@ -645,9 +643,9 @@ const App = {
hasSandbox: "sandbox" in document.createElement("iframe") hasSandbox: "sandbox" in document.createElement("iframe")
}; };
xhrPost("backend.php", params, (transport) => { xhr.json("backend.php", params, (reply) => {
try { try {
this.backendSanityCallback(transport); this.backendSanityCallback(reply);
} catch (e) { } catch (e) {
this.Error.report(e); this.Error.report(e);
} }
@ -862,7 +860,7 @@ const App = {
if (article_id) Article.view(article_id); if (article_id) Article.view(article_id);
xhrPost("backend.php", {op: "rpc", method: "setpanelmode", wide: wide ? 1 : 0}); xhr.post("backend.php", {op: "rpc", method: "setpanelmode", wide: wide ? 1 : 0});
}, },
initHotkeyActions: function() { initHotkeyActions: function() {
if (this.is_prefs) { if (this.is_prefs) {
@ -1058,7 +1056,7 @@ const App = {
Headlines.reverse(); Headlines.reverse();
}; };
this.hotkey_actions["feed_toggle_vgroup"] = () => { this.hotkey_actions["feed_toggle_vgroup"] = () => {
xhrPost("backend.php", {op: "rpc", method: "togglepref", key: "VFEED_GROUP_BY_FEED"}, () => { xhr.post("backend.php", {op: "rpc", method: "togglepref", key: "VFEED_GROUP_BY_FEED"}, () => {
Feeds.reloadCurrent(); Feeds.reloadCurrent();
}) })
}; };
@ -1133,7 +1131,7 @@ const App = {
this.hotkey_actions["toggle_combined_mode"] = () => { this.hotkey_actions["toggle_combined_mode"] = () => {
const value = this.isCombinedMode() ? "false" : "true"; const value = this.isCombinedMode() ? "false" : "true";
xhrPost("backend.php", {op: "rpc", method: "setpref", key: "COMBINED_DISPLAY_MODE", value: value}, () => { xhr.post("backend.php", {op: "rpc", method: "setpref", key: "COMBINED_DISPLAY_MODE", value: value}, () => {
this.setInitParam("combined_display_mode", this.setInitParam("combined_display_mode",
!this.getInitParam("combined_display_mode")); !this.getInitParam("combined_display_mode"));
@ -1144,7 +1142,7 @@ const App = {
this.hotkey_actions["toggle_cdm_expanded"] = () => { this.hotkey_actions["toggle_cdm_expanded"] = () => {
const value = this.getInitParam("cdm_expanded") ? "false" : "true"; const value = this.getInitParam("cdm_expanded") ? "false" : "true";
xhrPost("backend.php", {op: "rpc", method: "setpref", key: "CDM_EXPANDED", value: value}, () => { xhr.post("backend.php", {op: "rpc", method: "setpref", key: "CDM_EXPANDED", value: value}, () => {
this.setInitParam("cdm_expanded", !this.getInitParam("cdm_expanded")); this.setInitParam("cdm_expanded", !this.getInitParam("cdm_expanded"));
Headlines.renderAgain(); Headlines.renderAgain();
}); });

View File

@ -1,7 +1,7 @@
'use strict' 'use strict'
/* eslint-disable no-new */ /* eslint-disable no-new */
/* global __, ngettext, App, Headlines, xhrPost, xhrJson, dojo, dijit, PluginHost, Notify, fox */ /* global __, ngettext, App, Headlines, xhr, dojo, dijit, PluginHost, Notify, fox */
const Article = { const Article = {
_scroll_reset_timeout: false, _scroll_reset_timeout: false,
@ -331,13 +331,11 @@ const Article = {
if (this.validate()) { if (this.validate()) {
Notify.progress("Saving article tags...", true); Notify.progress("Saving article tags...", true);
xhrPost("backend.php", this.attr('value'), (transport) => { xhr.json("backend.php", this.attr('value'), (data) => {
try { try {
Notify.close(); Notify.close();
dialog.hide(); dialog.hide();
const data = JSON.parse(transport.responseText);
if (data) { if (data) {
const id = data.id; const id = data.id;

View File

@ -3,7 +3,7 @@
/* eslint-disable new-cap */ /* eslint-disable new-cap */
/* eslint-disable no-new */ /* eslint-disable no-new */
/* global __, dojo, dijit, Notify, App, Feeds, xhrPost, xhrJson, Tables, fox */ /* global __, dojo, dijit, Notify, App, Feeds, xhrPost, xhr, Tables, fox */
/* exported CommonDialogs */ /* exported CommonDialogs */
const CommonDialogs = { const CommonDialogs = {
@ -17,7 +17,7 @@ const CommonDialogs = {
const query = {op: "pref-feeds", method: "removeicon", feed_id: id}; const query = {op: "pref-feeds", method: "removeicon", feed_id: id};
xhrPost("backend.php", query, () => { xhr.post("backend.php", query, () => {
Notify.info("Feed icon removed."); Notify.info("Feed icon removed.");
if (App.isPrefs()) if (App.isPrefs())
@ -180,17 +180,12 @@ const CommonDialogs = {
Element.show("feed_add_spinner"); Element.show("feed_add_spinner");
Element.hide("fadd_error_message"); Element.hide("fadd_error_message");
xhrPost("backend.php", this.attr('value'), (transport) => { xhr.json("backend.php", this.attr('value'), (reply) => {
try { try {
let reply; if (!reply) {
try {
reply = JSON.parse(transport.responseText);
} catch (e) {
Element.hide("feed_add_spinner"); Element.hide("feed_add_spinner");
alert(__("Failed to parse output. This can indicate server timeout and/or network issues. Backend output was logged to browser console.")); alert(__("Failed to parse output. This can indicate server timeout and/or network issues. Backend output was logged to browser console."));
console.log('subscribeToFeed, backend returned:' + transport.responseText);
return; return;
} }
@ -285,7 +280,7 @@ const CommonDialogs = {
ids: sel_rows.toString() ids: sel_rows.toString()
}; };
xhrPost("backend.php", query, () => { xhr.post("backend.php", query, () => {
Notify.close(); Notify.close();
dialog.hide(); dialog.hide();
@ -359,7 +354,7 @@ const CommonDialogs = {
Notify.progress("Loading, please wait...", true); Notify.progress("Loading, please wait...", true);
xhrPost("backend.php", query, () => { xhr.post("backend.php", query, () => {
if (dijit.byId("labelTree")) { if (dijit.byId("labelTree")) {
dijit.byId("labelTree").reload(); dijit.byId("labelTree").reload();
} else { } else {
@ -377,7 +372,7 @@ const CommonDialogs = {
const query = {op: "pref-feeds", quiet: 1, method: "remove", ids: feed_id}; const query = {op: "pref-feeds", quiet: 1, method: "remove", ids: feed_id};
xhrPost("backend.php", query, () => { xhr.post("backend.php", query, () => {
if (App.isPrefs()) { if (App.isPrefs()) {
dijit.byId("feedTree").reload(); dijit.byId("feedTree").reload();
} else { } else {
@ -415,7 +410,7 @@ const CommonDialogs = {
if (this.validate()) { if (this.validate()) {
Notify.progress("Saving data...", true); Notify.progress("Saving data...", true);
xhrPost("backend.php", dialog.attr('value'), () => { xhr.post("backend.php", dialog.attr('value'), () => {
dialog.hide(); dialog.hide();
Notify.close(); Notify.close();

View File

@ -3,7 +3,7 @@
/* eslint-disable no-new */ /* eslint-disable no-new */
/* global __, App, Article, Lists, fox */ /* global __, App, Article, Lists, fox */
/* global xhrPost, dojo, dijit, Notify, Feeds */ /* global xhr, dojo, dijit, Notify, Feeds */
const Filters = { const Filters = {
filterDlgCheckAction: function(sender) { filterDlgCheckAction: function(sender) {
@ -275,7 +275,7 @@ const Filters = {
const query = {op: "pref-filters", method: "remove", ids: this.attr('value').id}; const query = {op: "pref-filters", method: "remove", ids: this.attr('value').id};
xhrPost("backend.php", query, () => { xhr.post("backend.php", query, () => {
const tree = dijit.byId("filterTree"); const tree = dijit.byId("filterTree");
if (tree) tree.reload(); if (tree) tree.reload();
@ -303,7 +303,7 @@ const Filters = {
Notify.progress("Saving data...", true); Notify.progress("Saving data...", true);
xhrPost("backend.php", this.attr('value'), () => { xhr.post("backend.php", this.attr('value'), () => {
dialog.hide(); dialog.hide();
const tree = dijit.byId("filterTree"); const tree = dijit.byId("filterTree");

View File

@ -1,6 +1,6 @@
'use strict' 'use strict'
/* global __, App, Headlines, xhrPost, xhrJson, dojo, dijit, Form, fox, PluginHost, Notify, $$, fox */ /* global __, App, Headlines, xhrPost, xhr, dojo, dijit, fox, PluginHost, Notify, fox */
const Feeds = { const Feeds = {
counters_last_request: 0, counters_last_request: 0,
@ -299,7 +299,7 @@ const Feeds = {
toggleUnread: function() { toggleUnread: function() {
const hide = !App.getInitParam("hide_read_feeds"); const hide = !App.getInitParam("hide_read_feeds");
xhrPost("backend.php", {op: "rpc", method: "setpref", key: "HIDE_READ_FEEDS", value: hide}, () => { xhr.post("backend.php", {op: "rpc", method: "setpref", key: "HIDE_READ_FEEDS", value: hide}, () => {
this.hideOrShowFeeds(hide); this.hideOrShowFeeds(hide);
App.setInitParam("hide_read_feeds", hide); App.setInitParam("hide_read_feeds", hide);
}); });
@ -393,7 +393,7 @@ const Feeds = {
Notify.progress("Marking all feeds as read..."); Notify.progress("Marking all feeds as read...");
xhrPost("backend.php", {op: "feeds", method: "catchupAll"}, () => { xhr.post("backend.php", {op: "feeds", method: "catchupAll"}, () => {
this.requestCounters(true); this.requestCounters(true);
this.reloadCurrent(); this.reloadCurrent();
}); });

View File

@ -1,5 +1,5 @@
/* eslint-disable prefer-rest-params */ /* eslint-disable prefer-rest-params */
/* global __, lib, dijit, define, dojo, CommonDialogs, Notify, Tables, xhrPost, xhrJson, fox, App */ /* global __, lib, dijit, define, dojo, CommonDialogs, Notify, Tables, xhrPost, xhr, fox, App */
define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_base/array", "dojo/cookie"], define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_base/array", "dojo/cookie"],
function (declare, domConstruct, checkBoxTree, array, cookie) { function (declare, domConstruct, checkBoxTree, array, cookie) {
@ -164,14 +164,14 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
resetFeedOrder: function() { resetFeedOrder: function() {
Notify.progress("Loading, please wait..."); Notify.progress("Loading, please wait...");
xhrPost("backend.php", {op: "pref-feeds", method: "feedsortreset"}, () => { xhr.post("backend.php", {op: "pref-feeds", method: "feedsortreset"}, () => {
this.reload(); this.reload();
}); });
}, },
resetCatOrder: function() { resetCatOrder: function() {
Notify.progress("Loading, please wait..."); Notify.progress("Loading, please wait...");
xhrPost("backend.php", {op: "pref-feeds", method: "catsortreset"}, () => { xhr.post("backend.php", {op: "pref-feeds", method: "catsortreset"}, () => {
this.reload(); this.reload();
}); });
}, },
@ -179,7 +179,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
if (confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name))) { if (confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name))) {
Notify.progress("Removing category..."); Notify.progress("Removing category...");
xhrPost("backend.php", {op: "pref-feeds", method: "removeCat", ids: id}, () => { xhr.post("backend.php", {op: "pref-feeds", method: "removeCat", ids: id}, () => {
Notify.close(); Notify.close();
this.reload(); this.reload();
}); });
@ -198,7 +198,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
ids: sel_rows.toString() ids: sel_rows.toString()
}; };
xhrPost("backend.php", query, () => { xhr.post("backend.php", query, () => {
this.reload(); this.reload();
}); });
} }
@ -247,7 +247,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
ids: sel_rows.toString() ids: sel_rows.toString()
}; };
xhrPost("backend.php", query, () => { xhr.post("backend.php", query, () => {
this.reload(); this.reload();
}); });
} }
@ -338,7 +338,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
Notify.progress("Saving data...", true); Notify.progress("Saving data...", true);
xhrPost("backend.php", query, () => { xhr.post("backend.php", query, () => {
dialog.hide(); dialog.hide();
const tree = dijit.byId("feedTree"); const tree = dijit.byId("feedTree");
@ -367,7 +367,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
Notify.progress("Loading, please wait..."); Notify.progress("Loading, please wait...");
xhrPost("backend.php", { op: 'pref-feeds', method: 'renamecat', id: id, title: new_name }, () => { xhr.post("backend.php", { op: 'pref-feeds', method: 'renamecat', id: id, title: new_name }, () => {
this.reload(); this.reload();
}); });
} }
@ -378,7 +378,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
if (title) { if (title) {
Notify.progress("Creating category..."); Notify.progress("Creating category...");
xhrPost("backend.php", {op: "pref-feeds", method: "addCat", cat: title}, () => { xhr.post("backend.php", {op: "pref-feeds", method: "addCat", cat: title}, () => {
Notify.close(); Notify.close();
this.reload(); this.reload();
}); });
@ -393,7 +393,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
if (this.validate()) { if (this.validate()) {
Notify.progress(__("Subscribing to feeds..."), true); Notify.progress(__("Subscribing to feeds..."), true);
xhrPost("backend.php", this.attr('value'), () => { xhr.post("backend.php", this.attr('value'), () => {
Notify.close(); Notify.close();
const tree = dijit.byId("feedTree"); const tree = dijit.byId("feedTree");
@ -478,7 +478,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
ids: sel_rows.toString() ids: sel_rows.toString()
}; };
xhrPost("backend.php", query, () => { xhr.post("backend.php", query, () => {
Notify.close(); Notify.close();
const tree = dijit.byId("feedTree"); const tree = dijit.byId("feedTree");

View File

@ -1,5 +1,5 @@
/* eslint-disable prefer-rest-params */ /* eslint-disable prefer-rest-params */
/* global __, define, lib, dijit, dojo, xhrPost, Notify */ /* global __, define, lib, dijit, dojo, xhr, Notify */
define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) { define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], function (declare, domConstruct) {
@ -99,7 +99,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
resetFilterOrder: function() { resetFilterOrder: function() {
Notify.progress("Loading, please wait..."); Notify.progress("Loading, please wait...");
xhrPost("backend.php", {op: "pref-filters", method: "filtersortreset"}, () => { xhr.post("backend.php", {op: "pref-filters", method: "filtersortreset"}, () => {
this.reload(); this.reload();
}); });
}, },
@ -114,7 +114,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
if (confirm(__("Combine selected filters?"))) { if (confirm(__("Combine selected filters?"))) {
Notify.progress("Joining filters..."); Notify.progress("Joining filters...");
xhrPost("backend.php", {op: "pref-filters", method: "join", ids: rows.toString()}, () => { xhr.post("backend.php", {op: "pref-filters", method: "join", ids: rows.toString()}, () => {
this.reload(); this.reload();
}); });
} }
@ -131,7 +131,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
ids: sel_rows.toString() ids: sel_rows.toString()
}; };
xhrPost("backend.php", query, () => { xhr.post("backend.php", query, () => {
this.reload(); this.reload();
}); });
} }

View File

@ -1,7 +1,7 @@
'use strict'; 'use strict';
/* eslint-disable no-new */ /* eslint-disable no-new */
/* global __, dijit, dojo, Tables, xhrPost, Notify, xhrJson, App, fox */ /* global __, dijit, dojo, Tables, xhrPost, Notify, xhr, App, fox */
const Helpers = { const Helpers = {
AppPasswords: { AppPasswords: {
@ -45,7 +45,7 @@ const Helpers = {
if (confirm(__("This will invalidate all previously generated feed URLs. Continue?"))) { if (confirm(__("This will invalidate all previously generated feed URLs. Continue?"))) {
Notify.progress("Clearing URLs..."); Notify.progress("Clearing URLs...");
xhrPost("backend.php", {op: "pref-feeds", method: "clearKeys"}, () => { xhr.post("backend.php", {op: "pref-feeds", method: "clearKeys"}, () => {
Notify.info("Generated URLs cleared."); Notify.info("Generated URLs cleared.");
}); });
} }
@ -82,7 +82,7 @@ const Helpers = {
Notify.progress("Loading, please wait..."); Notify.progress("Loading, please wait...");
xhrPost("backend.php", {op: "pref-system", method: "clearLog"}, () => { xhr.post("backend.php", {op: "pref-system", method: "clearLog"}, () => {
Helpers.EventLog.refresh(); Helpers.EventLog.refresh();
}); });
} }
@ -108,7 +108,7 @@ const Helpers = {
ids: sel_rows.toString() ids: sel_rows.toString()
}; };
xhrPost("backend.php", query, () => { xhr.post("backend.php", query, () => {
Notify.close(); Notify.close();
dialog.refresh(); dialog.refresh();
}); });
@ -124,7 +124,7 @@ const Helpers = {
const query = {op: "pref-prefs", method: "addprofile", title: dialog.attr('value').newprofile}; const query = {op: "pref-prefs", method: "addprofile", title: dialog.attr('value').newprofile};
xhrPost("backend.php", query, () => { xhr.post("backend.php", query, () => {
Notify.close(); Notify.close();
dialog.refresh(); dialog.refresh();
}); });
@ -194,7 +194,7 @@ const Helpers = {
if (confirm(__("Activate selected profile?"))) { if (confirm(__("Activate selected profile?"))) {
Notify.progress("Loading, please wait..."); Notify.progress("Loading, please wait...");
xhrPost("backend.php", {op: "pref-prefs", method: "activateprofile", id: sel_rows.toString()}, () => { xhr.post("backend.php", {op: "pref-prefs", method: "activateprofile", id: sel_rows.toString()}, () => {
window.location.reload(); window.location.reload();
}); });
} }
@ -217,7 +217,7 @@ const Helpers = {
const dialog = new fox.SingleUseDialog({ const dialog = new fox.SingleUseDialog({
title: __("Customize stylesheet"), title: __("Customize stylesheet"),
apply: function() { apply: function() {
xhrPost("backend.php", this.attr('value'), () => { xhr.post("backend.php", this.attr('value'), () => {
Element.show("css_edit_apply_msg"); Element.show("css_edit_apply_msg");
App.byId("user_css_style").innerText = this.attr('value'); App.byId("user_css_style").innerText = this.attr('value');
}); });
@ -225,7 +225,7 @@ const Helpers = {
execute: function () { execute: function () {
Notify.progress('Saving data...', true); Notify.progress('Saving data...', true);
xhrPost("backend.php", this.attr('value'), () => { xhr.post("backend.php", this.attr('value'), () => {
window.location.reload(); window.location.reload();
}); });
}, },
@ -277,7 +277,7 @@ const Helpers = {
if (confirm(__("Clear stored data for this plugin?"))) { if (confirm(__("Clear stored data for this plugin?"))) {
Notify.progress("Loading, please wait..."); Notify.progress("Loading, please wait...");
xhrPost("backend.php", {op: "pref-prefs", method: "clearplugindata", name: name}, () => { xhr.post("backend.php", {op: "pref-prefs", method: "clearplugindata", name: name}, () => {
Helpers.Prefs.refresh(); Helpers.Prefs.refresh();
}); });
} }

View File

@ -1,5 +1,5 @@
/* eslint-disable prefer-rest-params */ /* eslint-disable prefer-rest-params */
/* global __, define, lib, dijit, dojo, xhrPost, Notify, fox, App */ /* global __, define, lib, dijit, dojo, xhr, Notify, fox, App */
define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/form/DropDownButton"], function (declare, domConstruct) { define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/form/DropDownButton"], function (declare, domConstruct) {
@ -98,7 +98,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f
ids: id, fg: fg, bg: bg, color: color ids: id, fg: fg, bg: bg, color: color
}; };
xhrPost("backend.php", query, () => { xhr.post("backend.php", query, () => {
const tree = dijit.byId("filterTree"); const tree = dijit.byId("filterTree");
if (tree) tree.reload(); // maybe there's labels in there if (tree) tree.reload(); // maybe there's labels in there
}); });
@ -114,7 +114,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f
this.setLabelColor(id, fg_color, bg_color); this.setLabelColor(id, fg_color, bg_color);
this.hide(); this.hide();
xhrPost("backend.php", this.attr('value'), () => { xhr.post("backend.php", this.attr('value'), () => {
const tree = dijit.byId("filterTree"); const tree = dijit.byId("filterTree");
if (tree) tree.reload(); // maybe there's labels in there if (tree) tree.reload(); // maybe there's labels in there
}); });
@ -196,7 +196,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f
ids: labels.toString() ids: labels.toString()
}; };
xhrPost("backend.php", query, () => { xhr.post("backend.php", query, () => {
this.reload(); this.reload();
}); });
} }
@ -217,7 +217,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f
ids: sel_rows.toString() ids: sel_rows.toString()
}; };
xhrPost("backend.php", query, () => { xhr.post("backend.php", query, () => {
this.reload(); this.reload();
}); });
} }

View File

@ -1,7 +1,7 @@
'use strict' 'use strict'
/* global __ */ /* global __ */
/* global xhrPost, xhrJson, dijit, Notify, Tables, App, fox */ /* global xhrPost, xhr, dijit, Notify, Tables, App, fox */
const Users = { const Users = {
reload: function(sort) { reload: function(sort) {
@ -38,7 +38,7 @@ const Users = {
if (this.validate()) { if (this.validate()) {
Notify.progress("Saving data...", true); Notify.progress("Saving data...", true);
xhrPost("backend.php", this.attr('value'), () => { xhr.post("backend.php", this.attr('value'), () => {
dialog.hide(); dialog.hide();
Users.reload(); Users.reload();
}); });
@ -160,7 +160,7 @@ const Users = {
ids: sel_rows.toString() ids: sel_rows.toString()
}; };
xhrPost("backend.php", query, () => { xhr.post("backend.php", query, () => {
this.reload(); this.reload();
}); });
} }

View File

@ -140,7 +140,6 @@ String.prototype.stripTags = function() {
} }
/* exported xhr */ /* exported xhr */
const xhr = { const xhr = {
post: function(url, params = {}, complete = undefined) { post: function(url, params = {}, complete = undefined) {
console.log('xhr.post', '>>>', params); console.log('xhr.post', '>>>', params);