]> git.wh0rd.org - tt-rss.git/blobdiff - prefs.js
use prototype in form editor
[tt-rss.git] / prefs.js
index aa0d0a2e1371efc05b8b885d7bb871c418855284..c9001e8a07b55e2d074a24d2bf4d1e4a291bb5bd 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -62,7 +62,7 @@ function feedlist_callback() {
                                        checkbox.checked = true;
                                }
                        }
-//                     p_notify("");
+                       notify("");
                } catch (e) {
                        exception_error("feedlist_callback", e);
                }
@@ -88,7 +88,7 @@ function filterlist_callback() {
                                checkbox.checked = true;
                        }
                }
-//             p_notify("");
+               notify("");
        }
 }
 
@@ -110,7 +110,7 @@ function labellist_callback() {
                                checkbox.checked = true;
                        }
                }
-//             p_notify("");
+               notify("");
        }
 }
 
@@ -118,7 +118,7 @@ function feed_browser_callback() {
        var container = document.getElementById('prefContent');
        if (xmlhttp.readyState == 4) {
                container.innerHTML=xmlhttp.responseText;
-//             p_notify("");
+               notify("");
        }
 }
 
@@ -140,8 +140,7 @@ function userlist_callback() {
                                checkbox.checked = true;
                        }
                } 
-
-//             p_notify("");
+               notify("");
        }
 }
 
@@ -150,8 +149,8 @@ function prefslist_callback() {
        if (xmlhttp.readyState == 4) {
 
                container.innerHTML=xmlhttp.responseText;
-
-//             p_notify("");
+               
+               notify("");
        }
 }
 
@@ -282,8 +281,7 @@ function addFeed() {
 
        if (link.value.length == 0) {
                alert("Error: No feed URL given.");
-       } else if (link.value.match("http://") == null && 
-                       link.value.match("https://") == null) {
+       } else if (!isValidURL(link.value)) {
                alert("Error: Invalid feed URL.");
        } else {
                notify("Adding feed...");
@@ -407,15 +405,8 @@ function editFeed(feed) {
 
        active_feed = feed;
 
-/*     xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=edit&id=" +
-               param_escape(feed), true);
-       xmlhttp.onreadystatechange=feedlist_callback;
-       xmlhttp.send(null); */
-
+       // clean selection from all rows & select row being edited
        selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
-//     selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-'+feed, 'FRCHK-'+feed, 
-//             true, false);
-
        selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true);
 
        xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
@@ -608,11 +599,11 @@ function removeSelectedFeeds() {
 
        if (sel_rows.length > 0) {
 
-               var ok = confirm("Unsubscribe selected feeds?");
+               var ok = confirm("Unsubscribe from selected feeds?");
 
                if (ok) {
 
-                       notify("Removing selected feeds...");
+                       notify("Unsubscribing from selected feeds...");
        
                        xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
                                param_escape(sel_rows.toString()), true);
@@ -667,14 +658,9 @@ function feedEditCancel() {
 
        closeInfoBox();
 
-       active_feed = false;
-
-//     notify("Operation cancelled.");
-
-/*     xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
-       xmlhttp.onreadystatechange=feedlist_callback;
-       xmlhttp.send(null); */
+       selectPrefRows('feed', false); // cleanup feed selection
 
+       active_feed = false;
 }
 
 function feedCatEditCancel() {
@@ -704,68 +690,20 @@ function feedEditSave() {
                        printLockingError();
                        return
                }
-       
-               var link = document.getElementById("iedit_link").value;
-               var title = document.getElementById("iedit_title").value;
-               var upd_intl = document.getElementById("iedit_updintl");
 
-               upd_intl = upd_intl[upd_intl.selectedIndex].id;
-                       
-               var purge_intl = document.getElementById("iedit_purgintl");
+               // FIXME: add parameter validation
 
-               purge_intl = purge_intl[purge_intl.selectedIndex].id;
-               
-               var fcat = document.getElementById("iedit_fcat");
-
-               var is_pvt = document.getElementById("iedit_private");
-               var is_rtl = document.getElementById("iedit_rtl");
-
-               if (is_pvt) {
-                       is_pvt = is_pvt.checked;
-               }
-
-               if (is_rtl) {
-                       is_rtl = is_rtl.checked;
-               }
+               var query = Form.serialize("edit_feed_form");
 
-               var fcat_id = 0;
-       
-               if (fcat) {     
-                       fcat_id = fcat[fcat.selectedIndex].id;
-               }
-
-               var pfeed = document.getElementById("iedit_parent_feed");
-               var parent_feed_id = pfeed[pfeed.selectedIndex].id;
-       
-               if (link.length == 0) {
-                       notify("Feed link cannot be blank.");
-                       return;
-               }
-       
-               if (title.length == 0) {
-                       notify("Feed title cannot be blank.");
-                       return;
-               }
-       
-               var auth_login = document.getElementById("iedit_login").value;
-               var auth_pass = document.getElementById("iedit_pass").value;
-       
                active_feed = false;
-       
-               notify("Saving feed...");
 
-               var query = "op=pref-feeds&subop=editSave&id=" +
-                       feed + "&l=" + param_escape(link) + "&t=" + param_escape(title) +
-                       "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) +
-                       "&catid=" + param_escape(fcat_id) + "&login=" + param_escape(auth_login) +                      
-                       "&pfeed=" + param_escape(parent_feed_id) + "&pass=" + param_escape(auth_pass) +
-                       "&is_pvt=" + param_escape(is_pvt) + "&is_rtl=" + param_escape(is_rtl);
+               notify("Saving feed...");
 
                xmlhttp.open("POST", "backend.php", true);
                xmlhttp.onreadystatechange=feedlist_callback;
                xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
-               xmlhttp.send(query); 
-       
+               xmlhttp.send(query);
+
        } catch (e) {
                exception_error("feedEditSave", e);
        } 
@@ -1214,7 +1152,7 @@ function localPiggieFunction(enable) {
                var piggie = document.getElementById("piggie");
                piggie.style.display = "block";
 
-               if (navigator.userAgent.match("Firefox") && Math.random(1) > 0.5) {     
+               if (navigator.userAgent.match("Gecko") && Math.random(1) > 0.5) {       
                        piggie2_callback();
                } else {
                        piggie_callback();
@@ -1293,6 +1231,15 @@ function selectTab(id, noupdate) {
 
        if (!noupdate) {
 
+               notify("Loading, please wait...", true);
+
+               // clean up all current selections, just in case
+               active_feed = false;
+               active_feed_cat = false;
+               active_filter = false;
+               active_label = false;
+               active_user = false;
+
                if (id == "feedConfig") {
                        updateFeedList();
                } else if (id == "filterConfig") {
@@ -1447,6 +1394,11 @@ function browserToggleExpand(id) {
                        d.style.display = "none";
                } */
 
+               if (!xmlhttp_ready(xmlhttp)) {
+                       printLockingError();
+                       return
+               }
+
                var d = document.getElementById("BRDET-" + id);
 
                if (d.style.display == "block") {               
@@ -1456,6 +1408,9 @@ function browserToggleExpand(id) {
        
                        feed_to_expand = id;
 
+                       d.style.display = "block";
+                       d.innerHTML = "Loading, please wait...";
+
                        xmlhttp.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
                                + param_escape(id), true);
                        xmlhttp.onreadystatechange=expand_feed_callback;