shorten declaration of PrefHelpers.OPML

This commit is contained in:
Andrew Dolgov 2018-12-03 12:57:19 +03:00
parent 8f1881e12c
commit a049b5bd88
1 changed files with 67 additions and 68 deletions

View File

@ -147,84 +147,83 @@ define(["dojo/_base/declare"], function (declare) {
dijit.byId('genConfigTab').attr('content', transport.responseText); dijit.byId('genConfigTab').attr('content', transport.responseText);
Notify.close(); Notify.close();
}); });
}
};
Helpers.OPML = {
import: function() {
const opml_file = $("opml_file");
if (opml_file.value.length == 0) {
alert(__("Please choose an OPML file first."));
return false;
} else {
Notify.progress("Importing, please wait...", true);
Element.show("upload_iframe");
return true;
}
}, },
onImportComplete: function(iframe) { OPML: {
if (!iframe.contentDocument.body.innerHTML) return false; import: function() {
const opml_file = $("opml_file");
Element.show(iframe); if (opml_file.value.length == 0) {
alert(__("Please choose an OPML file first."));
return false;
} else {
Notify.progress("Importing, please wait...", true);
Notify.close(); Element.show("upload_iframe");
if (dijit.byId('opmlImportDlg')) return true;
dijit.byId('opmlImportDlg').destroyRecursive(); }
},
onImportComplete: function(iframe) {
if (!iframe.contentDocument.body.innerHTML) return false;
const content = iframe.contentDocument.body.innerHTML; Element.show(iframe);
const dialog = new dijit.Dialog({ Notify.close();
id: "opmlImportDlg",
title: __("OPML Import"),
style: "width: 600px",
onCancel: function () {
window.location.reload();
},
execute: function () {
window.location.reload();
},
content: content
});
dojo.connect(dialog, "onShow", function () { if (dijit.byId('opmlImportDlg'))
Element.hide(iframe); dijit.byId('opmlImportDlg').destroyRecursive();
});
dialog.show(); const content = iframe.contentDocument.body.innerHTML;
},
export: function() {
console.log("export");
window.open("backend.php?op=opml&method=export&" + dojo.formToQuery("opmlExportForm"));
},
changeKey: function() {
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) => { const dialog = new dijit.Dialog({
if (reply) { id: "opmlImportDlg",
const new_link = reply.link; title: __("OPML Import"),
const e = $('pub_opml_url'); style: "width: 600px",
onCancel: function () {
if (new_link) { window.location.reload();
e.href = new_link; },
e.innerHTML = new_link; execute: function () {
window.location.reload();
new Effect.Highlight(e); },
content: content
Notify.close();
} else {
Notify.error("Could not change feed URL.");
}
}
}); });
}
return false; dojo.connect(dialog, "onShow", function () {
}, Element.hide(iframe);
});
dialog.show();
},
export: function() {
console.log("export");
window.open("backend.php?op=opml&method=export&" + dojo.formToQuery("opmlExportForm"));
},
changeKey: function() {
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) => {
if (reply) {
const new_link = reply.link;
const e = $('pub_opml_url');
if (new_link) {
e.href = new_link;
e.innerHTML = new_link;
new Effect.Highlight(e);
Notify.close();
} else {
Notify.error("Could not change feed URL.");
}
}
});
}
return false;
},
}
}; };
return Helpers; return Helpers;