diff --git a/classes/feeds.php b/classes/feeds.php index d49fe7698..4cc76bd62 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -581,85 +581,10 @@ class Feeds extends Handler_Protected { return $reply; } - function quickAddFeed() { - print "
"; - - print_hidden("op", "rpc"); - print_hidden("method", "addfeed"); - - print ""; - - print ""; - - print "
"; - - print "
"; - print "
"; - print ""; - - print "
"; - - print "
"; - - if (get_pref('ENABLE_FEED_CATS')) { - print " "; - print_feed_cat_select("cat", false, 'dojoType="fox.form.Select"'); - } - - print "
"; - - print "
"; - - print ''; - - print ""; - - print "
"; - print "
"; - - print ""; - - print "
"; + function subscribeToFeed() { + print json_encode([ + "cat_select" => format_feed_cat_select("cat", false, 'dojoType="fox.form.Select"') + ]); } function search() { @@ -1077,6 +1002,18 @@ class Feeds extends Handler_Protected { } } + function add() { + $feed = clean($_REQUEST['feed']); + $cat = clean($_REQUEST['cat']); + $need_auth = isset($_REQUEST['need_auth']); + $login = $need_auth ? clean($_REQUEST['login']) : ''; + $pass = $need_auth ? clean($_REQUEST['pass']) : ''; + + $rc = Feeds::subscribe_to_feed($feed, $cat, $login, $pass); + + print json_encode(array("result" => $rc)); + } + /** * @return array (code => Status code, message => error message if available) * diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index e225949f2..af3877159 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1241,7 +1241,7 @@ class Pref_Feeds extends Handler_Protected {
-
diff --git a/classes/rpc.php b/classes/rpc.php index e0753a08e..2bbaf4135 100755 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -80,18 +80,6 @@ class RPC extends Handler_Protected { } } - function addfeed() { - $feed = clean($_REQUEST['feed']); - $cat = clean($_REQUEST['cat']); - $need_auth = isset($_REQUEST['need_auth']); - $login = $need_auth ? clean($_REQUEST['login']) : ''; - $pass = $need_auth ? clean($_REQUEST['pass']) : ''; - - $rc = Feeds::subscribe_to_feed($feed, $cat, $login, $pass); - - print json_encode(array("result" => $rc)); - } - function togglepref() { $key = clean($_REQUEST["key"]); set_pref($key, !get_pref($key)); diff --git a/js/App.js b/js/App.js index 3a31438c5..5c2d7726c 100644 --- a/js/App.js +++ b/js/App.js @@ -838,7 +838,7 @@ const App = { if (this.is_prefs) { this.hotkey_actions["feed_subscribe"] = () => { - CommonDialogs.quickAddFeed(); + CommonDialogs.subscribeToFeed(); }; this.hotkey_actions["create_label"] = () => { @@ -994,7 +994,7 @@ const App = { Feeds.toggleUnread(); }; this.hotkey_actions["feed_subscribe"] = () => { - CommonDialogs.quickAddFeed(); + CommonDialogs.subscribeToFeed(); }; this.hotkey_actions["feed_debug_update"] = () => { if (!Feeds.activeIsCat() && parseInt(Feeds.getActive()) > 0) { @@ -1139,7 +1139,7 @@ const App = { Feeds.search(); break; case "qmcAddFeed": - CommonDialogs.quickAddFeed(); + CommonDialogs.subscribeToFeed(); break; case "qmcDigest": window.location.href = "backend.php?op=digest"; diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index 60c3e2a84..492467b7f 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -77,15 +77,93 @@ const CommonDialogs = { return false; }, - quickAddFeed: function() { - xhrPost("backend.php", - {op: "feeds", method: "quickAddFeed"}, - (transport) => { - + subscribeToFeed: function() { + xhrJson("backend.php", + {op: "feeds", method: "subscribeToFeed"}, + (reply) => { const dialog = new fox.SingleUseDialog({ - id: "feedAddDlg", title: __("Subscribe to Feed"), - content: transport.responseText, + content: ` +
+ + ${App.FormFields.hidden("op", "feeds")} + ${App.FormFields.hidden("method", "add")} + + + + + +
+
+
+ +
+ + ${App.getInitParam('enable_feed_cats') ? + ` +
+ + ${reply.cat_select} +
+ ` : ''} +
+ + + + + +
+ +
+ + +
+ `, show_error: function (msg) { const elem = $("fadd_error_message"); @@ -114,7 +192,7 @@ const CommonDialogs = { } 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); + console.log('subscribeToFeed, backend returned:' + transport.responseText); return; }