]> git.wh0rd.org - tt-rss.git/blobdiff - prefs.js
tweak feed errors notification
[tt-rss.git] / prefs.js
index 28e54ee4faa78ff9ac0f90bdc35b6b27856667e4..6b772b1cddd7b0a035c95ee5a99d2dff536c4568 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -31,20 +31,6 @@ function feedlist_callback() {
                        var container = document.getElementById('prefContent'); 
                        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;
-                               }
-                       }
-
                        notify("");
                } catch (e) {
                        exception_error("feedlist_callback", e);
@@ -63,8 +49,8 @@ function filterlist_callback() {
 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) {
@@ -157,7 +143,7 @@ function updateFeedList(sort_key) {
 
 }
 
-function updateUsersList() {
+function updateUsersList(sort_key) {
 
        if (!xmlhttp_ready(xmlhttp)) {
                printLockingError();
@@ -168,7 +154,8 @@ function updateUsersList() {
 
 //     p_notify("Loading, please wait...");
 
-       xmlhttp.open("GET", "backend.php?op=pref-users", true);
+       xmlhttp.open("GET", "backend.php?op=pref-users&sort="
+               + param_escape(sort_key), true);
        xmlhttp.onreadystatechange=userlist_callback;
        xmlhttp.send(null);
 
@@ -181,55 +168,26 @@ function addLabel() {
                return
        }
 
-       var sqlexp = document.getElementById("ladd_expr");
-
-       if (sqlexp.value.length == 0) {
-               alert("Can't add label: missing SQL expression.");
-       } else {
-               notify("Adding label...");
+       var form = document.forms['label_edit_form'];
 
-               xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&exp=" +
-                       param_escape(sqlexp.value), true);                      
-                       
-               xmlhttp.onreadystatechange=labellist_callback;
-               xmlhttp.send(null);
+       var sql_exp = form.sql_exp.value;
+       var description = form.description.value;
 
-               sqlexp.value = "";
+       if (sql_exp == "") {
+               alert("Can't create label: missing SQL expression.");
+               return false;
        }
 
-}
-
-function addFilter() {
-
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
+       if (description == "") {
+               alert("Can't create label: missing caption.");
+               return false;
        }
 
-       var regexp = document.getElementById("fadd_regexp");
-       var match = document.getElementById("fadd_match");
-       var feed = document.getElementById("fadd_feed");
-       var action = document.getElementById("fadd_action");
-
-       if (regexp.value.length == 0) {
-               alert("Can't add filter: missing filter expression.");
-       } else {
-               notify("Adding filter...");
-
-               var v_match = match[match.selectedIndex].text;
-               var feed_id = feed[feed.selectedIndex].id;
-               var action_id = action[action.selectedIndex].id;
-
-               xmlhttp.open("GET", "backend.php?op=pref-filters&subop=add&regexp=" +
-                       param_escape(regexp.value) + "&match=" + v_match +
-                       "&fid=" + param_escape(feed_id) + "&aid=" + param_escape(action_id), true);
-                       
-               xmlhttp.onreadystatechange=filterlist_callback;
-               xmlhttp.send(null);
-
-               regexp.value = "";
-       }
+       var query = Form.serialize("label_edit_form");
 
+       xmlhttp.open("GET", "backend.php?op=pref-labels&subop=add&" + query, true);                     
+       xmlhttp.onreadystatechange=infobox_submit_callback;
+       xmlhttp.send(null);
 }
 
 function addFeed() {
@@ -273,9 +231,9 @@ function addFeedCat() {
        } else {
                notify("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 = "";
@@ -315,6 +273,8 @@ function editLabel(id) {
                return
        }
 
+       document.getElementById("label_create_btn").disabled = true;
+
        active_label = id;
 
        selectTableRowsByIdPrefix('prefLabelList', 'LILRR-', 'LICHK-', false);
@@ -391,9 +351,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);
 
 }
@@ -575,9 +535,9 @@ function removeSelectedFeedCats() {
                if (ok) {
                        notify("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);
                }
 
@@ -615,8 +575,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;
@@ -663,7 +623,7 @@ function feedCatEditSave() {
        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;
@@ -709,6 +669,8 @@ function labelEditCancel() {
                return
        }
 
+       document.getElementById("label_create_btn").disabled = false;
+
        active_label = false;
 
        selectPrefRows('label', false); // cleanup feed selection
@@ -754,18 +716,21 @@ function labelEditSave() {
                return
        }
 
-       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;
-       }
+/*     if (!is_opera()) {
 
-       if (description.length == 0) {
-               alert("Caption field cannot be blank.");
-               return;
-       }
+               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();
 
@@ -817,12 +782,14 @@ function filterEditSave() {
                return
        }
 
-       var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
-
-       if (reg_exp.length == 0) {
-               alert("Filter expression field cannot be blank.");
-               return;
-       }
+/*     if (!is_opera()) {
+               var reg_exp = document.forms["filter_edit_form"].reg_exp.value;
+       
+               if (reg_exp.length == 0) {
+                       alert("Filter expression field cannot be blank.");
+                       return;
+               }
+       } */
 
        notify("Saving filter...");
 
@@ -1092,7 +1059,7 @@ function validateOpmlImport() {
        }
 }
 
-function updateFilterList() {
+function updateFilterList(sort_key) {
 
        if (!xmlhttp_ready(xmlhttp)) {
                printLockingError();
@@ -1103,13 +1070,14 @@ function updateFilterList() {
 
 //     p_notify("Loading, please wait...");
 
-       xmlhttp.open("GET", "backend.php?op=pref-filters", true);
+       xmlhttp.open("GET", "backend.php?op=pref-filters&sort=" + 
+               param_escape(sort_key), true);
        xmlhttp.onreadystatechange=filterlist_callback;
        xmlhttp.send(null);
 
 }
 
-function updateLabelList() {
+function updateLabelList(sort_key) {
 
        if (!xmlhttp_ready(xmlhttp)) {
                printLockingError();
@@ -1120,7 +1088,8 @@ function updateLabelList() {
 
 //     document.getElementById("prefContent").innerHTML = "Loading labels, please wait...";
 
-       xmlhttp.open("GET", "backend.php?op=pref-labels", true);
+       xmlhttp.open("GET", "backend.php?op=pref-labels&sort=" + 
+               param_escape(sort_key), true);
        xmlhttp.onreadystatechange=labellist_callback;
        xmlhttp.send(null);
 }
@@ -1153,11 +1122,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("Loading, please wait...", true);
        
                        // close active infobox if needed
                        closeInfoBox();
@@ -1452,7 +1426,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";
@@ -1554,4 +1528,23 @@ 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');
+}