diff options
Diffstat (limited to 'js/CommonDialogs.js')
| -rw-r--r-- | js/CommonDialogs.js | 61 |
1 files changed, 31 insertions, 30 deletions
diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index c6d476de0..d3ad35161 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -1,8 +1,9 @@ 'use strict' -/* global __, ngettext */ -define(["dojo/_base/declare"], function (declare) { - // noinspection JSUnusedGlobalSymbols - CommonDialogs = { + +/* global __, ngettext, dojo, dijit, Notify, App, Feeds, $$, xhrPost, xhrJson, Tables, Effect */ + +/* exported CommonDialogs */ +const CommonDialogs = { closeInfoBox: function() { const dialog = dijit.byId("infoBox"); if (dialog) dialog.hide(); @@ -45,18 +46,20 @@ define(["dojo/_base/declare"], function (declare) { xhr.onload = function () { switch (parseInt(this.responseText)) { case 0: - Notify.info("Upload complete."); + { + Notify.info("Upload complete."); - if (App.isPrefs()) - dijit.byId("feedTree").reload(); - else - Feeds.reload(); + if (App.isPrefs()) + dijit.byId("feedTree").reload(); + else + Feeds.reload(); - const icon = $$(".feed-editor-icon")[0]; + const icon = $$(".feed-editor-icon")[0]; - if (icon) - icon.src = icon.src.replace(/\?[0-9]+$/, "?" + new Date().getTime()); + if (icon) + icon.src = icon.src.replace(/\?[0-9]+$/, "?" + new Date().getTime()); + } break; case 1: Notify.error("Upload failed: icon is too big."); @@ -103,8 +106,10 @@ define(["dojo/_base/declare"], function (declare) { xhrPost("backend.php", this.attr('value'), (transport) => { try { + let reply; + try { - var reply = JSON.parse(transport.responseText); + 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.")); @@ -137,27 +142,26 @@ define(["dojo/_base/declare"], function (declare) { dialog.show_error(__("Specified URL doesn't seem to contain any feeds.")); break; case 4: - const feeds = rc['feeds']; + { + const feeds = rc['feeds']; - Element.show("fadd_multiple_notify"); + Element.show("fadd_multiple_notify"); - const select = dijit.byId("feedDlg_feedContainerSelect"); + const select = dijit.byId("feedDlg_feedContainerSelect"); - while (select.getOptions().length > 0) - select.removeOption(0); + while (select.getOptions().length > 0) + select.removeOption(0); - select.addOption({value: '', label: __("Expand to select feed")}); + select.addOption({value: '', label: __("Expand to select feed")}); - let count = 0; - for (const feedUrl in feeds) { - if (feeds.hasOwnProperty(feedUrl)) { - select.addOption({value: feedUrl, label: feeds[feedUrl]}); - count++; + for (const feedUrl in feeds) { + if (feeds.hasOwnProperty(feedUrl)) { + select.addOption({value: feedUrl, label: feeds[feedUrl]}); + } } - } - - Effect.Appear('feedDlg_feedsContainer', {duration: 0.5}); + Effect.Appear('feedDlg_feedsContainer', {duration: 0.5}); + } break; case 5: dialog.show_error(__("Couldn't download the specified URL: %s").replace("%s", rc['message'])); @@ -478,6 +482,3 @@ define(["dojo/_base/declare"], function (declare) { return false; } }; - - return CommonDialogs; -}); |