]> git.wh0rd.org - tt-rss.git/blobdiff - prefs.js
update_daemon2: keep track of children PIDs
[tt-rss.git] / prefs.js
index c52ad446607e42114eea926d76bff40b42290b99..56de40ad3dee02512107264fc632f378f46c2b33 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 {   
@@ -48,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);
@@ -83,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() {
@@ -241,63 +251,6 @@ function infobox_feed_cat_callback() {
        }
 }
 
-function recat_onChange(elem) {
-       debug(elem);
-
-}
-
-function recat_onUpdate(ctr) {
-       debug(ctr);
-
-}
-
-function infobox_recategorize_callback() {
-       if (xmlhttp.readyState == 4) {
-               try {
-
-                       infobox_callback();
-
-                       var ctr = document.getElementById("prefFeedCatList2");
-
-                       if (ctr) {
-                               var elems = ctr.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);
-                                       }
-                               }
-
-                               elems = ctr.getElementsByTagName("UL");
-
-                               ctrs = new Array();
-                               ctr_ids = new Array();
-
-                               for (var i = 0; i < elems.length; i++) {
-                                       if (elems[i].id.match("FCNTR-")) {
-                                               ctrs.push(elems[i]);
-                                               ctr_ids.push(elems[i].id);
-                                       }
-                               }
-
-                               Position.includeScrollOffsets = true;
-
-                               for (var i = 0; i < ctrs.length; i++) {
-                                       Sortable.create(elems[i], { scroll: ctr, ghosting: false, 
-                                               containment: ctrs, dropOnEmpty: true, onChange: recat_onChange, onUpdate: recat_onUpdate });
-                               } 
-
-                       } 
-
-               } catch (e) {
-                       exception_error("infobox_recategorize_callback", e);
-               }
-       }
-}
-
 function updateFeedList(sort_key) {
 
        if (!xmlhttp_ready(xmlhttp)) {
@@ -305,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; }
@@ -336,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;
@@ -723,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)) {
@@ -843,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)) {
@@ -1223,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;
@@ -1241,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;
@@ -1258,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);
@@ -1296,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") {
@@ -1537,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");
@@ -1705,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();
@@ -1730,25 +1704,6 @@ function editFeedCats() {
        xmlhttp.send(null);
 }
 
-function recategorizeFeeds() {
-       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=categorizeDlg", true);
-       xmlhttp.onreadystatechange=infobox_recategorize_callback;
-       xmlhttp.send(null);
-}
-
 function showFeedsWithErrors() {
        displayDlg('feedUpdateErrors');
 }
@@ -1883,3 +1838,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;
+}
+
+