summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xinclude/login_form.php2
-rw-r--r--js/App.js2
-rw-r--r--js/Article.js4
-rw-r--r--js/CommonDialogs.js12
-rw-r--r--js/Feeds.js2
-rw-r--r--js/PrefFeedTree.js8
-rw-r--r--js/PrefHelpers.js4
-rw-r--r--js/PrefLabelTree.js2
-rw-r--r--js/PrefUsers.js2
-rwxr-xr-xjs/common.js22
-rw-r--r--plugins/af_readability/init.js2
-rw-r--r--plugins/mail/init.php2
-rw-r--r--plugins/mail/mail.js2
-rw-r--r--plugins/note/note.js2
-rw-r--r--plugins/share/share.js2
15 files changed, 30 insertions, 40 deletions
diff --git a/include/login_form.php b/include/login_form.php
index d1af23459..211302a87 100755
--- a/include/login_form.php
+++ b/include/login_form.php
@@ -59,7 +59,7 @@
if (login && login != this.previousLogin) {
this.previousLogin = login;
- xhrJson("public.php", {op: "getprofiles", login: login},
+ xhr.json("public.php", {op: "getprofiles", login: login},
(reply) => {
const profile = dijit.byId('profile');
diff --git a/js/App.js b/js/App.js
index d61c6ead0..0c12c7e6f 100644
--- a/js/App.js
+++ b/js/App.js
@@ -775,7 +775,7 @@ const App = {
checkForUpdates: function() {
console.log('checking for updates...');
- xhrJson("backend.php", {op: 'rpc', method: 'checkforupdates'})
+ xhr.json("backend.php", {op: 'rpc', method: 'checkforupdates'})
.then((reply) => {
console.log('update reply', reply);
diff --git a/js/Article.js b/js/Article.js
index 90be90f7b..379e05644 100644
--- a/js/Article.js
+++ b/js/Article.js
@@ -115,7 +115,7 @@ const Article = {
displayUrl: function (id) {
const query = {op: "article", method: "getmetadatabyid", id: id};
- xhrJson("backend.php", query, (reply) => {
+ xhr.json("backend.php", query, (reply) => {
if (reply && reply.link) {
prompt(__("Article URL:"), reply.link);
} else {
@@ -358,7 +358,7 @@ const Article = {
const tmph = dojo.connect(dialog, 'onShow', function () {
dojo.disconnect(tmph);
- xhrJson("backend.php", {op: "article", method: "printArticleTags", id: id}, (reply) => {
+ xhr.json("backend.php", {op: "article", method: "printArticleTags", id: id}, (reply) => {
dijit.getEnclosingWidget(App.byId("tags_str"))
.attr('value', reply.tags.join(", "))
diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js
index 6ace91c8c..3acd2b577 100644
--- a/js/CommonDialogs.js
+++ b/js/CommonDialogs.js
@@ -78,7 +78,7 @@ const CommonDialogs = {
return false;
},
subscribeToFeed: function() {
- xhrJson("backend.php",
+ xhr.json("backend.php",
{op: "feeds", method: "subscribeToFeed"},
(reply) => {
const dialog = new fox.SingleUseDialog({
@@ -265,7 +265,7 @@ const CommonDialogs = {
},
showFeedsWithErrors: function() {
- xhrJson("backend.php", {op: "pref-feeds", method: "feedsWithErrors"}, (reply) => {
+ xhr.json("backend.php", {op: "pref-feeds", method: "feedsWithErrors"}, (reply) => {
const dialog = new fox.SingleUseDialog({
id: "errorFeedsDlg",
@@ -446,7 +446,7 @@ const CommonDialogs = {
Notify.progress("Loading, please wait...", true);
- xhrJson("backend.php", {op: "pref-feeds", method: "getOPMLKey"}, (reply) => {
+ xhr.json("backend.php", {op: "pref-feeds", method: "getOPMLKey"}, (reply) => {
try {
const dialog = new fox.SingleUseDialog({
title: __("Public OPML URL"),
@@ -454,7 +454,7 @@ const CommonDialogs = {
if (confirm(__("Replace current OPML publishing address with a new one?"))) {
Notify.progress("Trying to change address...", true);
- xhrJson("backend.php", {op: "pref-feeds", method: "regenOPMLKey"}, (reply) => {
+ xhr.json("backend.php", {op: "pref-feeds", method: "regenOPMLKey"}, (reply) => {
if (reply) {
const new_link = reply.link;
const target = this.domNode.querySelector('.generated_url');
@@ -504,7 +504,7 @@ const CommonDialogs = {
Notify.progress("Loading, please wait...", true);
- xhrJson("backend.php", {op: "pref-feeds", method: "getsharedurl", id: feed, is_cat: is_cat, search: search}, (reply) => {
+ xhr.json("backend.php", {op: "pref-feeds", method: "getsharedurl", id: feed, is_cat: is_cat, search: search}, (reply) => {
try {
const dialog = new fox.SingleUseDialog({
title: __("Show as feed"),
@@ -515,7 +515,7 @@ const CommonDialogs = {
const query = {op: "pref-feeds", method: "regenFeedKey", id: feed, is_cat: is_cat};
- xhrJson("backend.php", query, (reply) => {
+ xhr.json("backend.php", query, (reply) => {
const new_link = reply.link;
const target = this.domNode.querySelector(".generated_url");
diff --git a/js/Feeds.js b/js/Feeds.js
index 67c78cbfe..7cefe2235 100644
--- a/js/Feeds.js
+++ b/js/Feeds.js
@@ -558,7 +558,7 @@ const Feeds = {
return tree.model.store.getValue(nuf, 'bare_id');
},
search: function() {
- xhrJson("backend.php",
+ xhr.json("backend.php",
{op: "feeds", method: "search"},
(reply) => {
try {
diff --git a/js/PrefFeedTree.js b/js/PrefFeedTree.js
index 92194e037..c7228e6ff 100644
--- a/js/PrefFeedTree.js
+++ b/js/PrefFeedTree.js
@@ -210,14 +210,14 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
return false;
},
checkErrorFeeds: function() {
- xhrJson("backend.php", {op: "pref-feeds", method: "feedsWithErrors"}, (reply) => {
+ xhr.json("backend.php", {op: "pref-feeds", method: "feedsWithErrors"}, (reply) => {
if (reply.length > 0) {
Element.show(dijit.byId("pref_feeds_errors_btn").domNode);
}
});
},
checkInactiveFeeds: function() {
- xhrJson("backend.php", {op: "pref-feeds", method: "inactivefeeds"}, (reply) => {
+ xhr.json("backend.php", {op: "pref-feeds", method: "inactivefeeds"}, (reply) => {
if (reply.length > 0) {
Element.show(dijit.byId("pref_feeds_inactive_btn").domNode);
}
@@ -385,7 +385,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
}
},
batchSubscribe: function() {
- xhrJson("backend.php", {op: 'pref-feeds', method: 'batchSubscribe'}, (reply) => {
+ xhr.json("backend.php", {op: 'pref-feeds', method: 'batchSubscribe'}, (reply) => {
const dialog = new fox.SingleUseDialog({
id: "batchSubDlg",
title: __("Batch subscribe"),
@@ -458,7 +458,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dojo/_b
});
},
showInactiveFeeds: function() {
- xhrJson("backend.php", {op: 'pref-feeds', method: 'inactivefeeds'}, function (reply) {
+ xhr.json("backend.php", {op: 'pref-feeds', method: 'inactivefeeds'}, function (reply) {
const dialog = new fox.SingleUseDialog({
id: "inactiveFeedsDlg",
diff --git a/js/PrefHelpers.js b/js/PrefHelpers.js
index d4db15c3b..c17966291 100644
--- a/js/PrefHelpers.js
+++ b/js/PrefHelpers.js
@@ -132,7 +132,7 @@ const Helpers = {
}
},
refresh: function() {
- xhrJson("backend.php", {op: 'pref-prefs', method: 'getprofiles'}, (reply) => {
+ xhr.json("backend.php", {op: 'pref-prefs', method: 'getprofiles'}, (reply) => {
dialog.attr('content', `
<div dojoType='fox.Toolbar'>
<div dojoType='fox.form.DropDownButton'>
@@ -212,7 +212,7 @@ const Helpers = {
},
Prefs: {
customizeCSS: function() {
- xhrJson("backend.php", {op: "pref-prefs", method: "customizeCSS"}, (reply) => {
+ xhr.json("backend.php", {op: "pref-prefs", method: "customizeCSS"}, (reply) => {
const dialog = new fox.SingleUseDialog({
title: __("Customize stylesheet"),
diff --git a/js/PrefLabelTree.js b/js/PrefLabelTree.js
index 4392dfc44..9d16a147c 100644
--- a/js/PrefLabelTree.js
+++ b/js/PrefLabelTree.js
@@ -61,7 +61,7 @@ define(["dojo/_base/declare", "dojo/dom-construct", "lib/CheckBoxTree", "dijit/f
});
},
editLabel: function(id) {
- xhrJson("backend.php", {op: "pref-labels", method: "edit", id: id}, (reply) => {
+ xhr.json("backend.php", {op: "pref-labels", method: "edit", id: id}, (reply) => {
console.log(reply);
diff --git a/js/PrefUsers.js b/js/PrefUsers.js
index 64466ef18..5b490a2a5 100644
--- a/js/PrefUsers.js
+++ b/js/PrefUsers.js
@@ -27,7 +27,7 @@ const Users = {
}
},
edit: function(id) {
- xhrJson('backend.php', {op: 'pref-users', method: 'edit', id: id}, (reply) => {
+ xhr.json('backend.php', {op: 'pref-users', method: 'edit', id: id}, (reply) => {
const user = reply.user;
const admin_disabled = (user.id == 1);
diff --git a/js/common.js b/js/common.js
index dbe1ae3c3..f3fcdd905 100755
--- a/js/common.js
+++ b/js/common.js
@@ -143,7 +143,7 @@ String.prototype.stripTags = function() {
const xhr = {
post: function(url, params = {}, complete = undefined) {
- console.log("xhr.post:", params);
+ console.log('xhr.post', '>>>', params);
return new Promise((resolve, reject) => {
if (typeof __csrf_token != "undefined")
@@ -156,6 +156,8 @@ const xhr = {
reject(error);
},
load: function(data, ioargs) {
+ //console.log('xhr.post', '<<<', data, ioargs);
+
if (complete != undefined)
complete(data, ioargs.xhr);
@@ -176,6 +178,8 @@ const xhr = {
reject(e);
}
+ console.log('xhr.json', '<<<', obj);
+
if (complete != undefined) complete(obj);
resolve(obj);
@@ -209,21 +213,7 @@ function xhrPost(url, params = {}, complete = undefined) {
/* exported xhrJson */
function xhrJson(url, params = {}, complete = undefined) {
- return new Promise((resolve, reject) =>
- xhrPost(url, params).then((reply) => {
- let obj = null;
-
- try {
- obj = JSON.parse(reply.responseText);
- } catch (e) {
- console.error("xhrJson", e, reply);
- reject(e);
- }
-
- if (complete != undefined) complete(obj);
-
- resolve(obj);
- }));
+ return xhr.json(url, params, complete);
}
/* common helpers not worthy of separate Dojo modules */
diff --git a/plugins/af_readability/init.js b/plugins/af_readability/init.js
index 6dec82f45..5297416b3 100644
--- a/plugins/af_readability/init.js
+++ b/plugins/af_readability/init.js
@@ -16,7 +16,7 @@ Plugins.Af_Readability = {
Notify.progress("Loading, please wait...");
- xhrJson("backend.php", App.getPhArgs("af_readability", "embed", {id: id}), (reply) => {
+ xhr.json("backend.php", App.getPhArgs("af_readability", "embed", {id: id}), (reply) => {
if (content && reply.content) {
content.setAttribute(self.orig_attr_name, content.innerHTML);
diff --git a/plugins/mail/init.php b/plugins/mail/init.php
index d96006b21..16e22f342 100644
--- a/plugins/mail/init.php
+++ b/plugins/mail/init.php
@@ -152,7 +152,7 @@ class Mail extends Plugin {
<script type='dojo/method' event='onSubmit' args='evt'>
evt.preventDefault();
if (this.validate()) {
- xhrJson("backend.php", this.getValues(), (reply) => {
+ xhr.json("backend.php", this.getValues(), (reply) => {
if (reply && reply.error)
Notify.error(reply.error);
else
diff --git a/plugins/mail/mail.js b/plugins/mail/mail.js
index 36b0baac5..fc0898085 100644
--- a/plugins/mail/mail.js
+++ b/plugins/mail/mail.js
@@ -17,7 +17,7 @@ Plugins.Mail = {
title: __("Forward article by email"),
execute: function () {
if (this.validate()) {
- xhrJson("backend.php", this.attr('value'), (reply) => {
+ xhr.json("backend.php", this.attr('value'), (reply) => {
if (reply) {
const error = reply['error'];
diff --git a/plugins/note/note.js b/plugins/note/note.js
index d2d9c2b01..36bc426cd 100644
--- a/plugins/note/note.js
+++ b/plugins/note/note.js
@@ -8,7 +8,7 @@ Plugins.Note = {
if (this.validate()) {
Notify.progress("Saving article note...", true);
- xhrJson("backend.php", this.attr('value'), (reply) => {
+ xhr.json("backend.php", this.attr('value'), (reply) => {
Notify.close();
dialog.hide();
diff --git a/plugins/share/share.js b/plugins/share/share.js
index a5f60d267..d7b8cd1f9 100644
--- a/plugins/share/share.js
+++ b/plugins/share/share.js
@@ -10,7 +10,7 @@ Plugins.Share = {
Notify.progress("Trying to change URL...", true);
- xhrJson("backend.php", App.getPhArgs("share", "newkey", {id: id}), (reply) => {
+ xhr.json("backend.php", App.getPhArgs("share", "newkey", {id: id}), (reply) => {
if (reply) {
const new_link = reply.link;
const target = dialog.domNode.querySelector(".target-url");