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