- try {
- var query = "backend.php?op=feeds&method=quickAddFeed";
-
- // overlapping widgets
- if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive();
- if (dijit.byId("feedAddDlg")) dijit.byId("feedAddDlg").destroyRecursive();
-
- var dialog = new dijit.Dialog({
- id: "feedAddDlg",
- title: __("Subscribe to Feed"),
- style: "width: 600px",
- execute: function() {
- if (this.validate()) {
- console.log(dojo.objectToQuery(this.attr('value')));
-
- var feed_url = this.attr('value').feed;
-
- Element.show("feed_add_spinner");
-
- new Ajax.Request("backend.php", {
- parameters: dojo.objectToQuery(this.attr('value')),
- onComplete: function(transport) {
- try {
-
- try {
- var reply = JSON.parse(transport.responseText);
- } catch (e) {
- Element.hide("feed_add_spinner");
- alert(__("Failed to parse output. This can indicate server timeout and/or network issues. Backend output was logged to browser console."));
- console.log('quickAddFeed, backend returned:' + transport.responseText);
- return;
- }
-
- var rc = reply['result'];
-
- notify('');
- Element.hide("feed_add_spinner");
-
- console.log(rc);
-
- switch (parseInt(rc['code'])) {
- case 1:
- dialog.hide();
- notify_info(__("Subscribed to %s").replace("%s", feed_url));
-
- updateFeedList();
- break;
- case 2:
- alert(__("Specified URL seems to be invalid."));
- break;
- case 3:
- alert(__("Specified URL doesn't seem to contain any feeds."));
- break;
- case 4:
- feeds = rc['feeds'];
-
- Element.show("fadd_multiple_notify");
-
- var select = dijit.byId("feedDlg_feedContainerSelect");
-
- while (select.getOptions().length > 0)
- select.removeOption(0);
-
- select.addOption({value: '', label: __("Expand to select feed")});
-
- var count = 0;
- for (var feedUrl in feeds) {
- select.addOption({value: feedUrl, label: feeds[feedUrl]});
- count++;
- }
-
- Effect.Appear('feedDlg_feedsContainer', {duration : 0.5});
-
- break;
- case 5:
- alert(__("Couldn't download the specified URL: %s").
- replace("%s", rc['message']));
- break;
- case 6:
- alert(__("XML validation failed: %s").
- replace("%s", rc['message']));
- break;
- break;
- case 0:
- alert(__("You are already subscribed to this feed."));
- break;
- }
-
- } catch (e) {
- exception_error("subscribeToFeed", e, transport);
- }
-
- } });
-
- }
- },
- href: query});
+ const query = "backend.php?op=feeds&method=quickAddFeed";
+
+ // overlapping widgets
+ if (dijit.byId("batchSubDlg")) dijit.byId("batchSubDlg").destroyRecursive();
+ if (dijit.byId("feedAddDlg")) dijit.byId("feedAddDlg").destroyRecursive();
+
+ const dialog = new dijit.Dialog({
+ id: "feedAddDlg",
+ title: __("Subscribe to Feed"),
+ style: "width: 600px",
+ show_error: function(msg) {
+ const elem = $("fadd_error_message");
+
+ elem.innerHTML = msg;
+
+ if (!Element.visible(elem))
+ new Effect.Appear(elem);
+
+ },
+ execute: function() {
+ if (this.validate()) {
+ console.log(dojo.objectToQuery(this.attr('value')));
+
+ const feed_url = this.attr('value').feed;
+
+ Element.show("feed_add_spinner");
+ Element.hide("fadd_error_message");
+
+ xhrPost("backend.php", this.attr('value'), (transport) => {
+ try {
+
+ try {
+ var reply = JSON.parse(transport.responseText);
+ } catch (e) {
+ Element.hide("feed_add_spinner");
+ alert(__("Failed to parse output. This can indicate server timeout and/or network issues. Backend output was logged to browser console."));
+ console.log('quickAddFeed, backend returned:' + transport.responseText);
+ return;
+ }
+
+ const rc = reply['result'];
+
+ notify('');
+ Element.hide("feed_add_spinner");
+
+ console.log(rc);
+
+ switch (parseInt(rc['code'])) {
+ case 1:
+ dialog.hide();
+ notify_info(__("Subscribed to %s").replace("%s", feed_url));
+
+ updateFeedList();
+ break;
+ case 2:
+ dialog.show_error(__("Specified URL seems to be invalid."));
+ break;
+ case 3:
+ dialog.show_error(__("Specified URL doesn't seem to contain any feeds."));
+ break;
+ case 4:
+ const feeds = rc['feeds'];
+
+ Element.show("fadd_multiple_notify");
+
+ const select = dijit.byId("feedDlg_feedContainerSelect");
+
+ while (select.getOptions().length > 0)
+ select.removeOption(0);
+
+ select.addOption({value: '', label: __("Expand to select feed")});
+
+ let count = 0;
+ for (const feedUrl in feeds) {
+ select.addOption({value: feedUrl, label: feeds[feedUrl]});
+ count++;
+ }
+
+ Effect.Appear('feedDlg_feedsContainer', {duration : 0.5});
+
+ break;
+ case 5:
+ dialog.show_error(__("Couldn't download the specified URL: %s").
+ replace("%s", rc['message']));
+ break;
+ case 6:
+ dialog.show_error(__("XML validation failed: %s").
+ replace("%s", rc['message']));
+ break;
+ case 0:
+ dialog.show_error(__("You are already subscribed to this feed."));
+ break;
+ }
+
+ } catch (e) {
+ console.error(transport.responseText);
+ exception_error(e);
+ }
+ });
+ }
+ },
+ href: query});