]> git.wh0rd.org - tt-rss.git/blobdiff - prefs.js
use prototype in form editor
[tt-rss.git] / prefs.js
index 85c707e618323df04c305b75f2dcd7bb8ee47e01..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("");
        }
 }
 
@@ -406,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=" +
@@ -666,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() {
@@ -703,73 +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");
-
-               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 fcat_id = 0;
-       
-               if (fcat) {     
-                       fcat_id = fcat[fcat.selectedIndex].id;
-               }
+               // FIXME: add parameter validation
 
-               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 query = Form.serialize("edit_feed_form");
 
-               if (!isValidURL(link)) {
-                       alert("Feed URL is invalid.");
-                       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);
        } 
@@ -1297,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") {