]> git.wh0rd.org - tt-rss.git/blobdiff - prefs.js
pref-feeds tweaks
[tt-rss.git] / prefs.js
index 2c10a2dbcdcd2c536411e4844f368f2cb1948d34..43a554cf2ba02fb2b8045b0c4cd7f06156fb81ab 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -5,20 +5,63 @@ var active_label = false;
 var active_tab = false;
 var feed_to_expand = false;
 
-var piggie_top = -400;
-var piggie_fwd = true;
-
 var xmlhttp = Ajax.getTransport();
 
 var init_params = new Array();
 
+var caller_subop = false;
+
+var sanity_check_done = false;
+
+function infobox_callback() {
+       if (xmlhttp.readyState == 4) {
+               infobox_callback2(xmlhttp);
+       }
+}
+
+function infobox_submit_callback() {
+       if (xmlhttp.readyState == 4) {
+               infobox_submit_callback2(xmlhttp);
+       }
+}
+
+
+function replace_pubkey_callback() {
+       if (xmlhttp.readyState == 4) {
+               try {   
+                       var link = document.getElementById("pubGenAddress");
+
+                       if (xmlhttp.responseXML) {
+
+                               var new_link = xmlhttp.responseXML.getElementsByTagName("link")[0];
+
+                               if (new_link) {
+                                       link.href = new_link.firstChild.nodeValue;
+                                       //link.innerHTML = new_link.firstChild.nodeValue;
+
+                                       new Effect.Highlight(link);
+
+                                       notify_info("Published feed URL changed.");
+                               } else {
+                                       notify_error("Could not change feed URL.");
+                               }
+
+                       } else {
+                               notify_error("Could not change feed URL.");
+                       }
+               } catch (e) {
+                       exception_error("replace_pubkey_callback", e);
+               }
+       }
+}
+
 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";
-//                     p_notify("");
+//                     container.style.display = "block";
+                       Effect.Appear(container, {duration : 0.5});
                } catch (e) {
                        exception_error("expand_feed_callback", e);
                }
@@ -32,19 +75,17 @@ function feedlist_callback() {
                        container.innerHTML=xmlhttp.responseText;
                        selectTab("feedConfig", true);
 
-                       if (active_feed_cat) {
-                               var row = document.getElementById("FCATR-" + active_feed_cat);
-                               if (row) {
-                                       if (!row.className.match("Selected")) {
-                                               row.className = row.className + "Selected";
-                                       }               
-                               }
-                               var checkbox = document.getElementById("FCCHK-" + active_feed_cat);
-                               if (checkbox) {
-                                       checkbox.checked = 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);
@@ -52,10 +93,40 @@ function feedlist_callback() {
        }
 }
 
+/* stub for subscription dialog */
+
+function dlg_frefresh_callback(transport) {
+
+       try {
+               var container = document.getElementById('prefContent'); 
+               container.innerHTML=transport.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);
+       }
+
+}
+
 function filterlist_callback() {
        var container = document.getElementById('prefContent');
        if (xmlhttp.readyState == 4) {
                container.innerHTML=xmlhttp.responseText;
+               if (typeof correctPNG != 'undefined') {
+                       correctPNG();
+               }
                notify("");
        }
 }
@@ -78,14 +149,9 @@ function labellist_callback() {
                                checkbox.checked = true;
                        }
                }
-               notify("");
-       }
-}
-
-function labeltest_callback() {
-       var container = document.getElementById('label_test_result');
-       if (xmlhttp.readyState == 4) {
-               container.innerHTML=xmlhttp.responseText;
+               if (typeof correctPNG != 'undefined') {
+                       correctPNG();
+               }
                notify("");
        }
 }
@@ -126,11 +192,62 @@ function gethelp_callback() {
        }
 }
 
-
 function notify_callback() {
-       var container = document.getElementById('notify');
        if (xmlhttp.readyState == 4) {
-               container.innerHTML=xmlhttp.responseText;
+               notify_info(xmlhttp.responseText);
+       } 
+}
+
+function prefs_reset_callback() {
+       if (xmlhttp.readyState == 4) {
+               notify_info(xmlhttp.responseText);
+               selectTab();
+       } 
+}
+
+
+function changepass_callback() {
+       try {
+               if (xmlhttp.readyState == 4) {
+       
+                       if (xmlhttp.responseText.indexOf("ERROR: ") == 0) {
+                               notify_error(xmlhttp.responseText.replace("ERROR: ", ""));
+                       } else {
+                               notify_info(xmlhttp.responseText);
+                               var warn = document.getElementById("default_pass_warning");
+                               if (warn) warn.style.display = "none";
+                       }
+       
+                       document.forms['change_pass_form'].reset();
+
+               } 
+       } catch (e) {
+               exception_error("changepass_callback", e);
+       }
+}
+
+function infobox_feed_cat_callback() {
+       if (xmlhttp.readyState == 4) {
+               try {
+
+                       infobox_callback();
+
+                       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);
+                                       }
+                               }
+                       }
+
+               } catch (e) {
+                       exception_error("infobox_feed_cat_callback", e);
+               }
        }
 }
 
