]> git.wh0rd.org - tt-rss.git/blobdiff - prefs.js
prefs: some async work (2)
[tt-rss.git] / prefs.js
index ad64f4812cefed5fdc7758607fe53c6996d9289e..e05de8c8878e9d73e1d395521f1ad82a42cedbc1 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -1,9 +1,7 @@
 var xmlhttp = false;
 
 var active_feed_cat = false;
-var active_label = false;
 var active_tab = false;
-var feed_to_expand = false;
 
 var xmlhttp = Ajax.getTransport();
 
@@ -55,49 +53,14 @@ function replace_pubkey_callback() {
        }
 }
 
-function expand_feed_callback() {
-       if (xmlhttp.readyState == 4) {
-               try {   
-                       var container = document.getElementById("BRDET-" + feed_to_expand);     
-                       container.innerHTML=xmlhttp.responseText;
-//                     container.style.display = "block";
-                       Effect.Appear(container, {duration : 0.5});
-               } catch (e) {
-                       exception_error("expand_feed_callback", e);
-               }
-       }
-}
-
 function feedlist_callback() {
        if (xmlhttp.readyState == 4) {
-               try {   
-                       var container = document.getElementById('prefContent'); 
-                       container.innerHTML=xmlhttp.responseText;
-                       selectTab("feedConfig", true);
-
-                       if (caller_subop) {
-                               var tuple = caller_subop.split(":");
-                               if (tuple[0] == 'editFeed') {
-                                       window.setTimeout('editFeed('+tuple[1]+')', 100);
-                               }                               
-
-                               caller_subop = false;
-                       }
-                       if (typeof correctPNG != 'undefined') {
-                               correctPNG();
-                       }
-                       notify("");
-               } catch (e) {
-                       exception_error("feedlist_callback", e);
-               }
+               return feedlist_callback2(xmlhttp);
        }
 }
 
