]> git.wh0rd.org - tt-rss.git/blobdiff - prefs.js
pref-feeds tweaks
[tt-rss.git] / prefs.js
index b233d8a1ffdb779323f074365ef3c86d2ff3e5b6..43a554cf2ba02fb2b8045b0c4cd7f06156fb81ab 100644 (file)
--- a/prefs.js
+++ b/prefs.js
@@ -13,6 +13,19 @@ 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 {   
@@ -24,15 +37,17 @@ function replace_pubkey_callback() {
 
                                if (new_link) {
                                        link.href = new_link.firstChild.nodeValue;
-                                       link.innerHTML = new_link.firstChild.nodeValue;
+                                       //link.innerHTML = new_link.firstChild.nodeValue;
 
-                                       notify_info("Address changed.");
+                                       new Effect.Highlight(link);
+
+                                       notify_info("Published feed URL changed.");
                                } else {
-                                       notify_error("Could not change address.");
+                                       notify_error("Could not change feed URL.");
                                }
 
                        } else {
-                               notify_error("Could not change address.");
+                               notify_error("Could not change feed URL.");
                        }
                } catch (e) {
                        exception_error("replace_pubkey_callback", e);
@@ -46,7 +61,6 @@ function expand_feed_callback() {
                        var container = document.getElementById("BRDET-" + feed_to_expand);     
                        container.innerHTML=xmlhttp.responseText;
 //                     container.style.display = "block";
-//                     p_notify("");
                        Effect.Appear(container, {duration : 0.5});
                } catch (e) {
                        exception_error("expand_feed_callback", e);
@@ -81,31 +95,29 @@ function feedlist_callback() {
 
 /* stub for subscription dialog */
 
-function dlg_frefresh_callback() {
-       if (xmlhttp.readyState == 4) {          
-       //      setTimeout("updateFeedList()", 500);
+function dlg_frefresh_callback(transport) {
 
-               try {
-                       var container = document.getElementById('prefContent'); 
-                       container.innerHTML=xmlhttp.responseText;
-                       selectTab("feedConfig", true);
+       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);
-                               }                               
+               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);
+                       caller_subop = false;
                }
+               if (typeof correctPNG != 'undefined') {
+                       correctPNG();
+               }
+               notify("");
+       } catch (e) {
+               exception_error("feedlist_callback", e);
        }
+
 }
 
 function filterlist_callback() {
@@ -246,10 +258,6 @@ 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; }
@@ -277,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;
@@ -664,6 +668,74 @@ function removeSelectedFeeds() {
        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."));
+
+       }
+       
+       return false;
+}
+
 function removeSelectedFeedCats() {
 
        if (!xmlhttp_ready(xmlhttp)) {
@@ -784,30 +856,6 @@ function feedCatEditSave() {
        return false;
 }
 
-
-
-function displayHelpInfobox(topic_id) {
-
-/*     if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
-
-       notify_progress("Loading help...");
-
-       xmlhttp.open("GET", "backend.php?op=help&tid=" +
-               param_escape(topic_id), true);
-
-       xmlhttp.onreadystatechange=helpbox_callback;
-       xmlhttp.send(null); */
-
-       var url = "backend.php?op=help&tid=" + param_escape(topic_id);
-
-       var w = window.open(url, "ttrss_help", 
-               "status=0,toolbar=0,location=0,width=400,height=450,menubar=0");
-
-}
-
 function labelEditCancel() {
 
        if (!xmlhttp_ready(xmlhttp)) {
@@ -1164,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;
@@ -1182,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;
@@ -1199,8 +1239,6 @@ function updatePrefsList() {
                return
        }
 
-//     p_notify("Loading, please wait...");
-
        xmlhttp.open("GET", "backend.php?op=pref-prefs", true);
        xmlhttp.onreadystatechange=prefslist_callback;
        xmlhttp.send(null);
@@ -1237,7 +1275,10 @@ 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 } } );
+
                        if (id == "feedConfig") {
                                updateFeedList();
                        } else if (id == "filterConfig") {
@@ -1478,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");
@@ -1646,12 +1685,6 @@ 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();
@@ -1684,6 +1717,36 @@ function changeUserPassword() {
                        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...");
@@ -1752,6 +1815,25 @@ function pubRegenKey() {
        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 {
 
@@ -1775,3 +1857,59 @@ function validatePrefsSave() {
 
        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;
+}
+
+