]> git.wh0rd.org Git - tt-rss.git/commitdiff
quick add feed dialog uses prototype
authorAndrew Dolgov <fox@bah.spb.su>
Sat, 20 May 2006 14:53:41 +0000 (15:53 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sat, 20 May 2006 14:53:41 +0000 (15:53 +0100)
backend.php
functions.js
prefs.js
tt-rss.js

index 745a1a13269a4f640a3c492427ef4494992e5c75..31c1215f67b3a6dabd1c20770b0d76dbf2c2d6ce 100644 (file)
                
                        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 "<div class=\"warning\">
-                                               Feed <b>$feed_link</b> already exists in the database.
+                                               Feed <b>$feed_url</b> already exists in the database.
                                        </div>";
                                }
                        }
                        print "<div id=\"infoBoxTitle\">Subscribe to feed</div>";
                        print "<div class=\"infoBoxContents\">";
 
+                       print "<form id='feed_add_form'>";
+
+                       print "<input type=\"hidden\" name=\"op\" value=\"pref-feeds\">";
+                       print "<input type=\"hidden\" name=\"quiet\" value=\"1\">";
+                       print "<input type=\"hidden\" name=\"subop\" value=\"add\">"; 
+
                        print "<table width='100%'>
                        <tr><td>Feed URL:</td><td>
-                               <input onblur=\"javascript:enableHotkeys()\" 
+                               <input class=\"iedit\" onblur=\"javascript:enableHotkeys()\" 
                                        onkeyup=\"toggleSubmitNotEmpty(this, 'fadd_submit_btn')\"
-                                       onfocus=\"javascript:disableHotkeys()\" id=\"qafInput\"></td></tr>";
+                                       onfocus=\"javascript:disableHotkeys()\" name=\"feed_url\"></td></tr>";
                
                        if (get_pref($link, 'ENABLE_FEED_CATS')) {
                                print "<tr><td>Category:</td><td>";
-                       
-                               $result = db_query($link, "SELECT title,id FROM ttrss_feed_categories
-                                       WHERE owner_uid = ".$_SESSION["uid"]."
-                                       ORDER BY title");
-
-                               print "<select id=\"qafCat\">";
-                               print "<option id=\"0\">Uncategorized</option>";
-
-                               if (db_num_rows($result) != 0) {
-       
-                                       print "<option disabled>--------</option>";
-
-                                       while ($line = db_fetch_assoc($result)) {
-                                               printf("<option id='%d'>%s</option>", 
-                                                       $line["id"], $line["title"]);
-                                       }               
-                               }
-
-                               print "</select>";
+                               print_feed_cat_select($link, "cat_id");                 
                                print "</td></tr>";
                        }
-                       
-                       print "<tr><td colspan='2' align='right'>
+
+                       print "</table>";
+                       print "</form>";
+
+                       print "<div align='right'>
                                <input class=\"button\"
                                        id=\"fadd_submit_btn\" disabled=\"true\"
                                        type=\"submit\" onclick=\"javascript:qafAdd()\" value=\"Subscribe\">
                                <input class=\"button\"
-                                       type=\"submit\" onclick=\"javascript:feedEditCancel()\" 
-                                       value=\"Cancel\"></td></tr></table>";
+                                       type=\"submit\" onclick=\"javascript:closeInfoBox()\" 
+                                       value=\"Cancel\"></div>";
 
                }
 
index 209ca340ad540d8de0e54b79a5fb4dced2e85edf..fda1ff4e478688f34b302ec871e0e6dcaeebbe31 100644 (file)
@@ -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);
+
+}
+
index 921eb0c4477237cf916679f96143de5edc0a5c01..8fcdcff20f0d12be775182dc3a823d876c94ccc5 100644 (file)
--- 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);
index 99afd7d6e4787b9de5353bebec8ad6cc71411874..8c072653559c4711545edbacc6de2bbf89aee653 100644 (file)
--- 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...");