-/* stub for subscription dialog */
-
-function dlg_frefresh_callback(transport) {
-
-       try {
+function feedlist_callback2(transport) {
+       try {   
                var container = document.getElementById('prefContent'); 
                container.innerHTML=transport.responseText;
                selectTab("feedConfig", true);
@@ -114,10 +77,17 @@ function dlg_frefresh_callback(transport) {
                        correctPNG();
                }
                notify("");
+               remove_splash();
+
        } catch (e) {
-               exception_error("feedlist_callback", e);
+               exception_error("feedlist_callback2", e);
        }
+}
+
+/* stub for subscription dialog */
 
+function dlg_frefresh_callback(transport) {
+       return feedlist_callback2(transport);
 }
 
 function filterlist_callback() {
@@ -128,31 +98,40 @@ function filterlist_callback() {
                        correctPNG();
                }
                notify("");
+               remove_splash();
        }
 }
 
-function labellist_callback() {
-       var container = document.getElementById('prefContent');
-       if (xmlhttp.readyState == 4) {
-               closeInfoBox();
-               container.innerHTML=xmlhttp.responseText;
-               if (active_label) {
-                       var row = document.getElementById("LILRR-" + active_label);
-                       if (row) {
-                               if (!row.className.match("Selected")) {
-                                       row.className = row.className + "Selected";
-                               }               
+function labellist_callback2(transport) {
+
+       try {
+
+               var container = document.getElementById('prefContent');
+                       closeInfoBox();
+                       container.innerHTML=transport.responseText;
+       
+                       if (document.getElementById("prefLabelList")) {
+                               var elems = document.getElementById("prefLabelList").getElementsByTagName("SPAN");
+
+                               for (var i = 0; i < elems.length; i++) {
+                                       if (elems[i].id && elems[i].id.match("LILT-")) {
+
+                                               var id = elems[i].id.replace("LILT-", "");
+                                                       new Ajax.InPlaceEditor(elems[i],
+                                                       'backend.php?op=pref-labels&subop=save&id=' + id,
+                                                       {cols: 20, rows: 1});
+                                       }
+                               }
                        }
-                       var checkbox = document.getElementById("LICHK-" + active_label);
-                       
-                       if (checkbox) {
-                               checkbox.checked = true;
+       
+                       if (typeof correctPNG != 'undefined') {
+                               correctPNG();
                        }
-               }
-               if (typeof correctPNG != 'undefined') {
-                       correctPNG();
-               }
-               notify("");
+                       notify("");
+                       remove_splash();
+
+       } catch (e) {
+               exception_error("labellist_callback2", e);
        }
 }
 
@@ -161,6 +140,7 @@ function feed_browser_callback() {
        if (xmlhttp.readyState == 4) {
                container.innerHTML=xmlhttp.responseText;
                notify("");
+               remove_splash();
        }
 }
 
@@ -169,16 +149,16 @@ function userlist_callback() {
        if (xmlhttp.readyState == 4) {
                container.innerHTML=xmlhttp.responseText;
                notify("");
+               remove_splash();
        }
 }
 
 function prefslist_callback() {
        var container = document.getElementById('prefContent');
        if (xmlhttp.readyState == 4) {
-
                container.innerHTML=xmlhttp.responseText;
-               
                notify("");
+               remove_splash();
        }
 }
 
@@ -226,28 +206,32 @@ function changepass_callback() {
        }
 }
 
-function infobox_feed_cat_callback() {
-       if (xmlhttp.readyState == 4) {
-               try {
-
-                       infobox_callback();
-
-                       if (document.getElementById("prefFeedCatList")) {
-                               var elems = document.getElementById("prefFeedCatList").getElementsByTagName("SPAN");
+function init_cat_inline_editor() {
+       try {
 
-                               for (var i = 0; i < elems.length; i++) {
-                                       if (elems[i].id && elems[i].id.match("FCATT-")) {
-                                               var cat_id = elems[i].id.replace("FCATT-", "");
+               if (document.getElementById("prefFeedCatList")) {
+                       var elems = document.getElementById("prefFeedCatList").getElementsByTagName("SPAN");
 
+                       for (var i = 0; i < elems.length; i++) {
+                               if (elems[i].id && elems[i].id.match("FCATT-")) {
+                                       var cat_id = elems[i].id.replace("FCATT-", "");
                                                new Ajax.InPlaceEditor(elems[i],
-                                                       'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id);
-                                       }
+                                               'backend.php?op=pref-feeds&subop=editCats&action=save&cid=' + cat_id);
                                }
                        }
-
-               } catch (e) {
-                       exception_error("infobox_feed_cat_callback", e);
                }
+
+       } catch (e) {
+               exception_error("init_cat_inline_editor", e);
+       }
+}
+
+function infobox_feed_cat_callback2(transport) {
+       try {
+               infobox_callback2(transport);
+               init_cat_inline_editor();
+       } catch (e) {
+               exception_error("infobox_feed_cat_callback2", e);
        }
 }
 
@@ -299,59 +283,62 @@ function updateUsersList(sort_key) {
 
 function addLabel() {
 
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
-
-       var form = document.forms['label_edit_form'];
-
-       var sql_exp = form.sql_exp.value;
-       var description = form.description.value;
+       try {
 
-       if (sql_exp == "") {
-               alert(__("Can't create label: missing SQL expression."));
-               return false;
-       }
+               var caption = prompt(__("Please enter label caption:"), "");
+       
+               if (caption == null) { 
+                       return false;
+               }
+       
+               if (caption == "") {
+                       alert(__("Can't create label: missing caption."));
+                       return false;
+               }
+       
+               // we can be called from some other tab
+               active_tab = "labelConfig";
+       
+               query = "backend.php?op=pref-labels&subop=add&caption=" + 
+                       param_escape(caption);
+       
+               new Ajax.Request(query, {
+                       onComplete: function(transport) {
+                                       infobox_submit_callback2(transport);
+                               } });
 
-       if (description == "") {
-               alert(__("Can't create label: missing caption."));
-               return false;
+       } catch (e) {
+               exception_error("addLabel", e);
        }
-
-       var query = Form.serialize("label_edit_form");
-
-       // we can be called from some other tab
-       active_tab = "labelConfig";
-
-       xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&" + query, true);                     
-       xmlhttp.onreadystatechange=infobox_submit_callback;
-       xmlhttp.send(null);
 }
 
 function addFeed() {
 
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
-
-       var link = document.getElementById("fadd_link");
-
-       if (link.value.length == 0) {
-               alert(__("Error: No feed URL given."));
-       } else if (!isValidURL(link.value)) {
-               alert(__("Error: Invalid feed URL."));
-       } else {
-               notify_progress("Adding feed...");
-
-               xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
-                       param_escape(link.value), true);
-               xmlhttp.onreadystatechange=feedlist_callback;
-               xmlhttp.send(null);
+       try {
 
-               link.value = "";
+               var link = document.getElementById("fadd_link");
+       
+               if (link.value.length == 0) {
+                       alert(__("Error: No feed URL given."));
+               } else if (!isValidURL(link.value)) {
+                       alert(__("Error: Invalid feed URL."));
+               } else {
+                       notify_progress("Adding feed...");
+       
+                       var query = "backend.php?op=pref-feeds&subop=add&from=tt-rss&feed_url=" +
+                               param_escape(link.value);
+       
+                       new Ajax.Request(query, {
+                               onComplete: function(transport) {
+                                               feedlist_callback2(transport);
+                                       } });
+       
+                       link.value = "";
+       
+               }
 
+       } catch (e) {
+               exception_error("addFeed", e);
        }
 
 }
@@ -370,10 +357,13 @@ function addFeedCat() {
        } else {
                notify_progress("Adding feed category...");
 
-               xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
-                       param_escape(cat.value), true);
-               xmlhttp.onreadystatechange=infobox_callback;
-               xmlhttp.send(null);
+               var query = "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
+                       param_escape(cat.value);
+
+               new Ajax.Request(query, {
+                       onComplete: function(transport) {
+                                       infobox_feed_cat_callback2(transport);
+                               } });
 
                link.value = "";
 
@@ -405,124 +395,83 @@ function addUser() {
 
 }
 
-function editLabel(id) {
-
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
-
-       disableHotkeys();
+function editUser(id) {
 
-       notify_progress("Loading, please wait...");
+       try {
 
-       document.getElementById("label_create_btn").disabled = true;
+               disableHotkeys();
 
-       active_label = id;
+               notify_progress("Loading, please wait...");
 
-       selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
-       selectTableRowById('LILRR-'+id, 'LICHK-'+id, true);
+               selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
+               selectTableRowById('UMRR-'+id, 'UMCHK-'+id, true);
 
-       xmlhttp.open("GET", "backend.php?op=pref-labels&subop=edit&id=" +
-               param_escape(id), true);
-       xmlhttp.onreadystatechange=infobox_callback;
-       xmlhttp.send(null);
+               disableContainerChildren("userOpToolbar", false);
 
-}
+               var query = "backend.php?op=pref-users&subop=edit&id=" +
+                       param_escape(id);
 
-function editUser(id) {
+               new Ajax.Request(query, {
+                       onComplete: function(transport) {
+                                       infobox_callback2(transport);
+                               } });
 
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
+       } catch (e) {
+               exception_error("editUser", e);
        }
-
-       disableHotkeys();
-
-       notify_progress("Loading, please wait...");
-
-       selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
-       selectTableRowById('UMRR-'+id, 'UMCHK-'+id, true);
-
-       xmlhttp.open("GET", "backend.php?op=pref-users&subop=edit&id=" +
-               param_escape(id), true);
-       xmlhttp.onreadystatechange=infobox_callback;
-       xmlhttp.send(null);
-
+               
 }
 
 function editFilter(id) {
 
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
-
-       disableHotkeys();
-
-       notify_progress("Loading, please wait...");
-
-       document.getElementById("create_filter_btn").disabled = true;
-
-       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) {
+       try {
 
-//     notify("Editing feed...");
+               disableHotkeys();
 
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
+               notify_progress("Loading, please wait...");
 
-       disableHotkeys();
+               disableContainerChildren("filterOpToolbar", false);
 
-       notify_progress("Loading, please wait...");
+               selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
+               selectTableRowById('FILRR-'+id, 'FICHK-'+id, true);
 
-       document.getElementById("subscribe_to_feed_btn").disabled = true;
+               var query = "backend.php?op=pref-filters&subop=edit&id=" + 
+                       param_escape(id);
 
-       try {
-               document.getElementById("top25_feeds_btn").disabled = true;
+               new Ajax.Request(query, {
+                       onComplete: function(transport) {
+                                       infobox_callback2(transport);
+                               } });
        } catch (e) {
-               // this button is not always available, no-op if not found
+               exception_error("editFilter", e);
        }
-
-       // clean selection from all rows & select row being edited
-       selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
-       selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true);
-
-       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editfeed&id=" +
-               param_escape(feed), true);
-
-       xmlhttp.onreadystatechange=infobox_callback;
-       xmlhttp.send(null);
-
 }
 
-function editFeedCat(cat) {
-
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
-
-       disableHotkeys();
-
-       notify_progress("Loading, please wait...");
+function editFeed(feed) {
 
-       active_feed_cat = cat;
+       try {
 
-       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
-               param_escape(cat), true);
-       xmlhttp.onreadystatechange=infobox_callback;
-       xmlhttp.send(null);
+               disableHotkeys();
+       
+               notify_progress("Loading, please wait...");
+       
+               // clean selection from all rows & select row being edited
+               selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
+               selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true);
+       
+               disableContainerChildren("feedOpToolbar", false);
+       
+               var query = "backend.php?op=pref-feeds&subop=editfeed&id=" +
+                       param_escape(feed);
+       
+               new Ajax.Request(query, {
+                       onComplete: function(transport) {
+                                       infobox_callback2(transport);
+                               } });
 
+       } catch (e) {
+               exception_error("editFeed", e);
+       }
 }
 
 function getSelectedLabels() {
@@ -545,36 +494,9 @@ function getSelectedFeedCats() {
        return getSelectedTableRowIds("prefFeedCatList", "FCATR");
 }
 
-function getSelectedFeedsFromBrowser() {
-
-       var list = document.getElementById("browseFeedList");
-       if (!list) list = document.getElementById("browseBigFeedList");
-
-       var selected = new Array();
-       
-       for (i = 0; i < list.childNodes.length; i++) {
-               var child = list.childNodes[i];
-               if (child.id && child.id.match("FBROW-")) {
-                       var id = child.id.replace("FBROW-", "");
-                       
-                       var cb = document.getElementById("FBCHK-" + id);
-
-                       if (cb.checked) {
-                               selected.push(id);
-                       }
-               }
-       }
-
-       return selected;
-}
 
 function removeSelectedLabels() {
 
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
-
        var sel_rows = getSelectedLabels();
 
        if (sel_rows.length > 0) {
@@ -584,10 +506,14 @@ function removeSelectedLabels() {
                if (ok) {
                        notify_progress("Removing selected labels...");
        
-                       xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
-                               param_escape(sel_rows.toString()), true);
-                       xmlhttp.onreadystatechange=labellist_callback;
-                       xmlhttp.send(null);
+                       var query = "backend.php?op=pref-labels&subop=remove&ids="+
+                               param_escape(sel_rows.toString());
+
+                       new Ajax.Request(query, {
+                               onComplete: function(transport) {
+                                               labellist_callback2(transport);
+                                       } });
+
                }
        } else {
                alert(__("No labels are selected."));
@@ -656,31 +582,33 @@ function removeSelectedFilters() {
 
 function removeSelectedFeeds() {
 
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
-
-       var sel_rows = getSelectedFeeds();
-
-       if (sel_rows.length > 0) {
-
-               var ok = confirm(__("Unsubscribe from selected feeds?"));
-
-               if (ok) {
+       try {
 
-                       notify_progress("Unsubscribing from selected feeds...");
+               var sel_rows = getSelectedFeeds();
        
-                       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
-                               param_escape(sel_rows.toString()), true);
-                       xmlhttp.onreadystatechange=feedlist_callback;
-                       xmlhttp.send(null);
+               if (sel_rows.length > 0) {
+       
+                       var ok = confirm(__("Unsubscribe from selected feeds?"));
+       
+                       if (ok) {
+       
+                               notify_progress("Unsubscribing from selected feeds...");
+               
+                               var query = "backend.php?op=pref-feeds&subop=remove&ids="+
+                                       param_escape(sel_rows.toString());
+       
+                               new Ajax.Request(query, {
+                                       onComplete: function(transport) {
+                                                       feedlist_callback2(transport);
+                                               } });
+                       }
+       
+               } else {
+                       alert(__("No feeds are selected."));
                }
 
-       } else {
-
-               alert(__("No feeds are selected."));
-
+       } catch (e) {
+               exception_error("removeSelectedFeeds", e);
        }
        
        return false;
@@ -770,10 +698,14 @@ function removeSelectedFeedCats() {
                if (ok) {
                        notify_progress("Removing selected categories...");
        
-                       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
-                               param_escape(sel_rows.toString()), true);
-                       xmlhttp.onreadystatechange=infobox_callback;
-                       xmlhttp.send(null);
+                       var query = "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
+                               param_escape(sel_rows.toString());
+
+                       new Ajax.Request(query, {
+                               onComplete: function(transport) {
+                                       infobox_feed_cat_callback2(transport);
+                               } });
+
                }
 
        } else {
@@ -806,24 +738,6 @@ function feedEditCancel() {
        return false;
 }
 
-function feedCatEditCancel() {
-
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
-
-       active_feed_cat = false;
-
-//     notify("Operation cancelled.");
-
-       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
-       xmlhttp.onreadystatechange=infobox_callback;
-       xmlhttp.send(null);
-
-       return false;
-}
-
 function feedEditSave() {
 
        try {
@@ -853,45 +767,6 @@ function feedEditSave() {
        } 
 }
 
-function feedCatEditSave() {
-
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
-
-       notify_progress("Saving category...");
-
-       var query = Form.serialize("feed_cat_edit_form");
-
-       xmlhttp.open("GET", "backend.php?" + query, true);
-       xmlhttp.onreadystatechange=infobox_callback;
-       xmlhttp.send(null);
-
-       active_feed_cat = false;
-
-       return false;
-}
-
-function labelEditCancel() {
-
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
-
-       try {
-               document.getElementById("label_create_btn").disabled = false;
-               selectPrefRows('label', false); // cleanup feed selection
-       } catch (e) { }
-
-       active_label = false;
-
-       closeInfoBox();
-
-       return false;
-}
-
 function userEditCancel() {
 
        if (!xmlhttp_ready(xmlhttp)) {
@@ -922,46 +797,6 @@ function filterEditCancel() {
        return false;
 }
 
-function labelEditSave() {
-
-       var label = active_label;
-
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
-
-/*     if (!is_opera()) {
-
-               var sql_exp = document.forms["label_edit_form"].sql_exp.value;
-               var description = document.forms["label_edit_form"].description.value;
-       
-               if (sql_exp.length == 0) {
-                       alert("SQL Expression cannot be blank.");
-                       return false;
-               }
-       
-               if (description.length == 0) {
-                       alert("Caption field cannot be blank.");
-                       return false;
-               }
-       } */
-
-       closeInfoBox();
-
-       notify_progress("Saving label...");
-
-       active_label = false;
-
-       query = Form.serialize("label_edit_form");
-
-       xmlhttp.open("GET", "backend.php?" + query, true);              
-       xmlhttp.onreadystatechange=labellist_callback;
-       xmlhttp.send(null);
-
-       return false;
-}
-
 function userEditSave() {
 
        if (!xmlhttp_ready(xmlhttp)) {
@@ -1021,24 +856,6 @@ function filterEditSave() {
        return false;
 }
 
-function editSelectedLabel() {
-       var rows = getSelectedLabels();
-
-       if (rows.length == 0) {
-               alert(__("No labels are selected."));
-               return;
-       }
-
-       if (rows.length > 1) {
-               alert(__("Please select only one label."));
-               return;
-       }
-
-       notify("");
-
-       editLabel(rows[0]);
-
-}
 
 function editSelectedUser() {
        var rows = getSelectedUsers();
@@ -1058,40 +875,7 @@ function editSelectedUser() {
        editUser(rows[0]);
 }
 
-function resetSelectedUserPass() {
-       var rows = getSelectedUsers();
-
-       if (rows.length == 0) {
-               alert(__("No users are selected."));
-               return;
-       }
-
-       if (rows.length > 1) {
-               alert(__("Please select only one user."));
-               return;
-       }
-
-       var ok = confirm(__("Reset password of selected user?"));
-
-       if (ok) {
-               notify_progress("Resetting password for selected user...");
-       
-               var id = rows[0];
-       
-               xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
-                       param_escape(id), true);
-               xmlhttp.onreadystatechange=userlist_callback;
-               xmlhttp.send(null);
-       }
-}
-
-function selectedUserDetails() {
-
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
-
+function resetSelectedUserPass() {
        var rows = getSelectedUsers();
 
        if (rows.length == 0) {
@@ -1104,46 +888,52 @@ function selectedUserDetails() {
                return;
        }
 
-       notify_progress("Loading, please wait...");
-
-       var id = rows[0];
-
-       xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
-       xmlhttp.onreadystatechange=infobox_callback;
-       xmlhttp.send(null);
+       var ok = confirm(__("Reset password of selected user?"));
 
+       if (ok) {
+               notify_progress("Resetting password for selected user...");
+       
+               var id = rows[0];
+       
+               xmlhttp.open("GET", "backend.php?op=pref-users&subop=resetPass&id=" +
+                       param_escape(id), true);
+               xmlhttp.onreadystatechange=userlist_callback;
+               xmlhttp.send(null);
+       }
 }
 
-function selectedFeedDetails() {
-
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
+function selectedUserDetails() {
 
-       var rows = getSelectedFeeds();
+       try {
 
-       if (rows.length == 0) {
-               alert(__("No feeds are selected."));
-               return;
-       }
+               var rows = getSelectedUsers();
+       
+               if (rows.length == 0) {
+                       alert(__("No users are selected."));
+                       return;
+               }
+       
+               if (rows.length > 1) {
+                       alert(__("Please select only one user."));
+                       return;
+               }
+       
+               notify_progress("Loading, please wait...");
+       
+               var id = rows[0];
+       
+               var query = "backend.php?op=pref-users&subop=user-details&id=" + id;
 
-       if (rows.length > 1) {
-               alert(__("Please select only one feed."));
-               return;
+               new Ajax.Request(query, {
+                       onComplete: function(transport) {
+                                       infobox_callback2(transport);
+                               } });
+       } catch (e) {
+               exception_error("selectedUserDetails", e);
        }
-
-//     var id = rows[0];
-
-       notify("");
-
-       xmlhttp.open("GET", "backend.php?op=feed-details&id=" + 
-               param_escape(rows.toString()), true);
-       xmlhttp.onreadystatechange=infobox_callback;
-       xmlhttp.send(null);
-
 }
 
+
 function editSelectedFilter() {
        var rows = getSelectedFilters();
 
@@ -1183,26 +973,36 @@ function editSelectedFeed() {
 
 }
 
-function editSelectedFeedCat() {
-       var rows = getSelectedFeedCats();
-
-       if (rows.length == 0) {
-               alert(__("No categories are selected."));
-               return;
-       }
-
-       if (rows.length > 1) {
-               alert(__("Please select only one category."));
-               return;
-       }
+function editSelectedFeeds() {
 
-       notify("");
+       try {
+               var rows = getSelectedFeeds();
+       
+               if (rows.length == 0) {
+                       alert(__("No feeds are selected."));
+                       return;
+               }
+       
+               notify("");
+       
+               disableHotkeys();
+       
+               notify_progress("Loading, please wait...");
+       
+               var query = "backend.php?op=pref-feeds&subop=editfeeds&ids=" +
+                       param_escape(rows.toString());
 
-       editFeedCat(rows[0]);
+               new Ajax.Request(query, {
+                       onComplete: function(transport) {
+                                       infobox_callback2(transport);
+                               } });
 
+       } catch (e) {
+               exception_error("editSelectedFeeds", e);
+       }
 }
 
-function localPiggieFunction(enable) {
+function piggie(enable) {
        if (enable) {
                debug("I LOVEDED IT!");
                var piggie = document.getElementById("piggie");
@@ -1247,20 +1047,24 @@ function updateFilterList(sort_key) {
 
 function updateLabelList(sort_key) {
 
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
+       try {
 
-       var label_search = document.getElementById("label_search");
-       var search = "";
-       if (label_search) { search = label_search.value; }
+               var label_search = document.getElementById("label_search");
+               var search = "";
+               if (label_search) { search = label_search.value; }
+       
+               var query = "backend.php?op=pref-labels&sort=" + 
+                       param_escape(sort_key) +
+                       "&search=" + param_escape(search);
+       
+               new Ajax.Request(query, {
+                       onComplete: function(transport) {
+                               labellist_callback2(transport);
+                       } });
 
-       xmlhttp.open("GET", "backend.php?op=pref-labels&sort=" + 
-               param_escape(sort_key) +
-               "&search=" + param_escape(search), true);
-       xmlhttp.onreadystatechange=labellist_callback;
-       xmlhttp.send(null);
+       } catch (e) {
+               exception_error("updateLabelList", e);
+       }
 }
 
 function updatePrefsList() {
@@ -1305,7 +1109,6 @@ function selectTab(id, noupdate, subop) {
        
                        // clean up all current selections, just in case
                        active_feed_cat = false;
-                       active_label = false;
 
 //                     Effect.Fade("prefContent", {duration: 1, to: 0.01, 
 //                             queue: { position:'end', scope: 'FEED_TAB', limit: 1 } } );
@@ -1320,8 +1123,6 @@ function selectTab(id, noupdate, subop) {
                                updatePrefsList();
                        } else if (id == "userConfig") {
                                updateUsersList();
-                       } else if (id == "feedBrowser") {
-                               updateBigFeedBrowser();
                        }
                }
 
@@ -1368,14 +1169,15 @@ function backend_sanity_check_callback() {
                        }
 
                        if (!xmlhttp.responseXML) {
-                               fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp.responseText);
+                               fatalError(3, "Sanity Check: Received reply is not XML", 
+                                       xmlhttp.responseText);
                                return;
                        }
        
                        var reply = xmlhttp.responseXML.firstChild.firstChild;
        
                        if (!reply) {
-                               fatalError(3, "[D002, Invalid RPC reply]: " + xmlhttp.responseText);
+                               fatalError(3, "Sanity Check: Invalid RPC reply", xmlhttp.responseText);
                                return;
                        }
        
@@ -1416,6 +1218,7 @@ function init_second_stage() {
 
        try {
                active_tab = getInitParam("prefs_active_tab");
+               if (!document.getElementById(active_tab+"Tab")) active_tab = "genConfig";
                if (!active_tab || active_tab == '0') active_tab = "genConfig";
 
                document.onkeydown = pref_hotkey_handler;
@@ -1424,6 +1227,10 @@ function init_second_stage() {
                
                caller_subop = getURLParam('subop');
 
+               if (getURLParam("subopparam")) {
+                       caller_subop = caller_subop + ":" + getURLParam("subopparam");
+               }
+
                if (tab) {
                        active_tab = tab;
                }
@@ -1434,6 +1241,9 @@ function init_second_stage() {
                        selectTab(active_tab);
                }
                notify("");
+
+               loading_set_progress(60);
+
        } catch (e) {
                exception_error("init_second_stage", e);
        }
@@ -1447,7 +1257,7 @@ function init() {
                arguments.callee.done = true;           
 
                if (getURLParam('debug')) {
-                       document.getElementById('debug_output').style.display = 'block';
+                       Element.show("debug_output");
                        debug('debug mode activated');
                }
 
@@ -1459,6 +1269,8 @@ function init() {
                        return;
                }
 
+               loading_set_progress(30);
+
                xmlhttp.open("GET", "backend.php?op=rpc&subop=sanityCheck", true);
                xmlhttp.onreadystatechange=backend_sanity_check_callback;
                xmlhttp.send(null);
@@ -1521,14 +1333,6 @@ function validatePrefsReset() {
 
 }
 
-function browseFeeds(limit) {
-
-       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
-       xmlhttp.onreadystatechange=infobox_callback;
-       xmlhttp.send(null);
-
-}
-
 function feedBrowserSubscribe() {
        try {
 
@@ -1549,59 +1353,9 @@ function feedBrowserSubscribe() {
        }
 }
 
-function updateBigFeedBrowser(limit) {
-
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
-
-       var query = "backend.php?op=pref-feed-browser";
-
-       var limit_sel = document.getElementById("feedBrowserLimit");
-
-       if (limit_sel) {
-               var limit = limit_sel[limit_sel.selectedIndex].value;
-               query = query + "&limit=" + param_escape(limit);
-       }
-
-       xmlhttp.open("GET", query, true);
-       xmlhttp.onreadystatechange=feed_browser_callback;
-       xmlhttp.send(null);
-}
-
-function browserToggleExpand(id) {
-       try {
-/*             if (feed_to_expand && feed_to_expand != id) {
-                       var d = document.getElementById("BRDET-" + feed_to_expand);
-                       d.style.display = "none";
-               } */
-
-               if (!xmlhttp_ready(xmlhttp)) {
-                       printLockingError();
-                       return
-               }
-
-/*             if (feed_to_expand && id != feed_to_expand) {
-                       Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
-               } */
-
-               var d = document.getElementById("BRDET-" + id);
-       
-               if (Element.visible(d)) {
-                       Effect.Fade(d, {duration : 0.5});
-               } else {
-                       feed_to_expand = id;
-
-                       xmlhttp.open("GET", "backend.php?op=pref-feed-browser&subop=details&id="
-                               + param_escape(id), true);
-                       xmlhttp.onreadystatechange=expand_feed_callback;
-                       xmlhttp.send(null);
-               }
-
-       } catch (e) {
-               exception_error("browserToggleExpand", e);
-       }
+function updateBigFeedBrowserBtn() {
+       notify_progress("Loading, please wait...");
+       return updateBigFeedBrowser();
 }
 
 function selectPrefRows(kind, select) {
@@ -1705,6 +1459,8 @@ function pref_hotkey_handler(e) {
                        keycode = e.which;
                }
 
+               var keychar = String.fromCharCode(keycode);
+
                if (keycode == 27) { // escape
                        if (Element.visible("hotkey_help_overlay")) {
                                Element.hide("hotkey_help_overlay");
@@ -1722,7 +1478,7 @@ function pref_hotkey_handler(e) {
 
                if ((keycode == 67 || keycode == 71) && !hotkey_prefix) {
                        hotkey_prefix = keycode;
-                       debug("KP: PREFIX=" + keycode);
+                       debug("KP: PREFIX=" + keycode + " CHAR=" + keychar);
                        return;
                }
 
@@ -1741,35 +1497,34 @@ function pref_hotkey_handler(e) {
                if (!hotkey_prefix) {
 
                        if (keycode == 68 && shift_key) { // d
-                               if (!debug_mode_enabled) {
-                                       document.getElementById('debug_output').style.display = 'block';
+                               if (!Element.visible("debug_output")) {
+                                       Element.show("debug_output");
                                        debug('debug mode activated');
                                } else {
-                                       document.getElementById('debug_output').style.display = 'none';
+                                       Element.hide("debug_output");
                                }
-       
-                               debug_mode_enabled = !debug_mode_enabled;
                                return;
                        }
        
-                       if (keycode == 191 && shift_key) { // ?
+                       if ((keycode == 191 || keychar == '?') && shift_key) { // ?
                                if (!Element.visible("hotkey_help_overlay")) {
                                        //Element.show("hotkey_help_overlay");
                                        Effect.Appear("hotkey_help_overlay", {duration : 0.3});
                                } else {
                                        Element.hide("hotkey_help_overlay");
                                }
-                               return;
+                               return false;
                        }
 
-                       if (keycode == 191) { // /
+                       if (keycode == 191 || keychar == '/') { // /
                                var search_boxes = new Array("label_search", 
-                                       "feed_search", "filter_search", "user_search");
+                                       "feed_search", "filter_search", "user_search", "feed_browser_search");
 
                                for (var i = 0; i < search_boxes.length; i++) {
                                        var elem = document.getElementById(search_boxes[i]);
                                        if (elem) {
-                                               return focus_element(search_boxes[i]);
+                                               focus_element(search_boxes[i]);
+                                               return false;
                                        }
                                }
                        }
@@ -1781,27 +1536,32 @@ function pref_hotkey_handler(e) {
                        hotkey_prefix = false;
 
                        if (keycode == 70) { // f
-                               return displayDlg("quickAddFilter");    
+                               displayDlg("quickAddFilter");
+                               return false;
                        }
 
                        if (keycode == 83) { // s
-                               return displayDlg("quickAddFeed");      
+                               displayDlg("quickAddFeed");
+                               return false;
                        }
 
-                       if (keycode == 76) { // l
-                               return displayDlg("quickAddLabel");     
-                       }
+/*                     if (keycode == 76) { // l
+                               displayDlg("quickAddLabel");
+                               return false;
+                       } */
 
                        if (keycode == 85) { // u
                                // no-op
                        }
 
                        if (keycode == 67) { // c
-                               return editFeedCats();
+                               editFeedCats();
+                               return false;
                        }
 
                        if (keycode == 84 && shift_key) { // T
-                               return browseFeeds();
+                               browseFeeds();
+                               return false;
                        }
 
                }
@@ -1814,26 +1574,27 @@ function pref_hotkey_handler(e) {
 
                        if (keycode == 49 && document.getElementById("genConfigTab")) { // 1
                                selectTab("genConfig");
+                               return false;
                        }
 
                        if (keycode == 50 && document.getElementById("feedConfigTab")) { // 2
-                               return selectTab("feedConfig");
-                       }
-
-                       if (keycode == 51 && document.getElementById("feedBrowserTab")) { // 3
-                               return selectTab("feedBrowser");
+                               selectTab("feedConfig");
+                               return false;
                        }
 
-                       if (keycode == 52 && document.getElementById("filterConfigTab")) { // 4
-                               return selectTab("filterConfig");
+                       if (keycode == 51 && document.getElementById("filterConfigTab")) { // 4
+                               selectTab("filterConfig");
+                               return false;
                        }
 
-                       if (keycode == 53 && document.getElementById("labelConfigTab")) { // 5
-                               return selectTab("labelConfig");
+                       if (keycode == 52 && document.getElementById("labelConfigTab")) { // 5
+                               selectTab("labelConfig");
+                               return false;
                        }
 
-                       if (keycode == 54 && document.getElementById("userConfigTab")) { // 6
-                               return selectTab("userConfig");
+                       if (keycode == 53 && document.getElementById("userConfigTab")) { // 6
+                               selectTab("userConfig");
+                               return false;
                        }
 
                        if (keycode == 88) { // x
@@ -1846,16 +1607,16 @@ function pref_hotkey_handler(e) {
        
                        if (seq.match("807371717369")) {
                                seq = "";
-                               localPiggieFunction(true);
+                               piggie(true);
                        } else {
-                               localPiggieFunction(false);
+                               piggie(false);
                        }
                }
 
                if (hotkey_prefix) {
-                       debug("KP: PREFIX=" + hotkey_prefix + " CODE=" + keycode);
+                       debug("KP: PREFIX=" + hotkey_prefix + " CODE=" + keycode + " CHAR=" + keychar);
                } else {
-                       debug("KP: CODE=" + keycode);
+                       debug("KP: CODE=" + keycode + " CHAR=" + keychar);
                }
 
        } catch (e) {
@@ -1864,22 +1625,24 @@ function pref_hotkey_handler(e) {
 }
 
 function editFeedCats() {
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
-
-       document.getElementById("subscribe_to_feed_btn").disabled = true;
-
        try {
-               document.getElementById("top25_feeds_btn").disabled = true;
+               document.getElementById("subscribe_to_feed_btn").disabled = true;
+       
+               try {
+                       document.getElementById("top25_feeds_btn").disabled = true;
+               } catch (e) {
+                       // this button is not always available, no-op if not found
+               }
+       
+               var query = "backend.php?op=pref-feeds&subop=editCats";
+
+               new Ajax.Request(query, {
+                       onComplete: function(transport) {
+                               infobox_feed_cat_callback2(transport);
+                       } });
        } catch (e) {
-               // this button is not always available, no-op if not found
+               exception_error("editFeedCats", e);
        }
-
-       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
-       xmlhttp.onreadystatechange=infobox_feed_cat_callback;
-       xmlhttp.send(null);
 }
 
 function showFeedsWithErrors() {
@@ -2051,7 +1814,14 @@ function feedActionChange() {
 function feedActionGo(op) {    
        try {
                if (op == "facEdit") {
-                       editSelectedFeed();
+
+                       var rows = getSelectedFeeds();
+
+                       if (rows.length > 1) {
+                               editSelectedFeeds();
+                       } else {
+                               editSelectedFeed();
+                       }
                }
 
                if (op == "facClear") {
@@ -2109,7 +1879,7 @@ function rescoreSelectedFeeds() {
                var ok = confirm(__("Rescore articles in selected feeds?"));
 
                if (ok) {
-                       notify_progress("Rescoring selected feeds...");
+                       notify_progress("Rescoring selected feeds...", true);
        
                        xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=rescore&quiet=1&ids="+
                                param_escape(sel_rows.toString()), true);
@@ -2127,10 +1897,152 @@ function rescore_all_feeds() {
                var ok = confirm(__("Rescore all articles? This operation may take a lot of time."));
 
                if (ok) {
-                       notify_progress("Rescoring feeds...");
+                       notify_progress("Rescoring feeds...", true);
 
                        xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=rescoreAll&quiet=1", true);
                        xmlhttp.onreadystatechange=notify_callback;
                        xmlhttp.send(null);
                }
 }
+
+function removeFilter(id, title) {
+
+       if (!xmlhttp_ready(xmlhttp)) {
+               printLockingError();
+               return
+       }
+
+       var msg = __("Remove filter %s?").replace("%s", title);
+
+       var ok = confirm(msg);
+
+       if (ok) {
+               closeInfoBox();
+
+               notify_progress("Removing filter...");
+       
+               xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
+                       param_escape(id), true);
+               xmlhttp.onreadystatechange=filterlist_callback;
+               xmlhttp.send(null);
+       }
+
+       return false;
+}
+
+function unsubscribeFeed(id, title) {
+
+       if (!xmlhttp_ready(xmlhttp)) {
+               printLockingError();
+               return
+       }
+
+       var msg = __("Unsubscribe from %s?").replace("%s", title);
+
+       var ok = confirm(msg);
+
+       if (ok) {
+               closeInfoBox();
+
+               notify_progress("Removing feed...");
+       
+               xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
+                       param_escape(id), true);
+               xmlhttp.onreadystatechange=filterlist_callback;
+               xmlhttp.send(null);
+       }
+
+       return false;
+
+       return false;
+
+}
+
+function feedsEditSave() {
+       try {
+
+               if (!xmlhttp_ready(xmlhttp)) {
+                       printLockingError();
+                       return
+               }
+
+               var ok = confirm(__("Save changes to selected feeds?"));
+
+               if (ok) {
+
+                       var f = document.forms["batch_edit_feed_form"];
+
+                       var query = Form.serialize("batch_edit_feed_form");
+
+                       /* Form.serialize ignores unchecked checkboxes */
+
+                       if (!query.match("&hidden=") && 
+                                       f.hidden.disabled == false) {
+                               query = query + "&hidden=false";
+                       }
+
+                       if (!query.match("&rtl_content=") && 
+                                       f.rtl_content.disabled == false) {
+                               query = query + "&rtl_content=false";
+                       }
+
+                       if (!query.match("&private=") && 
+                                       f.private.disabled == false) {
+                               query = query + "&private=false";
+                       }
+
+                       if (!query.match("&cache_images=") && 
+                                       f.cache_images.disabled == false) {
+                               query = query + "&cache_images=false";
+                       }
+
+                       if (!query.match("&include_in_digest=") && 
+                                       f.include_in_digest.disabled == false) {
+                               query = query + "&include_in_digest=false";
+                       }
+       
+                       closeInfoBox();
+       
+                       notify_progress("Saving feeds...");
+       
+                       xmlhttp.open("POST", "backend.php", true);
+                       xmlhttp.onreadystatechange=feedlist_callback;
+                       xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+                       xmlhttp.send(query);
+               }
+
+               return false;
+       } catch (e) {
+               exception_error("feedsEditSave", e);
+       }
+}
+
+function batchFeedsToggleField(cb, elem, label) {
+       try {
+               var f = document.forms["batch_edit_feed_form"];
+               var l = document.getElementById(label);
+
+               if (cb.checked) {
+                       f[elem].disabled = false;
+
+                       if (l) {
+                               l.className = "";
+                       };
+
+//                     new Effect.Highlight(f[elem], {duration: 1, startcolor: "#fff7d5",
+//                             queue: { position:'end', scope: 'BPEFQ', limit: 1 } } );
+
+               } else {
+                       f[elem].disabled = true;
+
+                       if (l) {
+                               l.className = "insensitive";
+                       };
+
+               }
+       } catch (e) {
+               exception_error("batchFeedsToggleField", e);
+       }
+}
+
+