]> git.wh0rd.org - tt-rss.git/blobdiff - prefs.js
unify frontend hotkey handlers
[tt-rss.git] / prefs.js
index 00ba1a62bed8095bbf4f497b59f1c5d629b7c4b6..19fcc8b6a035d4572b0972be6a407e0b5b96ec54 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -1,7 +1,6 @@
 var xmlhttp = false;
 
 var active_feed_cat = false;
-var active_filter = false;
 var active_label = false;
 var active_tab = false;
 var feed_to_expand = false;
@@ -54,22 +53,7 @@ function feedlist_callback() {
 function filterlist_callback() {
        var container = document.getElementById('prefContent');
        if (xmlhttp.readyState == 4) {
-
                container.innerHTML=xmlhttp.responseText;
-
-               if (active_filter) {
-                       var row = document.getElementById("FILRR-" + active_filter);
-                       if (row) {
-                               if (!row.className.match("Selected")) {
-                                       row.className = row.className + "Selected";
-                               }               
-                       }
-                       var checkbox = document.getElementById("FICHK-" + active_filter);
-                       
-                       if (checkbox) {
-                               checkbox.checked = true;
-                       }
-               }
                notify("");
        }
 }
@@ -254,7 +238,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);
@@ -354,13 +338,14 @@ function editFilter(id) {
                return
        }
 
-       active_filter = id;
+       document.getElementById("create_filter_btn").disabled = true;
 
-       xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" +
-               param_escape(id), true);
-       xmlhttp.onreadystatechange=filterlist_callback;
-       xmlhttp.send(null);
+       selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
+       selectTableRowById('FILRR-'+id, 'FICHK-'+id, true);
 
+       xmlhttp.open("GET", "backend.php?op=pref-filters&subop=edit&id=" + param_escape(id), true);
+       xmlhttp.onreadystatechange=infobox_callback;
+       xmlhttp.send(null);
 }
 
 function editFeed(feed) {
@@ -634,6 +619,8 @@ function feedEditSave() {
                xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                xmlhttp.send(query);
 
+               closeInfoBox();
+
                return false;
 
        } catch (e) {
@@ -697,6 +684,8 @@ function labelEditCancel() {
 
 //     notify("Operation cancelled.");
 
+       closeInfoBox();
+
        xmlhttp.open("GET", "backend.php?op=pref-labels", true);
        xmlhttp.onreadystatechange=labellist_callback;
        xmlhttp.send(null);
@@ -711,7 +700,6 @@ function userEditCancel() {
        }
 
        selectPrefRows('user', false); // cleanup feed selection
-
        closeInfoBox();
 }
 
@@ -722,14 +710,10 @@ function filterEditCancel() {
                return
        }
 
-       active_filter = false;
-
-//     notify("Operation cancelled.");
-
-       xmlhttp.open("GET", "backend.php?op=pref-filters", true);
-       xmlhttp.onreadystatechange=filterlist_callback;
-       xmlhttp.send(null);
-
+       document.getElementById("create_filter_btn").disabled = false;
+       
+       selectPrefRows('filter', false); // cleanup feed selection
+       closeInfoBox();
 }
 
 function labelEditSave() {
@@ -754,14 +738,15 @@ function labelEditSave() {
                return;
        }
 
+       closeInfoBox();
+
        notify("Saving label...");
 
        active_label = false;
 
        query = Form.serialize("label_edit_form");
 
-       xmlhttp.open("GET", "backend.php?" + query, true);
-               
+       xmlhttp.open("GET", "backend.php?" + query, true);              
        xmlhttp.onreadystatechange=labellist_callback;
        xmlhttp.send(null);
 
@@ -782,7 +767,9 @@ function userEditSave() {
        }
        
        notify("Saving user...");
-       
+
+       closeInfoBox();
+
        var query = Form.serialize("user_edit_form");
        
        xmlhttp.open("GET", "backend.php?" + query, true);                      
@@ -807,10 +794,12 @@ function filterEditSave() {
 
        notify("Saving filter...");
 
-       active_filter = false;
-
        var query = Form.serialize("filter_edit_form");
 
+       closeInfoBox();
+
+       document.getElementById("create_filter_btn").disabled = false;
+
        xmlhttp.open("GET", "backend.php?" + query, true);
        xmlhttp.onreadystatechange=filterlist_callback;
        xmlhttp.send(null);
@@ -1130,9 +1119,11 @@ function selectTab(id, noupdate) {
 
                notify("Loading, please wait...", true);
 
+               // close active infobox if needed
+               closeInfoBox();
+
                // clean up all current selections, just in case
                active_feed_cat = false;
-               active_filter = false;
                active_label = false;
 
                if (id == "feedConfig") {
@@ -1319,7 +1310,7 @@ function browserToggleExpand(id) {
 
 function validateNewPassword(form) {
        if (form.OLD_PASSWORD.value == "") {
-               alert("Current password cannot be blank");
+               alert("Old password cannot be blank");
                return false;
        }
        if (form.NEW_PASSWORD.value == "") {