]> git.wh0rd.org - tt-rss.git/blobdiff - prefs.js
UI improvements
[tt-rss.git] / prefs.js
index 2c10a2dbcdcd2c536411e4844f368f2cb1948d34..53f9ecc98bf25ca4a769f3bd597768e3e78eed0e 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -12,6 +12,8 @@ var xmlhttp = Ajax.getTransport();
 
 var init_params = new Array();
 
+var caller_subop = false;
+
 function expand_feed_callback() {
        if (xmlhttp.readyState == 4) {
                try {   
@@ -32,17 +34,13 @@ 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;
                        }
 
                        notify("");
@@ -128,10 +126,9 @@ function gethelp_callback() {
 
 
 function notify_callback() {
-       var container = document.getElementById('notify');
        if (xmlhttp.readyState == 4) {
-               container.innerHTML=xmlhttp.responseText;
-       }
+               notify_info(xmlhttp.responseText);
+       } 
 }
 
 function updateFeedList(sort_key) {
@@ -218,9 +215,9 @@ function addFeed() {
        } else if (!isValidURL(link.value)) {
                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);
@@ -243,11 +240,11 @@ function addFeedCat() {
        if (cat.value.length == 0) {
                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 = "";
@@ -267,7 +264,7 @@ function addUser() {
        if (sqlexp.value.length == 0) {
                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);                      
@@ -365,9 +362,9 @@ function editFeedCat(cat) {
 
        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);
 
 }
@@ -429,7 +426,7 @@ function removeSelectedLabels() {
                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);
@@ -457,7 +454,7 @@ function removeSelectedUsers() {
                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);
@@ -486,7 +483,7 @@ function removeSelectedFilters() {
                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);
@@ -516,7 +513,7 @@ function removeSelectedFeeds() {
 
                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);
@@ -547,11 +544,11 @@ function removeSelectedFeedCats() {
                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);
                }
 
@@ -589,8 +586,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 +606,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 +629,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;
@@ -748,7 +745,7 @@ function labelEditSave() {
 
        closeInfoBox();
 
-       notify("Saving label...");
+       notify_progress("Saving label...");
 
        active_label = false;
 
@@ -775,7 +772,7 @@ function userEditSave() {
                return;
        }
        
-       notify("Saving user...");
+       notify_progress("Saving user...");
 
        closeInfoBox();
 
@@ -805,7 +802,7 @@ function filterEditSave() {
                }
        } */
 
-       notify("Saving filter...");
+       notify_progress("Saving filter...");
 
        var query = Form.serialize("filter_edit_form");
 
@@ -873,7 +870,7 @@ function resetSelectedUserPass() {
        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];
        
@@ -928,7 +925,7 @@ function selectedFeedDetails() {
        }
 
        if (rows.length > 1) {
-               notify("Please select only one feed.");
+               alert("Please select only one feed.");
                return;
        }
 
@@ -967,12 +964,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;
        }
 
@@ -1123,7 +1120,7 @@ function updatePrefsList() {
 
 }
 
-function selectTab(id, noupdate) {
+function selectTab(id, noupdate, subop) {
 
 //     alert(id);
 
@@ -1136,11 +1133,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...", true);
        
                        // close active infobox if needed
                        closeInfoBox();
@@ -1248,6 +1250,14 @@ function init_second_stage() {
 
                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 +1312,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);
@@ -1435,7 +1445,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 +1547,25 @@ function pref_hotkey_handler(e) {
        }
 }
 
+function userSwitch() {
+       var chooser = document.getElementById("userSwitch");
+       var user = chooser[chooser.selectedIndex].value;
+       window.location = "prefs.php?swu=" + user;
+}
+
+function editFeedCats() {
+       if (!xmlhttp_ready(xmlhttp)) {
+               printLockingError();
+               return
+       }
+
+       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=editCats", true);
+       xmlhttp.onreadystatechange=infobox_callback;
+       xmlhttp.send(null);
+}
+
+function showFeedsWithErrors() {
+       displayDlg('feedUpdateErrors');
+}
+