migrate a bunch of xhrPost invocations

master
Andrew Dolgov 4 years ago
parent 6b43b788d9
commit bb4e4282f4

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

@ -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();
});

@ -1,7 +1,7 @@
'use strict'
/* 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 = {
_scroll_reset_timeout: false,
@ -331,13 +331,11 @@ const Article = {
if (this.validate()) {
Notify.progress("Saving article tags...", true);
xhrPost("backend.php", this.attr('value'), (transport) => {
xhr.json("backend.php", this.attr('value'), (data) => {
try {
Notify.close();
dialog.hide();
const data = JSON.parse(transport.responseText);
if (data) {
const id = data.id;

@ -3,7 +3,7 @@
/* eslint-disable new-cap */
/* 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 */
const CommonDialogs = {
@ -17,7 +17,7 @@ const CommonDialogs = {
const query = {op: "pref-feeds", method: "removeicon", feed_id: id};
xhrPost("backend.php", query, () => {
xhr.post("backend.php", query, () => {
Notify.info("Feed icon removed.");
if (App.isPrefs())
@ -180,17 +180,12 @@ const CommonDialogs = {
Element.show("feed_add_spinner");
Element.hide("fadd_error_message");
xhrPost("backend.php", this.attr('value'), (transport) => {
xhr.json("backend.php", this.attr('value'), (reply) => {
try {
let reply;
try {
reply = JSON.parse(transport.responseText);
} catch (e) {
if (!reply) {
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."));
console.log('subscribeToFeed, backend returned:' + transport.responseText);
return;
}
@ -285,7 +280,7 @@ const CommonDialogs = {
ids: sel_rows.toString()
};
xhrPost("backend.php", query, () => {
xhr.post("backend.php", query, () => {
Notify.close();
dialog.hide();
@ -359,7 +354,7 @@ const CommonDialogs = {
Notify.progress("Loading, please wait...", true);
xhrPost("backend.php", query, () => {
xhr.post("backend.php", query, () => {
if (dijit.byId("labelTree")) {
dijit.byId("labelTree").reload();
} else {
@ -377,7 +372,7 @@ const CommonDialogs = {
const query = {op: "pref-feeds", quiet: 1, method: "remove", ids: feed_id};
xhrPost("backend.php", query, () => {
xhr.post("backend.php", query, () => {
if (App.isPrefs()) {
dijit.byId("feedTree").reload();
} else {
@ -415,7 +410,7 @@ const CommonDialogs = {
if (this.validate()) {
Notify.progress("Saving data...", true);
xhrPost("backend.php", dialog.attr('value'), () => {
xhr.post("backend.php", dialog.attr('value'), () => {
dialog.hide();
Notify.close();

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

@ -1,6 +1,6 @@
'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 = {
counters_last_request: 0,
@ -299,7 +299,7 @@ const Feeds = {
toggleUnread: function() {
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);
App.setInitParam("hide_read_feeds", hide);
});
@ -393,7 +393,7 @@ const Feeds = {
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.reloadCurrent();
});

@ -1,5 +1,5 @@
/* 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"],
function (declare, domConstruct, checkBoxTree, array, cookie) {
@ -164,14 +164,14 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
resetFeedOrder: function() {
Notify.progress("Loading, please wait...");
xhrPost("backend.php", {op: "pref-feeds", method: "feedsortreset"}, () => {
xhr.post("backend.php", {op: "pref-feeds", method: "feedsortreset"}, () => {
this.reload();
});
},
resetCatOrder: function() {
Notify.progress("Loading, please wait...");
xhrPost("backend.php", {op: "pref-feeds", method: "catsortreset"}, () => {
xhr.post("backend.php", {op: "pref-feeds", method: "catsortreset"}, () => {
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))) {
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();
this.reload();
});
@ -198,7 +198,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
ids: sel_rows.toString()
};
xhrPost("backend.php", query, () => {
xhr.post("backend.php", query, () => {
this.reload();
});
}
@ -247,7 +247,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
ids: sel_rows.toString()
};
xhrPost("backend.php", query, () => {
xhr.post("backend.php", query, () => {
this.reload();
});
}
@ -338,7 +338,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
Notify.progress("Saving data...", true);
xhrPost("backend.php", query, () => {
xhr.post("backend.php", query, () => {
dialog.hide();
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...");
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();
});
}
@ -378,7 +378,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
if (title) {
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();
this.reload();
});
@ -393,7 +393,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
if (this.validate()) {
Notify.progress(__("Subscribing to feeds..."), true);
xhrPost("backend.php", this.attr('value'), () => {
xhr.post("backend.php", this.attr('value'), () => {
Notify.close();
const tree = dijit.byId("feedTree");
@ -478,7 +478,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
ids: sel_rows.toString()
};
xhrPost("backend.php", query, () => {
xhr.post("backend.php", query, () => {
Notify.close();
const tree = dijit.byId("feedTree");

@ -1,5 +1,5 @@
/* 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) {
@ -99,7 +99,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
resetFilterOrder: function() {
Notify.progress("Loading, please wait...");
xhrPost("backend.php", {op: "pref-filters", method: "filtersortreset"}, () => {
xhr.post("backend.php", {op: "pref-filters", method: "filtersortreset"}, () => {
this.reload();
});
},
@ -114,7 +114,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
if (confirm(__("Combine selected 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();
});
}
@ -131,7 +131,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree"], functio
ids: sel_rows.toString()
};
xhrPost("backend.php", query, () => {
xhr.post("backend.php", query, () => {
this.reload();
});
}

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

@ -1,5 +1,5 @@
/* 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) {
@ -98,7 +98,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f
ids: id, fg: fg, bg: bg, color: color
};
xhrPost("backend.php", query, () => {
xhr.post("backend.php", query, () => {
const tree = dijit.byId("filterTree");
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.hide();
xhrPost("backend.php", this.attr('value'), () => {
xhr.post("backend.php", this.attr('value'), () => {
const tree = dijit.byId("filterTree");
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()
};
xhrPost("backend.php", query, () => {
xhr.post("backend.php", query, () => {
this.reload();
});
}
@ -217,7 +217,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f
ids: sel_rows.toString()
};
xhrPost("backend.php", query, () => {
xhr.post("backend.php", query, () => {
this.reload();
});
}

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

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

Loading…
Cancel
Save