summaryrefslogtreecommitdiff
path: root/js/App.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-02-19 11:28:14 +0300
committerAndrew Dolgov <[email protected]>2021-02-19 11:28:14 +0300
commitbb4e4282f46824308aebc2eaeac29fa29f8687ad (patch)
tree8355547f2cf4baefc4a41146d27dcbd3240f724a /js/App.js
parent6b43b788d909ce20f07f29f9f3ccd2f6a8715616 (diff)
migrate a bunch of xhrPost invocations
Diffstat (limited to 'js/App.js')
-rw-r--r--js/App.js30
1 files changed, 14 insertions, 16 deletions
diff --git a/js/App.js b/js/App.js
index 0c12c7e6f..1b0fa7c65 100644
--- a/js/App.js
+++ b/js/App.js
@@ -2,7 +2,7 @@
/* eslint-disable new-cap */
/* 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 */
const App = {
@@ -362,10 +362,10 @@ const App = {
}
},
hotkeyHelp: function() {
- xhrPost("backend.php", {op: "rpc", method: "hotkeyHelp"}, (transport) => {
+ xhr.post("backend.php", {op: "rpc", method: "hotkeyHelp"}, (reply) => {
const dialog = new fox.SingleUseDialog({
title: __("Keyboard shortcuts"),
- content: transport.responseText,
+ content: reply,
});
dialog.show();
@@ -474,11 +474,9 @@ const App = {
PluginHost.run(PluginHost.HOOK_RUNTIME_INFO_LOADED, data);
},
- backendSanityCallback: function(transport) {
- const reply = JSON.parse(transport.responseText);
-
+ backendSanityCallback: function(reply) {
if (!reply) {
- this.Error.fatal(ERRORS[3], {info: transport.responseText});
+ this.Error.fatal(ERRORS[3]);
return;
}
@@ -559,14 +557,14 @@ const App = {
const message = params.message ? params.message : error.toString();
try {
- xhrPost("backend.php",
+ xhr.post("backend.php",
{op: "rpc", method: "log",
file: params.filename ? params.filename : error.fileName,
line: params.lineno ? params.lineno : error.lineNumber,
msg: message,
context: error.stack},
- (transport) => {
- console.warn("[Error.report] log response", transport.responseText);
+ (reply) => {
+ console.warn("[Error.report] log response", reply);
});
} catch (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")
};
- xhrPost("backend.php", params, (transport) => {
+ xhr.json("backend.php", params, (reply) => {
try {
- this.backendSanityCallback(transport);
+ this.backendSanityCallback(reply);
} catch (e) {
this.Error.report(e);
}
@@ -862,7 +860,7 @@ const App = {
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() {
if (this.is_prefs) {
@@ -1058,7 +1056,7 @@ const App = {
Headlines.reverse();
};
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();
})
};
@@ -1133,7 +1131,7 @@ const App = {
this.hotkey_actions["toggle_combined_mode"] = () => {
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.getInitParam("combined_display_mode"));
@@ -1144,7 +1142,7 @@ const App = {
this.hotkey_actions["toggle_cdm_expanded"] = () => {
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"));
Headlines.renderAgain();
});