@@ -141,16 +258,20 @@ function updateFeedList(sort_key) {
                return
        }
 
-//     document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
-
-//     p_notify("Loading, please wait...");
-
        var feed_search = document.getElementById("feed_search");
        var search = "";
        if (feed_search) { search = feed_search.value; }
 
+       var slat = document.getElementById("show_last_article_times");
+
+       var slat_checked = false;
+       if (slat) {
+               slat_checked = slat.checked;
+       }
+
        xmlhttp.open("GET", "backend.php?op=pref-feeds" +
                "&sort=" + param_escape(sort_key) + 
+               "&slat=" + param_escape(slat_checked) +
                "&search=" + param_escape(search), true);
        xmlhttp.onreadystatechange=feedlist_callback;
        xmlhttp.send(null);
@@ -164,10 +285,6 @@ function updateUsersList(sort_key) {
                return
        }
 
-//     document.getElementById("prefContent").innerHTML = "Loading feeds, please wait...";
-
-//     p_notify("Loading, please wait...");
-
        xmlhttp.open("GET", "backend.php?op=pref-users&sort="
                + param_escape(sort_key), true);
        xmlhttp.onreadystatechange=userlist_callback;
@@ -188,12 +305,12 @@ function addLabel() {
        var description = form.description.value;
 
        if (sql_exp == "") {
-               alert("Can't create label: missing SQL expression.");
+               alert(__("Can't create label: missing SQL expression."));
                return false;
        }
 
        if (description == "") {
-               alert("Can't create label: missing caption.");
+               alert(__("Can't create label: missing caption."));
                return false;
        }
 
@@ -214,13 +331,13 @@ function addFeed() {
        var link = document.getElementById("fadd_link");
 
        if (link.value.length == 0) {
-               alert("Error: No feed URL given.");
+               alert(__("Error: No feed URL given."));
        } else if (!isValidURL(link.value)) {
-               alert("Error: Invalid feed URL.");
+               alert(__("Error: Invalid feed URL."));
        } else {
-               notify("Adding feed...");
+               notify_progress("Adding feed...");
 
-               xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&feed_url=" +
+               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);
@@ -241,13 +358,13 @@ function addFeedCat() {
        var cat = document.getElementById("fadd_cat");
 
        if (cat.value.length == 0) {
-               alert("Can't add category: no name specified.");
+               alert(__("Can't add category: no name specified."));
        } else {
-               notify("Adding feed category...");
+               notify_progress("Adding feed category...");
 
-               xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=addCat&cat=" +
+               xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=add&cat=" +
                        param_escape(cat.value), true);
-               xmlhttp.onreadystatechange=feedlist_callback;
+               xmlhttp.onreadystatechange=infobox_callback;
                xmlhttp.send(null);
 
                link.value = "";
@@ -265,9 +382,9 @@ function addUser() {
        var sqlexp = document.getElementById("uadd_box");
 
        if (sqlexp.value.length == 0) {
-               alert("Can't add user: no login specified.");
+               alert(__("Can't add user: no login specified."));
        } else {
-               notify("Adding user...");
+               notify_progress("Adding user...");
 
                xmlhttp.open("GET", "backend.php?op=pref-users&subop=add&login=" +
                        param_escape(sqlexp.value), true);                      
@@ -287,6 +404,8 @@ function editLabel(id) {
                return
        }
 
+       notify_progress("Loading, please wait...");
+
        document.getElementById("label_create_btn").disabled = true;
 
        active_label = id;
@@ -308,6 +427,8 @@ function editUser(id) {
                return
        }
 
+       notify_progress("Loading, please wait...");
+
        selectTableRowsByIdPrefix('prefUserList', 'UMRR-', 'UMCHK-', false);
        selectTableRowById('UMRR-'+id, 'UMCHK-'+id, true);
 
@@ -325,6 +446,8 @@ function editFilter(id) {
                return
        }
 
+       notify_progress("Loading, please wait...");
+
        document.getElementById("create_filter_btn").disabled = true;
 
        selectTableRowsByIdPrefix('prefFilterList', 'FILRR-', 'FICHK-', false);
@@ -344,6 +467,16 @@ function editFeed(feed) {
                return
        }
 
+       notify_progress("Loading, please wait...");
+
+       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
+       }
+
        // clean selection from all rows & select row being edited
        selectTableRowsByIdPrefix('prefFeedList', 'FEEDR-', 'FRCHK-', false);
        selectTableRowById('FEEDR-'+feed, 'FRCHK-'+feed, true);
@@ -363,11 +496,13 @@ function editFeedCat(cat) {
                return
        }
 
+       notify_progress("Loading, please wait...");
+
        active_feed_cat = cat;
 
-       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCat&id=" +
+       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=edit&id=" +
                param_escape(cat), true);
-       xmlhttp.onreadystatechange=feedlist_callback;
+       xmlhttp.onreadystatechange=infobox_callback;
        xmlhttp.send(null);
 
 }
@@ -426,10 +561,10 @@ function removeSelectedLabels() {
 
        if (sel_rows.length > 0) {
 
-               var ok = confirm("Remove selected labels?");
+               var ok = confirm(__("Remove selected labels?"));
 
                if (ok) {
-                       notify("Removing selected labels...");
+                       notify_progress("Removing selected labels...");
        
                        xmlhttp.open("GET", "backend.php?op=pref-labels&subop=remove&ids="+
                                param_escape(sel_rows.toString()), true);
@@ -437,7 +572,7 @@ function removeSelectedLabels() {
                        xmlhttp.send(null);
                }
        } else {
-               alert("No labels are selected.");
+               alert(__("No labels are selected."));
        }
 
        return false;
@@ -454,10 +589,10 @@ function removeSelectedUsers() {
 
        if (sel_rows.length > 0) {
 
-               var ok = confirm("Remove selected users?");
+               var ok = confirm(__("Remove selected users?"));
 
                if (ok) {
-                       notify("Removing selected users...");
+                       notify_progress("Removing selected users...");
        
                        xmlhttp.open("GET", "backend.php?op=pref-users&subop=remove&ids="+
                                param_escape(sel_rows.toString()), true);
@@ -466,7 +601,7 @@ function removeSelectedUsers() {
                }
 
        } else {
-               alert("No users are selected.");
+               alert(__("No users are selected."));
        }
 
        return false;
@@ -483,10 +618,10 @@ function removeSelectedFilters() {
 
        if (sel_rows.length > 0) {
 
-               var ok = confirm("Remove selected filters?");
+               var ok = confirm(__("Remove selected filters?"));
 
                if (ok) {
-                       notify("Removing selected filters...");
+                       notify_progress("Removing selected filters...");
        
                        xmlhttp.open("GET", "backend.php?op=pref-filters&subop=remove&ids="+
                                param_escape(sel_rows.toString()), true);
@@ -494,7 +629,7 @@ function removeSelectedFilters() {
                        xmlhttp.send(null);
                }
        } else {
-               alert("No filters are selected.");
+               alert(__("No filters are selected."));
        }
 
        return false;
@@ -512,11 +647,11 @@ function removeSelectedFeeds() {
 
        if (sel_rows.length > 0) {
 
-               var ok = confirm("Unsubscribe from selected feeds?");
+               var ok = confirm(__("Unsubscribe from selected feeds?"));
 
                if (ok) {
 
-                       notify("Unsubscribing from selected feeds...");
+                       notify_progress("Unsubscribing from selected feeds...");
        
                        xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids="+
                                param_escape(sel_rows.toString()), true);
@@ -526,7 +661,75 @@ function removeSelectedFeeds() {
 
        } else {
 
-               alert("No feeds are selected.");
+               alert(__("No feeds are selected."));
+
+       }
+       
+       return false;
+}
+
+function clearSelectedFeeds() {
+
+       if (!xmlhttp_ready(xmlhttp)) {
+               printLockingError();
+               return
+       }
+
+       var sel_rows = getSelectedFeeds();
+
+       if (sel_rows.length > 1) {
+               alert(__("Please select only one feed."));
+               return;
+       }
+
+       if (sel_rows.length > 0) {
+
+               var ok = confirm(__("Erase all non-starred articles in selected feed?"));
+
+               if (ok) {
+                       notify_progress("Clearing selected feed...");
+                       clearFeedArticles(sel_rows[0]);
+               }
+
+       } else {
+
+               alert(__("No feeds are selected."));
+
+       }
+       
+       return false;
+}
+
+function purgeSelectedFeeds() {
+
+       if (!xmlhttp_ready(xmlhttp)) {
+               printLockingError();
+               return
+       }
+
+       var sel_rows = getSelectedFeeds();
+
+       if (sel_rows.length > 0) {
+
+               var pr = prompt(__("How many days of articles to keep (0 - use default)?"), "0");
+
+               if (pr != undefined) {
+                       notify_progress("Purging selected feed...");
+
+                       var query = "backend.php?op=rpc&subop=purge&ids="+
+                               param_escape(sel_rows.toString()) + "&days=" + pr;
+
+                       debug(query);
+
+                       new Ajax.Request(query, {
+                               onComplete: function(transport) {
+                                       notify('');
+                               } });
+               }
+
+       } else {
+
+               alert(__("No feeds are selected."));
 
        }
        
@@ -544,20 +747,20 @@ function removeSelectedFeedCats() {
 
        if (sel_rows.length > 0) {
 
-               var ok = confirm("Remove selected categories?");
+               var ok = confirm(__("Remove selected categories?"));
 
                if (ok) {
-                       notify("Removing selected categories...");
+                       notify_progress("Removing selected categories...");
        
-                       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=removeCats&ids="+
+                       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats&action=remove&ids="+
                                param_escape(sel_rows.toString()), true);
-                       xmlhttp.onreadystatechange=feedlist_callback;
+                       xmlhttp.onreadystatechange=infobox_callback;
                        xmlhttp.send(null);
                }
 
        } else {
 
-               alert("No categories are selected.");
+               alert(__("No categories are selected."));
 
        }
 
@@ -571,6 +774,14 @@ function feedEditCancel() {
                return
        }
 
+       document.getElementById("subscribe_to_feed_btn").disabled = false;
+
+       try {
+               document.getElementById("top25_feeds_btn").disabled = false;
+       } catch (e) {
+               // this button is not always available, no-op if not found
+       }
+
        closeInfoBox();
 
        selectPrefRows('feed', false); // cleanup feed selection
@@ -589,8 +800,8 @@ function feedCatEditCancel() {
 
 //     notify("Operation cancelled.");
 
-       xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
-       xmlhttp.onreadystatechange=feedlist_callback;
+       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
+       xmlhttp.onreadystatechange=infobox_callback;
        xmlhttp.send(null);
 
        return false;
@@ -609,7 +820,7 @@ function feedEditSave() {
 
                var query = Form.serialize("edit_feed_form");
 
-               notify("Saving feed...");
+               notify_progress("Saving feed...");
 
                xmlhttp.open("POST", "backend.php", true);
                xmlhttp.onreadystatechange=feedlist_callback;
@@ -632,12 +843,12 @@ function feedCatEditSave() {
                return
        }
 
-       notify("Saving category...");
+       notify_progress("Saving category...");
 
        var query = Form.serialize("feed_cat_edit_form");
 
        xmlhttp.open("GET", "backend.php?" + query, true);
-       xmlhttp.onreadystatechange=feedlist_callback;
+       xmlhttp.onreadystatechange=infobox_callback;
        xmlhttp.send(null);
 
        active_feed_cat = false;
@@ -645,37 +856,6 @@ function feedCatEditSave() {
        return false;
 }
 
-
-function labelTest() {
-
-       var container = document.getElementById('label_test_result');
-       container.style.display = "block";
-       container.innerHTML = "<p>Loading, please wait...</p>";
-
-       var form = document.forms['label_edit_form'];
-
-       var sql_exp = form.sql_exp.value;
-       var description = form.description.value;
-
-       xmlhttp.open("GET", "backend.php?op=pref-labels&subop=test&expr=" +
-               param_escape(sql_exp) + "&descr=" + param_escape(description), true);
-
-       xmlhttp.onreadystatechange=labeltest_callback;
-       xmlhttp.send(null);
-
-       return false;
-}
-
-function displayHelpInfobox(topic_id) {
-
-       xmlhttp.open("GET", "backend.php?op=help&tid=" +
-               param_escape(topic_id) + "&noheaders=1", true);
-
-       xmlhttp.onreadystatechange=infobox_callback;
-       xmlhttp.send(null);
-
-}
-
 function labelEditCancel() {
 
        if (!xmlhttp_ready(xmlhttp)) {
@@ -748,7 +928,7 @@ function labelEditSave() {
 
        closeInfoBox();
 
-       notify("Saving label...");
+       notify_progress("Saving label...");
 
        active_label = false;
 
@@ -771,11 +951,11 @@ function userEditSave() {
        var login = document.forms["user_edit_form"].login.value;
 
        if (login.length == 0) {
-               alert("Login field cannot be blank.");
+               alert(__("Login field cannot be blank."));
                return;
        }
        
-       notify("Saving user...");
+       notify_progress("Saving user...");
 
        closeInfoBox();
 
@@ -805,7 +985,7 @@ function filterEditSave() {
                }
        } */
 
-       notify("Saving filter...");
+       notify_progress("Saving filter...");
 
        var query = Form.serialize("filter_edit_form");
 
@@ -824,12 +1004,12 @@ function editSelectedLabel() {
        var rows = getSelectedLabels();
 
        if (rows.length == 0) {
-               alert("No labels are selected.");
+               alert(__("No labels are selected."));
                return;
        }
 
        if (rows.length > 1) {
-               alert("Please select only one label.");
+               alert(__("Please select only one label."));
                return;
        }
 
@@ -843,12 +1023,12 @@ function editSelectedUser() {
        var rows = getSelectedUsers();
 
        if (rows.length == 0) {
-               alert("No users are selected.");
+               alert(__("No users are selected."));
                return;
        }
 
        if (rows.length > 1) {
-               alert("Please select only one user.");
+               alert(__("Please select only one user."));
                return;
        }
 
@@ -861,19 +1041,19 @@ function resetSelectedUserPass() {
        var rows = getSelectedUsers();
 
        if (rows.length == 0) {
-               alert("No users are selected.");
+               alert(__("No users are selected."));
                return;
        }
 
        if (rows.length > 1) {
-               alert("Please select only one user.");
+               alert(__("Please select only one user."));
                return;
        }
 
-       var ok = confirm("Reset password of selected user?");
+       var ok = confirm(__("Reset password of selected user?"));
 
        if (ok) {
-               notify("Resetting password for selected user...");
+               notify_progress("Resetting password for selected user...");
        
                var id = rows[0];
        
@@ -894,18 +1074,18 @@ function selectedUserDetails() {
        var rows = getSelectedUsers();
 
        if (rows.length == 0) {
-               alert("No users are selected.");
+               alert(__("No users are selected."));
                return;
        }
 
        if (rows.length > 1) {
-               alert("Please select only one user.");
+               alert(__("Please select only one user."));
                return;
        }
 
-       var id = rows[0];
+       notify_progress("Loading, please wait...");
 
-       notify("");
+       var id = rows[0];
 
        xmlhttp.open("GET", "backend.php?op=user-details&id=" + id, true);
        xmlhttp.onreadystatechange=infobox_callback;
@@ -923,12 +1103,12 @@ function selectedFeedDetails() {
        var rows = getSelectedFeeds();
 
        if (rows.length == 0) {
-               alert("No feeds are selected.");
+               alert(__("No feeds are selected."));
                return;
        }
 
        if (rows.length > 1) {
-               notify("Please select only one feed.");
+               alert(__("Please select only one feed."));
                return;
        }
 
@@ -947,12 +1127,12 @@ function editSelectedFilter() {
        var rows = getSelectedFilters();
 
        if (rows.length == 0) {
-               alert("No filters are selected.");
+               alert(__("No filters are selected."));
                return;
        }
 
        if (rows.length > 1) {
-               alert("Please select only one filter.");
+               alert(__("Please select only one filter."));
                return;
        }
 
@@ -967,12 +1147,12 @@ function editSelectedFeed() {
        var rows = getSelectedFeeds();
 
        if (rows.length == 0) {
-               notify("No feeds are selected.");
+               alert(__("No feeds are selected."));
                return;
        }
 
        if (rows.length > 1) {
-               notify("Please select one feed.");
+               alert(__("Please select one feed."));
                return;
        }
 
@@ -986,12 +1166,12 @@ function editSelectedFeedCat() {
        var rows = getSelectedFeedCats();
 
        if (rows.length == 0) {
-               alert("No categories are selected.");
+               alert(__("No categories are selected."));
                return;
        }
 
        if (rows.length > 1) {
-               alert("Please select only one category.");
+               alert(__("Please select only one category."));
                return;
        }
 
@@ -1001,63 +1181,15 @@ function editSelectedFeedCat() {
 
 }
 
-function piggie_callback() {
-       var piggie = document.getElementById("piggie");
-
-       piggie.style.top = piggie_top;
-       piggie.style.backgroundColor = "white";
-       piggie.style.borderWidth = "1px";
-
-       if (piggie_fwd && piggie_top < 0) {
-               setTimeout("piggie_callback()", 50);
-               piggie_top = piggie_top + 10;
-       } else if (piggie_fwd && piggie_top >= 0) {
-               piggie_fwd = false;
-               setTimeout("piggie_callback()", 50);
-       } else if (!piggie_fwd && piggie_top > -400) {
-               setTimeout("piggie_callback()", 50);
-               piggie_top = piggie_top - 10;
-       } else if (!piggie_fwd && piggie_top <= -400) {
-               piggie.style.display = "none";
-               piggie_fwd = true;
-       }
-}
-
-var piggie_opacity = 0;
-
-function piggie2_callback() {
-       var piggie = document.getElementById("piggie");
-       piggie.style.top = 0;
-       piggie.style.opacity = piggie_opacity;
-       piggie.style.backgroundColor = "transparent";
-       piggie.style.borderWidth = "0px";
-
-       if (piggie_fwd && piggie_opacity < 1) {
-               setTimeout("piggie2_callback()", 50);
-               piggie_opacity = piggie_opacity + 0.03;
-       } else if (piggie_fwd && piggie_opacity >= 1) {
-               piggie_fwd = false;
-               setTimeout("piggie2_callback()", 50);
-       } else if (!piggie_fwd && piggie_opacity > 0) {
-               setTimeout("piggie2_callback()", 50);
-               piggie_opacity = piggie_opacity - 0.03;
-       } else if (!piggie_fwd && piggie_opacity <= 0) {
-               piggie.style.display = "none";
-               piggie_fwd = true;
-       }
-}
-
 function localPiggieFunction(enable) {
        if (enable) {
                debug("I LOVEDED IT!");
                var piggie = document.getElementById("piggie");
-               piggie.style.display = "block";
 
-               if (navigator.userAgent.match("Gecko") && Math.random(1) > 0.5) {       
-                       piggie2_callback();
-               } else {
-                       piggie_callback();
-               }
+               Element.show(piggie);
+               Position.Center(piggie);
+               Effect.Puff(piggie);
+
        }
 }
 
@@ -1066,7 +1198,7 @@ function validateOpmlImport() {
        var opml_file = document.getElementById("opml_file");
 
        if (opml_file.value.length == 0) {
-               alert("No OPML file to upload.");
+               alert(__("No OPML file to upload."));
                return false;
        } else {
                return true;
@@ -1080,10 +1212,6 @@ function updateFilterList(sort_key) {
                return
        }
 
-//     document.getElementById("prefContent").innerHTML = "Loading filters, please wait...";
-
-//     p_notify("Loading, please wait...");
-
        xmlhttp.open("GET", "backend.php?op=pref-filters&sort=" + 
                param_escape(sort_key), true);
        xmlhttp.onreadystatechange=filterlist_callback;
@@ -1098,10 +1226,6 @@ function updateLabelList(sort_key) {
                return
        }
 
-//     p_notify("Loading, please wait...");
-
-//     document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
-
        xmlhttp.open("GET", "backend.php?op=pref-labels&sort=" + 
                param_escape(sort_key), true);
        xmlhttp.onreadystatechange=labellist_callback;
@@ -1115,15 +1239,13 @@ function updatePrefsList() {
                return
        }
 
-//     p_notify("Loading, please wait...");
-
        xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
        xmlhttp.onreadystatechange=prefslist_callback;
        xmlhttp.send(null);
 
 }
 
-function selectTab(id, noupdate) {
+function selectTab(id, noupdate, subop) {
 
 //     alert(id);
 
@@ -1136,11 +1258,16 @@ function selectTab(id, noupdate) {
                        return
                }
 
+               try {
+                       var c = document.getElementById('prefContent'); 
+                       c.scrollTop = 0;
+               } catch (e) { };
+
                if (!noupdate) {
 
                        debug("selectTab: " + id + "(NU: " + noupdate + ")");
        
-//                     notify("Loading, please wait...", true);
+                       notify_progress("Loading, please wait...");
        
                        // close active infobox if needed
                        closeInfoBox();
@@ -1148,7 +1275,10 @@ function selectTab(id, noupdate) {
                        // 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 } } );
+
                        if (id == "feedConfig") {
                                updateFeedList();
                        } else if (id == "filterConfig") {
@@ -1180,10 +1310,6 @@ function selectTab(id, noupdate) {
                        }
                }
        
-               if (active_tab != id) {
-                       storeInitParam("prefs_active_tab", id);
-               }
-       
                active_tab = id;
 
        } catch (e) {
@@ -1196,7 +1322,14 @@ function backend_sanity_check_callback() {
        if (xmlhttp.readyState == 4) {
 
                try {
-               
+
+                       if (sanity_check_done) {
+                               fatalError(11, "Sanity check request received twice. This can indicate "+
+                             "presence of Firebug or some other disrupting extension. "+
+                                       "Please disable it and try again.");
+                               return;
+                       }
+
                        if (!xmlhttp.responseXML) {
                                fatalError(3, "[D001, Received reply is not XML]: " + xmlhttp.responseText);
                                return;
@@ -1232,6 +1365,8 @@ function backend_sanity_check_callback() {
                                }
                        }
 
+                       sanity_check_done = true;
+
                        init_second_stage();
 
                } catch (e) {
@@ -1244,10 +1379,18 @@ function init_second_stage() {
 
        try {
                active_tab = getInitParam("prefs_active_tab");
-               if (!active_tab) active_tab = "genConfig";
+               if (!active_tab || active_tab == '0') active_tab = "genConfig";
 
                document.onkeydown = pref_hotkey_handler;
 
+               var tab = getURLParam('tab');
+               
+               caller_subop = getURLParam('subop');
+
+               if (tab) {
+                       active_tab = tab;
+               }
+
                if (navigator.userAgent.match("Opera")) {       
                        setTimeout("selectTab()", 500);
                } else {
@@ -1302,7 +1445,7 @@ function categorizeSelectedFeeds() {
 
        if (sel_rows.length > 0) {
 
-               notify("Changing category of selected feeds...");
+               notify_progress("Changing category of selected feeds...");
 
                xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=categorize&ids="+
                        param_escape(sel_rows.toString()) + "&cat_id=" + param_escape(cat_id), true);
@@ -1311,14 +1454,34 @@ function categorizeSelectedFeeds() {
 
        } else {
 
-               alert("No feeds are selected.");
+               alert(__("No feeds are selected."));
 
        }
 
 }
 
 function validatePrefsReset() {
-       return confirm("Reset to defaults?");
+       try {
+               var ok = confirm(__("Reset to defaults?"));
+
+               if (ok) {
+
+                       var query = Form.serialize("pref_prefs_form");
+                       query = query + "&subop=reset-config";
+                       debug(query);
+
+                       xmlhttp.open("POST", "backend.php", true);
+                       xmlhttp.onreadystatechange=prefs_reset_callback;
+                       xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+                       xmlhttp.send(query);
+               }
+
+       } catch (e) {
+               exception_error("validatePrefsSave", e);
+       }
+
+       return false;
+
 }
 
 function browseFeeds(limit) {
@@ -1341,7 +1504,7 @@ function feedBrowserSubscribe() {
                        xmlhttp.onreadystatechange=feedlist_callback;
                        xmlhttp.send(null);
                } else {
-                       alert("No feeds are selected.");
+                       alert(__("No feeds are selected."));
                }
 
        } catch (e) {
@@ -1356,8 +1519,6 @@ function updateBigFeedBrowser(limit) {
                return
        }
 
-//     p_notify("Loading, please wait...");
-
        var query = "backend.php?op=pref-feed-browser";
 
        var limit_sel = document.getElementById("feedBrowserLimit");
@@ -1384,18 +1545,17 @@ function browserToggleExpand(id) {
                        return
                }
 
-               var d = document.getElementById("BRDET-" + id);
+/*             if (feed_to_expand && id != feed_to_expand) {
+                       Effect.Fade('BRDET-' + feed_to_expand, {duration : 0.5});
+               } */
 
-               if (d.style.display == "block") {               
-                       d.style.display = "none";
-                       
-               } else {
+               var d = document.getElementById("BRDET-" + id);
        
+               if (Element.visible(d)) {
+                       Effect.Fade(d, {duration : 0.5});
+               } else {
                        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;
@@ -1403,20 +1563,8 @@ function browserToggleExpand(id) {
                }
 
        } catch (e) {
-               exception_error("browserExpand", e);
-       }
-}
-
-function validateNewPassword(form) {
-       if (form.OLD_PASSWORD.value == "") {
-               alert("Old password cannot be blank");
-               return false;
-       }
-       if (form.NEW_PASSWORD.value == "") {
-               alert("New password cannot be blank");
-               return false;
+               exception_error("browserToggleExpand", e);
        }
-       return true;
 }
 
 function selectPrefRows(kind, select) {
@@ -1435,7 +1583,7 @@ function selectPrefRows(kind, select) {
                } else if (kind == "fcat") {
                        opbarid = "catOpToolbar";
                        nrow = "FCATR-";
-                       nchk = "FCHK-";
+                       nchk = "FCCHK-";
                        lname = "prefFeedCatList";
                } else if (kind == "filter") {
                        opbarid = "filterOpToolbar";
@@ -1537,4 +1685,231 @@ 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;
+       } catch (e) {
+               // this button is not always available, no-op if not found
+       }
+
+       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
+       xmlhttp.onreadystatechange=infobox_feed_cat_callback;
+       xmlhttp.send(null);
+}
+
+function showFeedsWithErrors() {
+       displayDlg('feedUpdateErrors');
+}
+
+function changeUserPassword() {
+
+       try {
+
+               if (!xmlhttp_ready(xmlhttp)) {
+                       printLockingError();
+                       return false;
+               }
+       
+               var f = document.forms["change_pass_form"];
+
+               if (f) {
+                       if (f.OLD_PASSWORD.value == "") {
+                               new Effect.Highlight(f.OLD_PASSWORD);
+                               notify_error("Old password cannot be blank.");
+                               return false;
+                       }
+
+                       if (f.NEW_PASSWORD.value == "") {
+                               new Effect.Highlight(f.NEW_PASSWORD);
+                               notify_error("New password cannot be blank.");
+                               return false;
+                       }
+
+                       if (f.CONFIRM_PASSWORD.value == "") {
+                               new Effect.Highlight(f.CONFIRM_PASSWORD);
+                               notify_error("Entered passwords do not match.");
+                               return false;
+                       }
+
+                       if (f.CONFIRM_PASSWORD.value != f.NEW_PASSWORD.value) {
+                               new Effect.Highlight(f.CONFIRM_PASSWORD);
+                               new Effect.Highlight(f.NEW_PASSWORD);
+                               notify_error("Entered passwords do not match.");
+                               return false;
+                       }
+
+               }
+
+               var query = Form.serialize("change_pass_form");
+       
+               notify_progress("Trying to change password...");
+       
+               xmlhttp.open("POST", "backend.php", true);
+               xmlhttp.onreadystatechange=changepass_callback;
+               xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+               xmlhttp.send(query);
+
+       } catch (e) {
+               exception_error("changeUserPassword", e);
+       }
+       
+       return false;
+}
+
+function changeUserEmail() {
+
+       try {
+
+               if (!xmlhttp_ready(xmlhttp)) {
+                       printLockingError();
+                       return false;
+               }
+       
+               var query = Form.serialize("change_email_form");
+       
+               notify_progress("Trying to change e-mail...");
+       
+               xmlhttp.open("POST", "backend.php", true);
+               xmlhttp.onreadystatechange=notify_callback;
+               xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+               xmlhttp.send(query);
+
+       } catch (e) {
+               exception_error("changeUserPassword", e);
+       }
+       
+       return false;
+
+}
+
+function feedlistToggleSLAT() {
+       notify_progress("Loading, please wait...");
+       updateFeedList()
+}
+
+function pubRegenKey() {
+
+       if (!xmlhttp_ready(xmlhttp)) {
+               printLockingError();
+               return false;
+       }
+
+       var ok = confirm(__("Replace current publishing address with a new one?"));
+
+       if (ok) {
+
+               notify_progress("Trying to change address...");
+
+               xmlhttp.open("GET", "backend.php?op=rpc&subop=regenPubKey");
+               xmlhttp.onreadystatechange=replace_pubkey_callback;
+               xmlhttp.send(null);
+       }
+
+       return false;
+}
+
+function pubToClipboard() {
+
+       try {
+
+               if (!xmlhttp_ready(xmlhttp)) {
+                       printLockingError();
+                       return false;
+               }
+       
+               var link = document.getElementById("pubGenAddress");
+               alert(link.href);
+
+       } catch (e) {
+               exception_error("pubToClipboard", e);
+       }
+
+       return false; 
+}
+
+function validatePrefsSave() {
+       try {
+
+               var ok = confirm(__("Save current configuration?"));
+
+               if (ok) {
+
+                       var query = Form.serialize("pref_prefs_form");
+                       query = query + "&subop=save-config";
+                       debug(query);
+
+                       xmlhttp.open("POST", "backend.php", true);
+                       xmlhttp.onreadystatechange=notify_callback;
+                       xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+                       xmlhttp.send(query);
+               }
+
+       } catch (e) {
+               exception_error("validatePrefsSave", e);
+       }
+
+       return false;
+}
+
+function feedActionChange() {
+       try {
+               var chooser = document.getElementById("feedActionChooser");
+               var opid = chooser[chooser.selectedIndex].value;
+
+               chooser.selectedIndex = 0;
+               feedActionGo(opid);
+       } catch (e) {
+               exception_error("feedActionChange", e);
+       }
+}
+
+function feedActionGo(op) {    
+       try {
+               if (op == "facEdit") {
+                       editSelectedFeed();
+               }
+
+               if (op == "facClear") {
+                       clearSelectedFeeds();
+               }
+
+               if (op == "facPurge") {
+                       purgeSelectedFeeds();
+               }
+
+               if (op == "facEditCats") {
+                       editFeedCats();
+               }
+
+               if (op == "facUnsubscribe") {
+                       removeSelectedFeeds();
+               }
+
+       } catch (e) {
+               exception_error("feedActionGo", e);
+
+       }
+}
+
+function clearFeedArticles(feed_id) {
+
+       notify_progress("Clearing feed...");
+
+       var query = "backend.php?op=pref-feeds&quiet=1&subop=clear&id=" + feed_id;
+
+       new Ajax.Request(query, {
+               onComplete: function(transport) {
+                               notify('');
+                       } });
+
+       return false;
+}
+