]> git.wh0rd.org - tt-rss.git/blobdiff - prefs.js
interface tweaks
[tt-rss.git] / prefs.js
index 4a018345f9ae84d1f8d829f7ec9b1b4859e69c2c..2539c3b629623c76863bace525f0fd35ae6f2188 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -145,23 +145,6 @@ function userlist_callback() {
        }
 }
 
-function infobox_callback() {
-       if (xmlhttp.readyState == 4) {
-               var box = document.getElementById('infoBox');
-               var shadow = document.getElementById('infoBoxShadow');
-
-               if (box) {
-                       box.innerHTML=xmlhttp.responseText;
-                       if (shadow) {
-                               shadow.style.display = "block";
-                       } else {
-                               box.style.display = "block";                            
-                       }
-               }
-       }
-}
-
-
 function prefslist_callback() {
        var container = document.getElementById('prefContent');
        if (xmlhttp.readyState == 4) {
@@ -240,7 +223,7 @@ function addLabel() {
        var sqlexp = document.getElementById("ladd_expr");
 
        if (sqlexp.value.length == 0) {
-               notify("Missing SQL expression.");
+               alert("Can't add label: missing SQL expression.");
        } else {
                notify("Adding label...");
 
@@ -268,7 +251,7 @@ function addFilter() {
        var action = document.getElementById("fadd_action");
 
        if (regexp.value.length == 0) {
-               notify("Missing filter expression.");
+               alert("Can't add filter: missing filter expression.");
        } else {
                notify("Adding filter...");
 
@@ -298,7 +281,7 @@ function addFeed() {
        var link = document.getElementById("fadd_link");
 
        if (link.value.length == 0) {
-               notify("Missing feed URL.");
+               alert("Error: No feed URL given.");
        } else {
                notify("Adding feed...");
 
@@ -323,7 +306,7 @@ function addFeedCat() {
        var cat = document.getElementById("fadd_cat");
 
        if (cat.value.length == 0) {
-               notify("Missing feed category.");
+               alert("Can't add category: no name specified.");
        } else {
                notify("Adding feed category...");
 
@@ -347,7 +330,7 @@ function addUser() {
        var sqlexp = document.getElementById("uadd_box");
 
        if (sqlexp.value.length == 0) {
-               notify("Missing user login.");
+               alert("Can't add user: no login specified.");
        } else {
                notify("Adding user...");
 
@@ -477,7 +460,7 @@ function getSelectedFeedCats() {
 }
 
 
-function readSelectedFeeds(read) {
+/*function readSelectedFeeds(read) {
 
        if (!xmlhttp_ready(xmlhttp)) {
                printLockingError();
@@ -503,10 +486,10 @@ function readSelectedFeeds(read) {
 
        } else {
 
-               notify("Please select some feeds first.");
+               alert("No feeds are selected.");
 
        }
-}
+} */
 
 function removeSelectedLabels() {
 
@@ -530,7 +513,7 @@ function removeSelectedLabels() {
                        xmlhttp.send(null);
                }
        } else {
-               notify("Please select some labels first.");
+               alert("No labels are selected.");
        }
 }
 
@@ -557,7 +540,7 @@ function removeSelectedUsers() {
                }
 
        } else {
-               notify("Please select some labels first.");
+               alert("No users are selected.");
        }
 }
 
@@ -583,7 +566,7 @@ function removeSelectedFilters() {
                        xmlhttp.send(null);
                }
        } else {
-               notify("Please select some filters first.");
+               alert("No filters are selected.");
        }
 }
 
@@ -613,7 +596,7 @@ function removeSelectedFeeds() {
 
        } else {
 
-               notify("Please select some feeds first.");
+               alert("No feeds are selected.");
 
        }
 
@@ -643,7 +626,7 @@ function removeSelectedFeedCats() {
 
        } else {
 
-               notify("Please select some feeds first.");
+               alert("No categories are selected.");
 
        }
 
@@ -660,7 +643,7 @@ function feedEditCancel() {
 
        active_feed = false;
 
-       notify("Operation cancelled.");
+//     notify("Operation cancelled.");
 
 /*     xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
        xmlhttp.onreadystatechange=feedlist_callback;
@@ -677,7 +660,7 @@ function feedCatEditCancel() {
 
        active_feed_cat = false;
 
-       notify("Operation cancelled.");
+//     notify("Operation cancelled.");
 
        xmlhttp.open("GET", "backend.php?op=pref-feeds", true);
        xmlhttp.onreadystatechange=feedlist_callback;
@@ -698,16 +681,27 @@ function feedEditSave() {
        
                var link = document.getElementById("iedit_link").value;
                var title = document.getElementById("iedit_title").value;
-               var upd_intl = document.getElementById("iedit_updintl").value;
-               var purge_intl = document.getElementById("iedit_purgintl").value;
+               var upd_intl = document.getElementById("iedit_updintl");
+
+               upd_intl = upd_intl[upd_intl.selectedIndex].id;
+                       
+               var purge_intl = document.getElementById("iedit_purgintl");
+
+               purge_intl = purge_intl[purge_intl.selectedIndex].id;
+               
                var fcat = document.getElementById("iedit_fcat");
 
                var is_pvt = document.getElementById("iedit_private");
+               var is_rtl = document.getElementById("iedit_rtl");
 
                if (is_pvt) {
                        is_pvt = is_pvt.checked;
                }
-       
+
+               if (is_rtl) {
+                       is_rtl = is_rtl.checked;
+               }
+
                var fcat_id = 0;
        
                if (fcat) {     
@@ -739,7 +733,7 @@ function feedEditSave() {
                        "&ui=" + param_escape(upd_intl) + "&pi=" + param_escape(purge_intl) +
                        "&catid=" + param_escape(fcat_id) + "&login=" + param_escape(auth_login) +                      
                        "&pfeed=" + param_escape(parent_feed_id) + "&pass=" + param_escape(auth_pass) +
-                       "&is_pvt=" + param_escape(is_pvt);
+                       "&is_pvt=" + param_escape(is_pvt) + "&is_rtl=" + param_escape(is_rtl);
 
                xmlhttp.open("POST", "backend.php", true);
                xmlhttp.onreadystatechange=feedlist_callback;
@@ -805,7 +799,7 @@ function labelEditCancel() {
 
        active_label = false;
 
-       notify("Operation cancelled.");
+//     notify("Operation cancelled.");
 
        xmlhttp.open("GET", "backend.php?op=pref-labels", true);
        xmlhttp.onreadystatechange=labellist_callback;
@@ -822,7 +816,7 @@ function userEditCancel() {
 
        active_user = false;
 
-       notify("Operation cancelled.");
+//     notify("Operation cancelled.");
 
        xmlhttp.open("GET", "backend.php?op=pref-users", true);
        xmlhttp.onreadystatechange=userlist_callback;
@@ -839,7 +833,7 @@ function filterEditCancel() {
 
        active_filter = false;
 
-       notify("Operation cancelled.");
+//     notify("Operation cancelled.");
 
        xmlhttp.open("GET", "backend.php?op=pref-filters", true);
        xmlhttp.onreadystatechange=filterlist_callback;
@@ -894,7 +888,10 @@ function userEditSave() {
        }
 
        var login = document.getElementById("iedit_ulogin").value;
-       var level = document.getElementById("iedit_ulevel").value;
+       var level = document.getElementById("iedit_ulevel");
+
+       level = level[level.selectedIndex].id;
+       
        var email = document.getElementById("iedit_email").value;
 
        if (login.length == 0) {
@@ -931,7 +928,6 @@ function filterEditSave() {
        }
 
        var regexp = document.getElementById("iedit_regexp").value;
-       var descr = document.getElementById("iedit_descr").value;
        var match = document.getElementById("iedit_match");
 
        var v_match = match[match.selectedIndex].text;
@@ -942,19 +938,16 @@ function filterEditSave() {
        var action = document.getElementById("iedit_filter_action");
        var action_id = action[action.selectedIndex].id;
 
-//     notify("Saving filter " + filter + ": " + regexp + ", " + descr + ", " + match);
-
        if (regexp.length == 0) {
-               notify("Filter expression cannot be blank.");
+               alert("Can't save filter: match expression is blank.");
                return;
        }
 
        active_filter = false;
 
        xmlhttp.open("GET", "backend.php?op=pref-filters&subop=editSave&id=" +
-               filter + "&r=" + param_escape(regexp) + "&d=" + param_escape(descr) +
-               "&m=" + param_escape(v_match) + "&fid=" + param_escape(feed_id) + 
-               "&aid=" + param_escape(action_id), true);
+               filter + "&r=" + param_escape(regexp) + "&m=" + param_escape(v_match) + 
+               "&fid=" + param_escape(feed_id) + "&aid=" + param_escape(action_id), true);
 
        notify("Saving filter...");
 
@@ -967,12 +960,12 @@ function editSelectedLabel() {
        var rows = getSelectedLabels();
 
        if (rows.length == 0) {
-               notify("No labels are selected.");
+               alert("No labels are selected.");
                return;
        }
 
        if (rows.length > 1) {
-               notify("Please select one label.");
+               alert("Please select only one label.");
                return;
        }
 
@@ -986,12 +979,12 @@ function editSelectedUser() {
        var rows = getSelectedUsers();
 
        if (rows.length == 0) {
-               notify("No users are selected.");
+               alert("No users are selected.");
                return;
        }
 
        if (rows.length > 1) {
-               notify("Please select one user.");
+               alert("Please select only one user.");
                return;
        }
 
@@ -1004,12 +997,12 @@ function resetSelectedUserPass() {
        var rows = getSelectedUsers();
 
        if (rows.length == 0) {
-               notify("No users are selected.");
+               alert("No users are selected.");
                return;
        }
 
        if (rows.length > 1) {
-               notify("Please select one user.");
+               alert("Please select only one user.");
                return;
        }
 
@@ -1037,12 +1030,12 @@ function selectedUserDetails() {
        var rows = getSelectedUsers();
 
        if (rows.length == 0) {
-               notify("No users are selected.");
+               alert("No users are selected.");
                return;
        }
 
        if (rows.length > 1) {
-               notify("Please select one user.");
+               alert("Please select only one user.");
                return;
        }
 
@@ -1066,14 +1059,14 @@ function selectedFeedDetails() {
        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.");
-//             return;
-//     }
+       if (rows.length > 1) {
+               notify("Please select only one feed.");
+               return;
+       }
 
 //     var id = rows[0];
 
@@ -1090,12 +1083,12 @@ function editSelectedFilter() {
        var rows = getSelectedFilters();
 
        if (rows.length == 0) {
-               notify("No filters are selected.");
+               alert("No filters are selected.");
                return;
        }
 
        if (rows.length > 1) {
-               notify("Please select one filter.");
+               alert("Please select only one filter.");
                return;
        }
 
@@ -1129,12 +1122,12 @@ function editSelectedFeedCat() {
        var rows = getSelectedFeedCats();
 
        if (rows.length == 0) {
-               notify("No categories are selected.");
+               alert("No categories are selected.");
                return;
        }
 
        if (rows.length > 1) {
-               notify("Please select one category.");
+               alert("Please select only one category.");
                return;
        }
 
@@ -1208,7 +1201,7 @@ function validateOpmlImport() {
        var opml_file = document.getElementById("opml_file");
 
        if (opml_file.value.length == 0) {
-               notify("Please select OPML file to upload.");
+               alert("No OPML file to upload.");
                return false;
        } else {
                return true;
@@ -1337,17 +1330,6 @@ function init() {
        }
 }
 
-function closeInfoBox() {
-       var box = document.getElementById('infoBox');
-       var shadow = document.getElementById('infoBoxShadow');
-
-       if (shadow) {
-               shadow.style.display = "none";
-       } else if (box) {
-               box.style.display = "none";
-       }
-}
-
 function categorizeSelectedFeeds() {
 
        if (!xmlhttp_ready(xmlhttp)) {
@@ -1371,7 +1353,7 @@ function categorizeSelectedFeeds() {
 
        } else {
 
-               notify("Please select some feeds first.");
+               alert("No feeds are selected.");
 
        }
 
@@ -1381,7 +1363,7 @@ function validatePrefsReset() {
        return confirm("Reset to defaults?");
 }
 
-function browseFeeds() {
+function browseFeeds(limit) {
 
        xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=browse", true);
        xmlhttp.onreadystatechange=infobox_callback;
@@ -1425,7 +1407,7 @@ function feedBrowserSubscribe() {
        }
 }
 
-function updateBigFeedBrowser() {
+function updateBigFeedBrowser(limit) {
 
        if (!xmlhttp_ready(xmlhttp)) {
                printLockingError();
@@ -1434,10 +1416,18 @@ function updateBigFeedBrowser() {
 
        p_notify("Loading, please wait...");
 
-       xmlhttp.open("GET", "backend.php?op=pref-feed-browser", true);
+       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) {
@@ -1466,3 +1456,15 @@ function browserToggleExpand(id) {
                exception_error("browserExpand", e);
        }
 }
+
+function validateNewPassword(form) {
+       if (form.OLD_PASSWORD.value == "") {
+               alert("Current password cannot be blank");
+               return false;
+       }
+       if (form.NEW_PASSWORD.value == "") {
+               alert("New password cannot be blank");
+               return false;
+       }
+       return true;
+}