finish xhrPost migration of js/

master
Andrew Dolgov 6 years ago
parent 7e8be97b66
commit fd752a79af

@ -734,16 +734,12 @@ function init() {
loading_set_progress(50); loading_set_progress(50);
const clientTzOffset = new Date().getTimezoneOffset() * 60; const clientTzOffset = new Date().getTimezoneOffset() * 60;
const params = { op: "rpc", method: "sanityCheck", clientTzOffset: clientTzOffset };
new Ajax.Request("backend.php", { xhrPost("backend.php", params, (transport) => {
parameters: { backend_sanity_check_callback(transport);
op: "rpc", method: "sanityCheck",
clientTzOffset: clientTzOffset
},
onComplete: function (transport) {
backend_sanity_check_callback(transport);
}
}); });
} catch (e) { } catch (e) {
exception_error(e); exception_error(e);
} }
@ -793,44 +789,32 @@ function pref_hotkey_handler(e) {
function removeCategory(id, item) { function removeCategory(id, item) {
const ok = confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name)); if (confirm(__("Remove category %s? Any nested feeds would be placed into Uncategorized.").replace("%s", item.name))) {
if (ok) {
const query = "?op=pref-feeds&method=removeCat&ids=" +
param_escape(id);
notify_progress("Removing category..."); notify_progress("Removing category...");
new Ajax.Request("backend.php", { const query = { op: "pref-feeds", method: "removeCat",
parameters: query, ids: id };
onComplete: function (transport) {
notify(''); xhrPost("backend.php", query, () => {
updateFeedList(); notify('');
} updateFeedList();
}); });
} }
} }
function removeSelectedCategories() { function removeSelectedCategories() {
const sel_rows = getSelectedCategories(); const sel_rows = getSelectedCategories();
if (sel_rows.length > 0) { if (sel_rows.length > 0) {
if (confirm(__("Remove selected categories?"))) {
const ok = confirm(__("Remove selected categories?"));
if (ok) {
notify_progress("Removing selected categories..."); notify_progress("Removing selected categories...");
const query = "?op=pref-feeds&method=removeCat&ids="+ const query = { op: "pref-feeds", method: "removeCat",
param_escape(sel_rows.toString()); ids: sel_rows.toString() };
new Ajax.Request("backend.php", {
parameters: query,
onComplete: function(transport) {
updateFeedList();
} });
xhrPost("backend.php", query, () => {
updateFeedList();
});
} }
} else { } else {
alert(__("No categories are selected.")); alert(__("No categories are selected."));
@ -843,19 +827,12 @@ function createCategory() {
const title = prompt(__("Category title:")); const title = prompt(__("Category title:"));
if (title) { if (title) {
notify_progress("Creating category..."); notify_progress("Creating category...");
const query = "?op=pref-feeds&method=addCat&cat=" + xhrPost("backend.php", { op: "pref-feeds", method: "addCat", cat: title }, () => {
param_escape(title); notify('');
updateFeedList();
new Ajax.Request("backend.php", { });
parameters: query,
onComplete: function (transport) {
notify('');
updateFeedList();
}
});
} }
} }
@ -875,25 +852,18 @@ function showInactiveFeeds() {
removeSelected: function () { removeSelected: function () {
const sel_rows = this.getSelectedFeeds(); const sel_rows = this.getSelectedFeeds();
console.log(sel_rows);
if (sel_rows.length > 0) { if (sel_rows.length > 0) {
const ok = confirm(__("Remove selected feeds?")); if (confirm(__("Remove selected feeds?"))) {
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, notify('');
onComplete: function (transport) { dialog.hide();
notify(''); updateFeedList();
dialog.hide(); });
updateFeedList();
}
});
} }
} else { } else {
@ -911,36 +881,27 @@ function showInactiveFeeds() {
} }
function opmlRegenKey() { function opmlRegenKey() {
const ok = confirm(__("Replace current OPML publishing address with a new one?")); if (confirm(__("Replace current OPML publishing address with a new one?"))) {
if (ok) {
notify_progress("Trying to change address...", true); notify_progress("Trying to change address...", true);
const query = "?op=pref-feeds&method=regenOPMLKey"; xhrJson("backend.php", { op: "pref-feeds", method: "regenOPMLKey" }, (reply) => {
if (reply) {
new Ajax.Request("backend.php", { const new_link = reply.link;
parameters: query, const e = $('pub_opml_url');
onComplete: function (transport) {
const reply = JSON.parse(transport.responseText);
const new_link = reply.link; if (new_link) {
e.href = new_link;
e.innerHTML = new_link;
const e = $('pub_opml_url'); new Effect.Highlight(e);
if (new_link) { notify('');
e.href = new_link;
e.innerHTML = new_link;
new Effect.Highlight(e); } else {
notify_error("Could not change feed URL.");
notify(''); }
}
} else { });
notify_error("Could not change feed URL.");
}
}
});
} }
return false; return false;
} }
@ -949,18 +910,14 @@ function labelColorReset() {
const labels = getSelectedLabels(); const labels = getSelectedLabels();
if (labels.length > 0) { if (labels.length > 0) {
const ok = confirm(__("Reset selected labels to default colors?")); if (confirm(__("Reset selected labels to default colors?"))) {
if (ok) { const query = { op: "pref-labels", method: "colorreset",
const query = "?op=pref-labels&method=colorreset&ids=" + ids: labels.toString() };
param_escape(labels.toString());
new Ajax.Request("backend.php", { xhrPost("backend.php", query, () => {
parameters: query, updateLabelList();
onComplete: function (transport) { });
updateLabelList();
}
});
} }
} else { } else {

@ -235,17 +235,15 @@ function init() {
return false; return false;
loading_set_progress(30); loading_set_progress(30);
const a = document.createElement('audio');
const hasAudio = !!a.canPlayType;
const hasSandbox = "sandbox" in document.createElement("iframe");
const hasMp3 = !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, ''));
const clientTzOffset = new Date().getTimezoneOffset() * 60;
init_hotkey_actions(); init_hotkey_actions();
const params = { const a = document.createElement('audio');
const hasAudio = !!a.canPlayType;
const hasSandbox = "sandbox" in document.createElement("iframe");
const hasMp3 = !!(a.canPlayType && a.canPlayType('audio/mpeg;').replace(/no/, ''));
const clientTzOffset = new Date().getTimezoneOffset() * 60;
const params = {
op: "rpc", method: "sanityCheck", hasAudio: hasAudio, op: "rpc", method: "sanityCheck", hasAudio: hasAudio,
hasMp3: hasMp3, hasMp3: hasMp3,
clientTzOffset: clientTzOffset, clientTzOffset: clientTzOffset,

Loading…
Cancel
Save