From 07eb9178463a08ae4aaad49ae53ea92909dfbfa4 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 20 May 2006 15:53:41 +0100 Subject: [PATCH] quick add feed dialog uses prototype --- backend.php | 49 ++++++++++++++++++++----------------------------- functions.js | 24 ++++++++++++++++++++++++ prefs.js | 2 +- tt-rss.js | 41 ----------------------------------------- 4 files changed, 45 insertions(+), 71 deletions(-) diff --git a/backend.php b/backend.php index 745a1a132..31c1215f6 100644 --- a/backend.php +++ b/backend.php @@ -1626,14 +1626,14 @@ if (!WEB_DEMO_MODE) { - $feed_link = db_escape_string(trim($_GET["link"])); - $cat_id = db_escape_string($_GET["cid"]); + $feed_url = db_escape_string(trim($_GET["feed_url"])); + $cat_id = db_escape_string($_GET["cat_id"]); - if (subscribe_to_feed($link, $feed_link, $cat_id)) { + if (subscribe_to_feed($link, $feed_url, $cat_id)) { print "Added feed."; } else { print "
- Feed $feed_link already exists in the database. + Feed $feed_url already exists in the database.
"; } } @@ -2643,43 +2643,34 @@ print "
Subscribe to feed
"; print "
"; + print "
"; + + print ""; + print ""; + print ""; + print ""; + onfocus=\"javascript:disableHotkeys()\" name=\"feed_url\">"; if (get_pref($link, 'ENABLE_FEED_CATS')) { print ""; } - - print "
Feed URL: -
Category:"; - - $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories - WHERE owner_uid = ".$_SESSION["uid"]." - ORDER BY title"); - - print ""; + print_feed_cat_select($link, "cat_id"); print "
+ + print "
"; + print "
"; + + print "
"; + type=\"submit\" onclick=\"javascript:closeInfoBox()\" + value=\"Cancel\">
"; } diff --git a/functions.js b/functions.js index 209ca340a..fda1ff4e4 100644 --- a/functions.js +++ b/functions.js @@ -1007,3 +1007,27 @@ function toggleSubmitNotEmpty(e, submit_id) { function isValidURL(s) { return s.match("http://") != null || s.match("https://") != null; } + +function qafAdd() { + + if (!xmlhttp_ready(xmlhttp)) { + printLockingError(); + return + } + + notify("Adding feed..."); + + closeInfoBox(); + + var feeds_doc = window.frames["feeds-frame"].document; + + feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait..."; + + var query = Form.serialize("feed_add_form"); + + xmlhttp.open("GET", "backend.php?" + query, true); + xmlhttp.onreadystatechange=dlg_frefresh_callback; + xmlhttp.send(null); + +} + diff --git a/prefs.js b/prefs.js index 921eb0c44..8fcdcff20 100644 --- a/prefs.js +++ b/prefs.js @@ -254,7 +254,7 @@ function addFeed() { } else { notify("Adding feed..."); - xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" + + xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&feed_url=" + param_escape(link.value), true); xmlhttp.onreadystatechange=feedlist_callback; xmlhttp.send(null); diff --git a/tt-rss.js b/tt-rss.js index 99afd7d6e..8c0726535 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -510,47 +510,6 @@ function quickMenuGo(opid) { } } -function qafAdd() { - - if (!xmlhttp_ready(xmlhttp)) { - printLockingError(); - return - } - - var link = document.getElementById("qafInput"); - - if (link.value.length == 0) { - alert("Error: No feed URL given."); - } else if (!isValidURL(link.value)) { - alert("Error: Invalid feed URL."); - } else { - notify("Adding feed..."); - - closeInfoBox(); - - var cat = document.getElementById("qafCat"); - var cat_id = ""; - - if (cat) { - cat_id = cat[cat.selectedIndex].id; - } else { - cat_id = 0; - } - - var feeds_doc = window.frames["feeds-frame"].document; - - feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait..."; - - xmlhttp.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=add&link=" + - param_escape(link.value) + "&cid=" + param_escape(cat_id), true); - xmlhttp.onreadystatechange=dlg_frefresh_callback; - xmlhttp.send(null); - - link.value = ""; - - } -} - function qfdDelete(feed_id) { notify("Removing feed...");