mirror of
https://tt-rss.org/git/tt-rss.git
synced 2024-06-29 12:20:51 +02:00
use xhrPost is even more places!
This commit is contained in:
parent
3ad9944d5e
commit
fc0a3050eb
|
@ -1711,11 +1711,11 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
|
|
||||||
function regenFeedKey() {
|
function regenFeedKey() {
|
||||||
$feed_id = clean($_REQUEST['id']);
|
$feed_id = clean($_REQUEST['id']);
|
||||||
$is_cat = clean($_REQUEST['is_cat']) == "true";
|
$is_cat = clean($_REQUEST['is_cat']);
|
||||||
|
|
||||||
$new_key = $this->update_feed_access_key($feed_id, $is_cat);
|
$new_key = $this->update_feed_access_key($feed_id, $is_cat);
|
||||||
|
|
||||||
print json_encode(array("link" => $new_key));
|
print json_encode(["link" => $new_key]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1725,7 +1725,7 @@ class Pref_Feeds extends Handler_Protected {
|
||||||
// clear old value and generate new one
|
// clear old value and generate new one
|
||||||
$sth = $this->pdo->prepare("DELETE FROM ttrss_access_keys
|
$sth = $this->pdo->prepare("DELETE FROM ttrss_access_keys
|
||||||
WHERE feed_id = ? AND is_cat = ? AND owner_uid = ?");
|
WHERE feed_id = ? AND is_cat = ? AND owner_uid = ?");
|
||||||
$sth->execute([$feed_id, $is_cat, $owner_uid]);
|
$sth->execute([$feed_id, bool_to_sql_bool($is_cat), $owner_uid]);
|
||||||
|
|
||||||
return get_feed_access_key($feed_id, $is_cat, $owner_uid);
|
return get_feed_access_key($feed_id, $is_cat, $owner_uid);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2093,7 +2093,7 @@
|
||||||
$sth = $pdo->prepare("SELECT access_key FROM ttrss_access_keys
|
$sth = $pdo->prepare("SELECT access_key FROM ttrss_access_keys
|
||||||
WHERE feed_id = ? AND is_cat = ?
|
WHERE feed_id = ? AND is_cat = ?
|
||||||
AND owner_uid = ?");
|
AND owner_uid = ?");
|
||||||
$sth->execute([$feed_id, (int)$is_cat, $owner_uid]);
|
$sth->execute([$feed_id, $is_cat, $owner_uid]);
|
||||||
|
|
||||||
if ($row = $sth->fetch()) {
|
if ($row = $sth->fetch()) {
|
||||||
return $row["access_key"];
|
return $row["access_key"];
|
||||||
|
@ -2104,7 +2104,7 @@
|
||||||
(access_key, feed_id, is_cat, owner_uid)
|
(access_key, feed_id, is_cat, owner_uid)
|
||||||
VALUES (?, ?, ?, ?)");
|
VALUES (?, ?, ?, ?)");
|
||||||
|
|
||||||
$sth->execute([$key, $feed_id, (int)$is_cat, $owner_uid]);
|
$sth->execute([$key, $feed_id, $is_cat, $owner_uid]);
|
||||||
|
|
||||||
return $key;
|
return $key;
|
||||||
}
|
}
|
||||||
|
|
166
js/functions.js
166
js/functions.js
|
@ -336,15 +336,12 @@ function displayDlg(title, id, param, callback) {
|
||||||
|
|
||||||
notify_progress("Loading, please wait...", true);
|
notify_progress("Loading, please wait...", true);
|
||||||
|
|
||||||
const query = "?op=dlg&method=" +
|
const query = { op: "dlg", method: id, param: param };
|
||||||
param_escape(id) + "¶m=" + param_escape(param);
|
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
xhrPost("backend.php", query, (transport) => {
|
||||||
parameters: query,
|
|
||||||
onComplete: function (transport) {
|
|
||||||
infobox_callback2(transport, title);
|
infobox_callback2(transport, title);
|
||||||
if (callback) callback(transport);
|
if (callback) callback(transport);
|
||||||
} });
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -527,22 +524,19 @@ function uploadIconHandler(rc) {
|
||||||
|
|
||||||
function removeFeedIcon(id) {
|
function removeFeedIcon(id) {
|
||||||
if (confirm(__("Remove stored feed icon?"))) {
|
if (confirm(__("Remove stored feed icon?"))) {
|
||||||
const query = "backend.php?op=pref-feeds&method=removeicon&feed_id=" + param_escape(id);
|
|
||||||
|
|
||||||
console.log(query);
|
|
||||||
|
|
||||||
notify_progress("Removing feed icon...", true);
|
notify_progress("Removing feed icon...", true);
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
const query = { op: "pref-feeds", method: "removeicon", feed_id: id };
|
||||||
parameters: query,
|
|
||||||
onComplete: function(transport) {
|
xhrPost("backend.php", query, (transport) => {
|
||||||
notify_info("Feed icon removed.");
|
notify_info("Feed icon removed.");
|
||||||
if (inPreferences()) {
|
if (inPreferences()) {
|
||||||
updateFeedList();
|
updateFeedList();
|
||||||
} else {
|
} else {
|
||||||
setTimeout('updateFeedList(false, false)', 50);
|
setTimeout('updateFeedList(false, false)', 50);
|
||||||
}
|
}
|
||||||
} });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -572,17 +566,14 @@ function addLabel(select, callback) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
let query = "?op=pref-labels&method=add&caption=" +
|
const query = { op: "pref-labels", method: "add", caption: caption };
|
||||||
param_escape(caption);
|
|
||||||
|
|
||||||
if (select)
|
if (select)
|
||||||
query += "&output=select";
|
Object.extend(query, {output: "select"});
|
||||||
|
|
||||||
notify_progress("Loading, please wait...", true);
|
notify_progress("Loading, please wait...", true);
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
xhrPost("backend.php", query, (transport) => {
|
||||||
parameters: query,
|
|
||||||
onComplete: function(transport) {
|
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback(transport);
|
callback(transport);
|
||||||
} else if (inPreferences()) {
|
} else if (inPreferences()) {
|
||||||
|
@ -590,8 +581,7 @@ function addLabel(select, callback) {
|
||||||
} else {
|
} else {
|
||||||
updateFeedList();
|
updateFeedList();
|
||||||
}
|
}
|
||||||
} });
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -625,9 +615,7 @@ function quickAddFeed() {
|
||||||
Element.show("feed_add_spinner");
|
Element.show("feed_add_spinner");
|
||||||
Element.hide("fadd_error_message");
|
Element.hide("fadd_error_message");
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
xhrPost("backend.php", this.attr('value'), (transport) => {
|
||||||
parameters: dojo.objectToQuery(this.attr('value')),
|
|
||||||
onComplete: function(transport) {
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -660,18 +648,18 @@ function quickAddFeed() {
|
||||||
dialog.show_error(__("Specified URL doesn't seem to contain any feeds."));
|
dialog.show_error(__("Specified URL doesn't seem to contain any feeds."));
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
var feeds = rc['feeds'];
|
const feeds = rc['feeds'];
|
||||||
|
|
||||||
Element.show("fadd_multiple_notify");
|
Element.show("fadd_multiple_notify");
|
||||||
|
|
||||||
var select = dijit.byId("feedDlg_feedContainerSelect");
|
const select = dijit.byId("feedDlg_feedContainerSelect");
|
||||||
|
|
||||||
while (select.getOptions().length > 0)
|
while (select.getOptions().length > 0)
|
||||||
select.removeOption(0);
|
select.removeOption(0);
|
||||||
|
|
||||||
select.addOption({value: '', label: __("Expand to select feed")});
|
select.addOption({value: '', label: __("Expand to select feed")});
|
||||||
|
|
||||||
var count = 0;
|
let count = 0;
|
||||||
for (const feedUrl in feeds) {
|
for (const feedUrl in feeds) {
|
||||||
select.addOption({value: feedUrl, label: feeds[feedUrl]});
|
select.addOption({value: feedUrl, label: feeds[feedUrl]});
|
||||||
count++;
|
count++;
|
||||||
|
@ -697,9 +685,7 @@ function quickAddFeed() {
|
||||||
console.error(transport.responseText);
|
console.error(transport.responseText);
|
||||||
exception_error(e);
|
exception_error(e);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
} });
|
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
href: query});
|
href: query});
|
||||||
|
@ -712,14 +698,9 @@ function createNewRuleElement(parentNode, replaceNode) {
|
||||||
|
|
||||||
//form.reg_exp.value = form.reg_exp.value.replace(/(<([^>]+)>)/ig,"");
|
//form.reg_exp.value = form.reg_exp.value.replace(/(<([^>]+)>)/ig,"");
|
||||||
|
|
||||||
const query = "backend.php?op=pref-filters&method=printrulename&rule="+
|
const query = { op: "pref-filters", method: "printrulename", rule: dojo.formToJson(form) };
|
||||||
param_escape(dojo.formToJson(form));
|
|
||||||
|
|
||||||
console.log(query);
|
xhrPost("backend.php", query, (transport) => {
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
|
||||||
parameters: query,
|
|
||||||
onComplete: function (transport) {
|
|
||||||
try {
|
try {
|
||||||
const li = dojo.create("li");
|
const li = dojo.create("li");
|
||||||
|
|
||||||
|
@ -748,7 +729,7 @@ function createNewRuleElement(parentNode, replaceNode) {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
exception_error(e);
|
exception_error(e);
|
||||||
}
|
}
|
||||||
} });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function createNewActionElement(parentNode, replaceNode) {
|
function createNewActionElement(parentNode, replaceNode) {
|
||||||
|
@ -760,14 +741,10 @@ function createNewActionElement(parentNode, replaceNode) {
|
||||||
form.action_param.value = form.action_param_plugin.value;
|
form.action_param.value = form.action_param_plugin.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
const query = "backend.php?op=pref-filters&method=printactionname&action="+
|
const query = { op: "pref-filters", method: "printactionname",
|
||||||
param_escape(dojo.formToJson(form));
|
action: dojo.formToJson(form) };
|
||||||
|
|
||||||
console.log(query);
|
xhrPost("backend.php", query, (transport) => {
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
|
||||||
parameters: query,
|
|
||||||
onComplete: function (transport) {
|
|
||||||
try {
|
try {
|
||||||
const li = dojo.create("li");
|
const li = dojo.create("li");
|
||||||
|
|
||||||
|
@ -797,7 +774,7 @@ function createNewActionElement(parentNode, replaceNode) {
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
exception_error(e);
|
exception_error(e);
|
||||||
}
|
}
|
||||||
} });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -862,9 +839,7 @@ function editFilterTest(query) {
|
||||||
|
|
||||||
console.log("getTestResults:" + offset);
|
console.log("getTestResults:" + offset);
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
xhrPost("backend.php", updquery, (transport) => {
|
||||||
parameters: updquery,
|
|
||||||
onComplete: function (transport) {
|
|
||||||
try {
|
try {
|
||||||
const result = JSON.parse(transport.responseText);
|
const result = JSON.parse(transport.responseText);
|
||||||
|
|
||||||
|
@ -923,7 +898,7 @@ function editFilterTest(query) {
|
||||||
exception_error(e);
|
exception_error(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
} });
|
});
|
||||||
},
|
},
|
||||||
href: query});
|
href: query});
|
||||||
|
|
||||||
|
@ -1005,17 +980,13 @@ function quickAddFilter() {
|
||||||
|
|
||||||
const query = dojo.formToQuery("filter_new_form");
|
const query = dojo.formToQuery("filter_new_form");
|
||||||
|
|
||||||
console.log(query);
|
xhrPost("backend.php", query, (transport) => {
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
|
||||||
parameters: query,
|
|
||||||
onComplete: function (transport) {
|
|
||||||
if (inPreferences()) {
|
if (inPreferences()) {
|
||||||
updateFilterList();
|
updateFilterList();
|
||||||
}
|
}
|
||||||
|
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
} });
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
href: query});
|
href: query});
|
||||||
|
@ -1037,11 +1008,9 @@ function quickAddFilter() {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
const query = "op=rpc&method=getlinktitlebyid&id=" + getActiveArticleId();
|
const query = { op: "rpc", method: "getlinktitlebyid", id: getActiveArticleId() };
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
xhrPost("backend.php", query, (transport) => {
|
||||||
parameters: query,
|
|
||||||
onComplete: function(transport) {
|
|
||||||
const reply = JSON.parse(transport.responseText);
|
const reply = JSON.parse(transport.responseText);
|
||||||
|
|
||||||
let title = false;
|
let title = false;
|
||||||
|
@ -1059,11 +1028,8 @@ function quickAddFilter() {
|
||||||
|
|
||||||
addFilterRule(null, dojo.toJson(rule));
|
addFilterRule(null, dojo.toJson(rule));
|
||||||
}
|
}
|
||||||
|
});
|
||||||
} });
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1078,12 +1044,9 @@ function unsubscribeFeed(feed_id, title) {
|
||||||
if (title == undefined || confirm(msg)) {
|
if (title == undefined || confirm(msg)) {
|
||||||
notify_progress("Removing feed...");
|
notify_progress("Removing feed...");
|
||||||
|
|
||||||
const query = "?op=pref-feeds&quiet=1&method=remove&ids=" + feed_id;
|
const query = { op: "pref-feeds", quiet: 1, method: "remove", ids: feed_id };
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
|
||||||
parameters: query,
|
|
||||||
onComplete: function(transport) {
|
|
||||||
|
|
||||||
|
xhrPost("backend.php", query, (transport) => {
|
||||||
if (dijit.byId("feedEditDlg")) dijit.byId("feedEditDlg").hide();
|
if (dijit.byId("feedEditDlg")) dijit.byId("feedEditDlg").hide();
|
||||||
|
|
||||||
if (inPreferences()) {
|
if (inPreferences()) {
|
||||||
|
@ -1094,8 +1057,7 @@ function unsubscribeFeed(feed_id, title) {
|
||||||
|
|
||||||
if (feed_id < 0) updateFeedList();
|
if (feed_id < 0) updateFeedList();
|
||||||
}
|
}
|
||||||
|
});
|
||||||
} });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -1145,19 +1107,13 @@ function genUrlChangeKey(feed, is_cat) {
|
||||||
|
|
||||||
notify_progress("Trying to change address...", true);
|
notify_progress("Trying to change address...", true);
|
||||||
|
|
||||||
const query = "?op=pref-feeds&method=regenFeedKey&id=" + param_escape(feed) +
|
const query = { op: "pref-feeds", method: "regenFeedKey", id: feed, is_cat: is_cat };
|
||||||
"&is_cat=" + param_escape(is_cat);
|
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
xhrJson("backend.php", query, (reply) => {
|
||||||
parameters: query,
|
|
||||||
onComplete: function(transport) {
|
|
||||||
const reply = JSON.parse(transport.responseText);
|
|
||||||
const new_link = reply.link;
|
const new_link = reply.link;
|
||||||
|
|
||||||
const e = $('gen_feed_url');
|
const e = $('gen_feed_url');
|
||||||
|
|
||||||
if (new_link) {
|
if (new_link) {
|
||||||
|
|
||||||
e.innerHTML = e.innerHTML.replace(/\&key=.*$/,
|
e.innerHTML = e.innerHTML.replace(/\&key=.*$/,
|
||||||
"&key=" + new_link);
|
"&key=" + new_link);
|
||||||
|
|
||||||
|
@ -1171,7 +1127,7 @@ function genUrlChangeKey(feed, is_cat) {
|
||||||
} else {
|
} else {
|
||||||
notify_error("Could not change feed URL.");
|
notify_error("Could not change feed URL.");
|
||||||
}
|
}
|
||||||
} });
|
});
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -1267,17 +1223,13 @@ function editFeed(feed) {
|
||||||
style: "width: 600px",
|
style: "width: 600px",
|
||||||
execute: function() {
|
execute: function() {
|
||||||
if (this.validate()) {
|
if (this.validate()) {
|
||||||
// console.log(dojo.objectToQuery(this.attr('value')));
|
|
||||||
|
|
||||||
notify_progress("Saving data...", true);
|
notify_progress("Saving data...", true);
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
xhrPost("backend.php", dialog.attr('value'), (transport) => {
|
||||||
parameters: dojo.objectToQuery(dialog.attr('value')),
|
|
||||||
onComplete: function(transport) {
|
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
notify('');
|
notify('');
|
||||||
updateFeedList();
|
updateFeedList();
|
||||||
}});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
href: query});
|
href: query});
|
||||||
|
@ -1341,20 +1293,12 @@ function feedBrowser() {
|
||||||
|
|
||||||
notify_progress("Loading, please wait...", true);
|
notify_progress("Loading, please wait...", true);
|
||||||
|
|
||||||
// we use dojo.toJson instead of JSON.stringify because
|
const query = { op: "rpc", method: "massSubscribe",
|
||||||
// it somehow escapes everything TWICE, at least in Chrome 9
|
payload: JSON.stringify(selected), mode: mode };
|
||||||
|
|
||||||
const query = "?op=rpc&method=massSubscribe&payload=" +
|
xhrPost("backend.php", query, () => {
|
||||||
param_escape(dojo.toJson(selected)) + "&mode=" + param_escape(mode);
|
|
||||||
|
|
||||||
console.log(query);
|
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
|
||||||
parameters: query,
|
|
||||||
onComplete: function (transport) {
|
|
||||||
notify('');
|
notify('');
|
||||||
updateFeedList();
|
updateFeedList();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -1363,13 +1307,9 @@ function feedBrowser() {
|
||||||
|
|
||||||
},
|
},
|
||||||
update: function () {
|
update: function () {
|
||||||
const query = dojo.objectToQuery(dialog.attr('value'));
|
|
||||||
|
|
||||||
Element.show('feed_browser_spinner');
|
Element.show('feed_browser_spinner');
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
xhrPost("backend.php", dialog.attr("value"), (transport) => {
|
||||||
parameters: query,
|
|
||||||
onComplete: function (transport) {
|
|
||||||
notify('');
|
notify('');
|
||||||
|
|
||||||
Element.hide('feed_browser_spinner');
|
Element.hide('feed_browser_spinner');
|
||||||
|
@ -1388,8 +1328,6 @@ function feedBrowser() {
|
||||||
} else {
|
} else {
|
||||||
Element.hide(dijit.byId('feed_archive_remove').domNode);
|
Element.hide(dijit.byId('feed_archive_remove').domNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
removeFromArchive: function () {
|
removeFromArchive: function () {
|
||||||
|
@ -1402,15 +1340,10 @@ function feedBrowser() {
|
||||||
if (confirm(pr)) {
|
if (confirm(pr)) {
|
||||||
Element.show('feed_browser_spinner');
|
Element.show('feed_browser_spinner');
|
||||||
|
|
||||||
const query = "?op=rpc&method=remarchive&ids=" +
|
const query = { op: "rpc", method: "remarchive", ids: selected.toString() };
|
||||||
param_escape(selected.toString());
|
|
||||||
|
|
||||||
|
xhrPost("backend.php", query, () => {
|
||||||
new Ajax.Request("backend.php", {
|
|
||||||
parameters: query,
|
|
||||||
onComplete: function (transport) {
|
|
||||||
dialog.update();
|
dialog.update();
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1450,16 +1383,14 @@ function showFeedsWithErrors() {
|
||||||
if (ok) {
|
if (ok) {
|
||||||
notify_progress("Removing selected feeds...", true);
|
notify_progress("Removing selected feeds...", true);
|
||||||
|
|
||||||
const query = "?op=pref-feeds&method=remove&ids="+
|
const query = { op: "pref-feeds", method: "remove",
|
||||||
param_escape(sel_rows.toString());
|
ids: sel_rows.toString() };
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
xhrPost("backend.php", query, () => {
|
||||||
parameters: query,
|
|
||||||
onComplete: function(transport) {
|
|
||||||
notify('');
|
notify('');
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
updateFeedList();
|
updateFeedList();
|
||||||
} });
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -1468,6 +1399,7 @@ function showFeedsWithErrors() {
|
||||||
},
|
},
|
||||||
execute: function() {
|
execute: function() {
|
||||||
if (this.validate()) {
|
if (this.validate()) {
|
||||||
|
//
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
href: query});
|
href: query});
|
||||||
|
|
Loading…
Reference in New Issue
Block a user