]> git.wh0rd.org - tt-rss.git/blobdiff - tt-rss.js
toggle hide/display only unread feeds, All feeds: button ops changed into selector
[tt-rss.git] / tt-rss.js
index de262f91c5056138c6711adf60fe000cbe370d4a..0fb61a117526bee3b22094a74f47dd70c8724d54 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -4,25 +4,17 @@
 */
 
 var xmlhttp = false;
-var xmlhttp_rpc = false;
-var xmlhttp_view = false;
 
 var total_unread = 0;
 var first_run = true;
 
-var active_post_id = false;
-var active_feed_id = false;
-var active_offset = false;
-
-var total_feed_entries = false;
-
-var _viewfeed_autoselect_first = false;
-var _viewfeed_autoselect_last = false;
+var search_query = "";
+var search_mode = "";
 
-var _update_ids;
-var _update_num_ids;
+var display_tags = false;
+//var display_read_feeds = true;
 
-var search_query = "";
+var global_unread = 0;
 
 /*@cc_on @*/
 /*@if (@_jscript_version >= 5)
@@ -33,143 +25,123 @@ try {
 } catch (e) {
        try {
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
-               xmlhttp_rpc = new ActiveXObject("Microsoft.XMLHTTP");
-               xmlhttp_view = new ActiveXObject("Microsoft.XMLHTTP");
        } catch (E) {
                xmlhttp = false;
-               xmlhttp_rpc = false;
-               xmlhttp_view = false;
        }
 }
 @end @*/
 
 if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
        xmlhttp = new XMLHttpRequest();
-       xmlhttp_rpc = new XMLHttpRequest();
-       xmlhttp_view = new XMLHttpRequest();
 }
 
-function feedlist_callback() {
-       var container = document.getElementById('feeds');
-       if (xmlhttp.readyState == 4) {
-               container.innerHTML=xmlhttp.responseText;
+function toggleTags() {
+       display_tags = !display_tags;
 
-               if (first_run) {
-                       scheduleFeedUpdate(false);
-                       first_run = false;
-               } else {
-                       notify("");
-               } 
-       } 
-}
+       var p = document.getElementById("dispSwitchPrompt");
 
-function feed_update_callback() {
-       if (xmlhttp_rpc.readyState == 4) {
-               var result = xmlhttp_rpc.responseText;
-               notify(_update_ids);
-               updateFeed(_update_ids.shift());
+       if (display_tags) {
+               p.innerHTML = "display feeds";
+       } else {
+               p.innerHTML = "display tags";
        }
+       
+       updateFeedList();
 }
 
-function viewfeed_callback() {
-       var container = document.getElementById('headlines');
+function dlg_frefresh_callback() {
        if (xmlhttp.readyState == 4) {
-               container.innerHTML = xmlhttp.responseText;
-
-               var factive = document.getElementById("FACTIVE");
-               var funread = document.getElementById("FUNREAD");
-               var ftotal = document.getElementById("FTOTAL");
+               updateFeedList(false, false);
+               closeDlg();
+       } 
+}
 
-               if (_viewfeed_autoselect_first == true) {
-                       _viewfeed_autoselect_first = false;
-                       view(getFirstVisibleHeadlineId(), active_feed_id);
-               }
+function dialog_refresh_callback() {
+       if (xmlhttp.readyState == 4) {
+               var dlg = document.getElementById("userDlg");
 
-               if (_viewfeed_autoselect_last == true) {
-                       _viewfeed_autoselect_last = false;
-                       view(getLastVisibleHeadlineId(), active_feed_id);
-               }
+               dlg.innerHTML = xmlhttp.responseText;
+               dlg.style.display = "block";
+       } 
+}
 
-               if (ftotal && factive && funread) {
-                       var feed_id = factive.innerHTML;
+function refetch_callback() {
+       if (xmlhttp.readyState == 4) {
 
-                       var feedr = document.getElementById("FEEDR-" + feed_id);
-                       var feedt = document.getElementById("FEEDT-" + feed_id);
-                       var feedu = document.getElementById("FEEDU-" + feed_id);
+//             document.title = "Tiny Tiny RSS";
 
-                       feedt.innerHTML = ftotal.innerHTML;
-                       feedu.innerHTML = funread.innerHTML;
+               if (!xmlhttp.responseXML) {
+                       notify("refetch_callback: backend did not return valid XML");
+                       return;
+               }
 
-                       total_feed_entries = ftotal.innerHTML;  
+               var reply = xmlhttp.responseXML.firstChild;
 
-                       if (feedu.innerHTML > 0 && !feedr.className.match("Unread")) {
-                                       feedr.className = feedr.className + "Unread";
-                       } else if (feedu.innerHTML <= 0) {      
-                                       feedr.className = feedr.className.replace("Unread", "");
-                       }
+               if (!reply) {
+                       notify("refetch_callback: backend did not return expected XML object");
+                       return;
+               } 
 
-                       cleanSelected("feedsList");
+               var f_document = window.frames["feeds-frame"].document;
 
-                       feedr.className = feedr.className + "Selected";
-               }
+               for (var l = 0; l < reply.childNodes.length; l++) {
+                       var id = reply.childNodes[l].getAttribute("id");
+                       var ctr = reply.childNodes[l].getAttribute("counter");
 
-               var searchbox = document.getElementById("searchbox");
-               searchbox.value = search_query;
+                       var feedctr = f_document.getElementById("FEEDCTR-" + id);
+                       var feedu = f_document.getElementById("FEEDU-" + id);
+                       var feedr = f_document.getElementById("FEEDR-" + id);
 
-               markHeadline(active_post_id);
+/*                     TODO figure out how to update this from viewfeed.js->view()
+                       disabled for now...
 
-               notify("");
+                       if (id == "global-unread") {
+                               global_unread = ctr;
+                       } */
 
-       }       
-}
+                       if (feedctr && feedu && feedr) {
 
-function view_callback() {
-       var container = document.getElementById('content');
-       if (xmlhttp_view.readyState == 4) {
-               container.innerHTML=xmlhttp_view.responseText;          
-               markHeadline(active_post_id);
-       }
-}
+                               feedu.innerHTML = ctr;
+       
+                               if (ctr > 0) {
+                                       feedctr.className = "odd";
+                                       if (!feedr.className.match("Unread")) {
+                                               feedr.className = feedr.className + "Unread";
+                                       }
+                               } else {
+                                       feedctr.className = "invisible";
+                                       feedr.className = feedr.className.replace("Unread", "");
+                               }
+                       }
+               }  
 
-function refetch_callback() {
+               updateTitle("");
+               notify("All feeds updated.");
 
-       if (xmlhttp_rpc.readyState == 4) {
-               notify("All feeds updated");
-               var container = document.getElementById('feeds');
-               container.innerHTML = xmlhttp_rpc.responseText;
-               document.title = "Tiny Tiny RSS";
-       } 
+       }
 }
 
 function updateFeed(feed_id) {
 
        var query_str = "backend.php?op=rpc&subop=updateFeed&feed=" + feed_id;
 
-       if (xmlhttp_ready(xmlhttp_rpc)) {
-               xmlhttp_rpc.open("GET", query_str, true);
-               xmlhttp_rpc.onreadystatechange=feed_update_callback;
-               xmlhttp_rpc.send(null);
+       if (xmlhttp_ready(xmlhttp)) {
+               xmlhttp.open("GET", query_str, true);
+               xmlhttp.onreadystatechange=feed_update_callback;
+               xmlhttp.send(null);
        } else {
                printLockingError();
        }   
 
 }
 
-function scheduleSepFeedUpdate(force) {
-       notify("Updating feeds in background (M2)...");
-
-       _update_ids = getFeedIds();
-       _update_num_ids = _update_ids.length;
-
-       updateFeed(_update_ids.pop());
-
-}
-
 function scheduleFeedUpdate(force) {
 
        notify("Updating feeds in background...");
 
-       document.title = "Tiny Tiny RSS - Updating...";
+//     document.title = "Tiny Tiny RSS - Updating...";
+
+       updateTitle("Updating...");
 
        var query_str = "backend.php?op=rpc&subop=";
 
@@ -179,113 +151,77 @@ function scheduleFeedUpdate(force) {
                query_str = query_str + "updateAllFeeds";
        }
 
-       if (xmlhttp_ready(xmlhttp_rpc)) {
-               xmlhttp_rpc.open("GET", query_str, true);
-               xmlhttp_rpc.onreadystatechange=refetch_callback;
-               xmlhttp_rpc.send(null);
-       } else {
-               printLockingError();
-       }   
-}
-
-function updateFeedList(silent, fetch) {
+       var omode;
 
-       if (silent != true) {
-               notify("Loading feed list...");
+       if (display_tags) {
+               omode = "t";
+       } else {
+               omode = "fl";
        }
 
-       var query_str = "backend.php?op=feeds";
-
-       if (fetch) query_str = query_str + "&fetch=yes";
+       query_str = query_str + "&omode=" + omode;
 
        if (xmlhttp_ready(xmlhttp)) {
                xmlhttp.open("GET", query_str, true);
-               xmlhttp.onreadystatechange=feedlist_callback;
+               xmlhttp.onreadystatechange=refetch_callback;
                xmlhttp.send(null);
        } else {
                printLockingError();
-       }
+       }   
 }
 
-function catchupPage(feed) {
-
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
-
-       var content = document.getElementById("headlinesList");
+function updateFeedList(silent, fetch) {
 
-       var rows = new Array();
+//     if (silent != true) {
+//             notify("Loading feed list...");
+//     }
 
-       for (i = 0; i < content.rows.length; i++) {
-               var row_id = content.rows[i].id.replace("RROW-", "");
-               if (row_id.length > 0) {
-                       if (content.rows[i].className.match("Unread")) {
-                               rows.push(row_id);      
-                               content.rows[i].className = content.rows[i].className.replace("Unread", "");
-                       }
+       var query_str = "backend.php?op=feeds";
 
-                       var upd_img_pic = document.getElementById("FUPDPIC-" + row_id);
-                       if (upd_img_pic) {
-                               upd_img_pic.innerHTML = "";
-                       } 
-               }
+       if (display_tags) {
+               query_str = query_str + "&tags=1";
        }
 
-       if (rows.length > 0) {
-
-               var feedr = document.getElementById("FEEDR-" + feed);
-               var feedu = document.getElementById("FEEDU-" + feed);
-       
-               feedu.innerHTML = feedu.innerHTML - rows.length;
-       
-               if (feedu.innerHTML > 0 && !feedr.className.match("Unread")) {
-                               feedr.className = feedr.className + "Unread";
-               } else if (feedu.innerHTML <= 0) {      
-                               feedr.className = feedr.className.replace("Unread", "");
-               } 
-
-               var query_str = "backend.php?op=rpc&subop=catchupPage&ids=" + 
-                       param_escape(rows.toString());
-       
-               notify("Marking this page as read...");
-
-               var button = document.getElementById("btnCatchupPage");
+       if (getActiveFeedId()) {
+               query_str = query_str + "&actid=" + getActiveFeedId();
+       }
 
-               if (button) {
-                       button.className = "disabledButton";
-                       button.href = "";
-               }
-       
-               xmlhttp.open("GET", query_str, true);
-               xmlhttp.onreadystatechange=notify_callback;
-               xmlhttp.send(null);
+       if (fetch) query_str = query_str + "&fetch=yes";
 
-       } else {
-               notify("No unread items on this page.");
+       var feeds_frame = document.getElementById("feeds-frame");
 
-       }
+       feeds_frame.src = query_str;
 }
 
 function catchupAllFeeds() {
 
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
        var query_str = "backend.php?op=feeds&subop=catchupAll";
 
        notify("Marking all feeds as read...");
 
-       xmlhttp.open("GET", query_str, true);
-       xmlhttp.onreadystatechange=feedlist_callback;
-       xmlhttp.send(null);
+       var feeds_frame = document.getElementById("feeds-frame");
+
+       feeds_frame.src = query_str;
+
+       global_unread = 0;
+       updateTitle();
+
+}
+
+function viewCurrentFeed(skip, subop) {
 
+       if (getActiveFeedId()) {
+               viewfeed(getActiveFeedId(), skip, subop);
+       } else {
+               disableContainerChildren("headlinesToolbar", false, document);
+               viewfeed(-1, skip, subop); // FIXME
+       }
 }
 
 function viewfeed(feed, skip, subop) {
 
+//     notify("Loading headlines...");
+
        enableHotkeys();
 
        var searchbox = document.getElementById("searchbox");
@@ -296,157 +232,106 @@ function viewfeed(feed, skip, subop) {
                search_query = "";
        } 
 
+       var searchmodebox = document.getElementById("searchmodebox");
+
+       if (searchmodebox) {
+               search_mode = searchmodebox.value;
+       } else {
+               search_mode = "";
+       }
+
+       setCookie("ttrss_vf_smode", search_mode);
+
        var viewbox = document.getElementById("viewbox");
 
        var view_mode;
 
        if (viewbox) {
-               view_mode = viewbox.value;
+               view_mode = viewbox[viewbox.selectedIndex].text;
        } else {
                view_mode = "All Posts";
        }
 
-/*     if (active_feed_id == feed && subop != "ForceUpdate") {
-               notify("This feed is currently selected.");
-               return;
-       } */
-
-       if (skip < 0 || skip > total_feed_entries) {
-               return;
-       }
-
-       if (!xmlhttp_ready(xmlhttp)) {
-               printLockingError();
-               return
-       }
+       setCookie("ttrss_vf_vmode", view_mode);
 
-       if (active_feed_id != feed || skip != active_offset) {
-               active_post_id = false;
-       }
-
-       active_feed_id = feed;
-       active_offset = skip;
+       var limitbox = document.getElementById("limitbox");
 
-       var query = "backend.php?op=viewfeed&feed=" + param_escape(feed) +
-               "&skip=" + param_escape(skip) + "&subop=" + param_escape(subop) +
-               "&view=" + param_escape(view_mode);
+       var limit;
 
-       if (search_query != "") {
-               query = query + "&search=" + param_escape(search_query);
+       if (limitbox) {
+               limit = limitbox[limitbox.selectedIndex].text;
+               setCookie("ttrss_vf_limit", limit);
+       } else {
+               limit = "All";
        }
-       
-       xmlhttp.open("GET", query, true);
-       xmlhttp.onreadystatechange=viewfeed_callback;
-       xmlhttp.send(null);
 
-       notify("Loading headlines...");
+       setActiveFeedId(feed);
 
-}
+       var f_doc = frames["feeds-frame"].document;
 
-function markHeadline(id) {
-       var row = document.getElementById("RROW-" + id);
-       if (row) {
-               row.className = row.className + "Selected";
-       }
-}
+//     f_doc.getElementById("ACTFEEDID").innerHTML = feed;
 
-function getFeedIds() {
-       var content = document.getElementById("feedsList");
+       if (subop == "MarkAllRead") {
 
-       var rows = new Array();
+               var feedr = f_doc.getElementById("FEEDR-" + feed);
+               var feedctr = f_doc.getElementById("FEEDCTR-" + feed);
+               
+               feedctr.className = "invisible";
 
-       for (i = 0; i < content.rows.length; i++) {
-               var id = content.rows[i].id.replace("FEEDR-", "");
-               if (id.length > 0) {
-                       rows.push(id);
+               if (feedr.className.match("Unread")) {
+                       feedr.className = feedr.className.replace("Unread", "");
                }
        }
 
-       return rows;
-}
-
-function cleanSelected(element) {
-       var content = document.getElementById(element);
-
-       var rows = new Array();
+       var query = "backend.php?op=viewfeed&feed=" + param_escape(feed) +
+               "&skip=" + param_escape(skip) + "&subop=" + param_escape(subop) +
+               "&view=" + param_escape(view_mode) + "&limit=" + limit + 
+               "&smode=" + param_escape(search_mode);
 
-       for (i = 0; i < content.rows.length; i++) {
-               content.rows[i].className = content.rows[i].className.replace("Selected", "");
+       if (search_query != "") {
+               query = query + "&search=" + param_escape(search_query);
        }
+       
+       var headlines_frame = parent.frames["headlines-frame"];
 
-}
-
-function view(id,feed_id) {
-
-       enableHotkeys();
+       headlines_frame.location.href = query + "&addheader=true";
 
-       if (!xmlhttp_ready(xmlhttp_view)) {
-               printLockingError();
-               return
+       cleanSelected("feedsList");
+       var feedr = document.getElementById("FEEDR-" + feed);
+       if (feedr) {
+               feedr.className = feedr.className + "Selected";
        }
+       
+       disableContainerChildren("headlinesToolbar", false, doc);
 
-       var crow = document.getElementById("RROW-" + id);
-
-       if (crow.className.match("Unread")) {
-               var umark = document.getElementById("FEEDU-" + feed_id);
-               umark.innerHTML = umark.innerHTML - 1;
-               crow.className = crow.className.replace("Unread", "");
-
-               if (umark.innerHTML == "0") {
-                       var feedr = document.getElementById("FEEDR-" + feed_id);
-                       feedr.className = feedr.className.replace("Unread", "");
-               }
-
-               total_unread--;
-       }       
-
-       cleanSelected("headlinesList");
-//     crow.className = crow.className + "Selected";
-
-       var upd_img_pic = document.getElementById("FUPDPIC-" + id);
-
-       if (upd_img_pic) {
-               upd_img_pic.innerHTML = "";
-       } 
-
-//     document.getElementById('content').innerHTML='Loading, please wait...';         
-
-       var unread_rows = getVisibleUnreadHeadlines();
+       var btnMarkAsRead = document.getElementById("btnMarkFeedAsRead");
 
-       if (unread_rows.length == 0) {
-               var button = document.getElementById("btnCatchupPage");
-               if (button) {
-                       button.className = "disabledButton";
-                       button.href = "";
-               }
+       if (btnMarkAsRead && !isNumeric(feed)) {
+               btnMarkAsRead.disabled = true;
+               btnMarkAsRead.className = "disabledButton";
        }
 
-       active_post_id = id;
-
-       var content = document.getElementById("content-frame");
+//     notify("");
 
-       if (content) {
-               content.src = "backend.php?op=view&addheader=true&id=" + param_escape(id);
-               markHeadline(active_post_id);
-       } else {
-               xmlhttp_view.open("GET", "backend.php?op=view&id=" + param_escape(id), true);
-               xmlhttp_view.onreadystatechange=view_callback;
-               xmlhttp_view.send(null);
-       }
 }
 
+
 function timeout() {
        scheduleFeedUpdate(true);
        setTimeout("timeout()", 1800*1000);
 }
 
 function resetSearch() {
-       document.getElementById("searchbox").value = "";
-       viewfeed(active_feed_id, 0, "");
+       var searchbox = document.getElementById("searchbox")
+
+       if (searchbox.value != "" && getActiveFeedId()) {       
+               searchbox.value = "";
+               viewfeed(getActiveFeedId(), 0, "");
+       }
 }
 
-function search(feed) {
-       viewfeed(feed, 0, "");
+function search() {
+       viewCurrentFeed(0, "");
 }
 
 function localPiggieFunction(enable) {
@@ -462,164 +347,220 @@ function localPiggieFunction(enable) {
        }
 }
 
-function relativeid_callback() {
+function localHotkeyHandler(keycode) {
 
-       if (xmlhttp_rpc.readyState == 4) {
-               notify(xmlhttp_rpc.responseText);
+/*     if (keycode == 78) {
+               return moveToPost('next');
        }
 
-}
+       if (keycode == 80) {
+               return moveToPost('prev');
+       } */
 
-function getVisibleUnreadHeadlines() {
-       var content = document.getElementById("headlinesList");
+       if (keycode == 82) {
+               return scheduleFeedUpdate(true);
+       }
 
-       var rows = new Array();
+       if (keycode == 85) {
+               return viewfeed(getActiveFeedId(), 0, "ForceUpdate");
+       }
 
-       for (i = 0; i < content.rows.length; i++) {
-               var row_id = content.rows[i].id.replace("RROW-", "");
-               if (row_id.length > 0 && content.rows[i].className.match("Unread")) {
-                               rows.push(row_id);      
-               }
+//     notify("KC: " + keycode);
+
+}
+
+function updateTitle(s) {
+       var tmp = "Tiny Tiny RSS";
+       
+       if (global_unread > 0) {
+               tmp = tmp + " (" + global_unread + ")";
        }
-       return rows;
+
+       if (s) {
+               tmp = tmp + " - " + s;
+       }
+       document.title = tmp;
 }
 
-function getVisibleHeadlineIds() {
+function genericSanityCheck() {
 
-       var content = document.getElementById("headlinesList");
+       if (!xmlhttp) {
+               document.getElementById("headlines").innerHTML = 
+                       "<b>Fatal error:</b> This program requires XmlHttpRequest " + 
+                       "to function properly. Your browser doesn't seem to support it.";
+               return false;
+       }
 
-       var rows = new Array();
+       setCookie("ttrss_vf_test", "TEST");
+       if (getCookie("ttrss_vf_test") != "TEST") {
 
-       for (i = 0; i < content.rows.length; i++) {
-               var row_id = content.rows[i].id.replace("RROW-", "");
-               if (row_id.length > 0) {
-                               rows.push(row_id);      
-               }
+               document.getElementById("headlines").innerHTML = 
+                       "<b>Fatal error:</b> This program requires cookies " + 
+                       "to function properly. Your browser doesn't seem to support them.";
+
+               return false;
        }
-       return rows;
-}
 
-function getFirstVisibleHeadlineId() {
-       var rows = getVisibleHeadlineIds();
-       return rows[0];
+       return true;
 }
 
-function getLastVisibleHeadlineId() {
-       var rows = getVisibleHeadlineIds();
-       return rows[rows.length-1];
-}
+function init() {
 
-function moveToPost(mode) {
+       disableContainerChildren("headlinesToolbar", true);
 
-       var rows = getVisibleHeadlineIds();
+       if (!genericSanityCheck()) 
+               return;
 
-       var prev_id;
-       var next_id;
+       setCookie("ttrss_vf_actfeed", "");
 
-       if (active_post_id == false) {
-               next_id = getFirstVisibleHeadlineId();
-               prev_id = getLastVisibleHeadlineId();
-       } else {        
-               for (var i = 0; i < rows.length; i++) {
-                       if (rows[i] == active_post_id) {
-                               prev_id = rows[i-1];
-                               next_id = rows[i+1];                    
-                       }
-               }
-       }
+       updateFeedList(false, false);
+       document.onkeydown = hotkey_handler;
 
-       if (mode == "next") {
-               if (next_id != undefined) {
-                       view(next_id, active_feed_id);
-               } else {
-                       _viewfeed_autoselect_first = true;
-                       viewfeed(active_feed_id, active_offset+15);
-               }
+       setTimeout("timeout()", 1800*1000);
+       scheduleFeedUpdate(true);
+
+       var content = document.getElementById("content");
+
+       if (getCookie("ttrss_vf_vmode")) {
+               var viewbox = document.getElementById("viewbox");
+               viewbox.value = getCookie("ttrss_vf_vmode");
        }
 
-       if (mode == "prev") {
-               if ( prev_id != undefined) {
-                       view(prev_id, active_feed_id);
-               } else {
-                       _viewfeed_autoselect_last = true;
-                       viewfeed(active_feed_id, active_offset-15);
-               }
+       if (getCookie("ttrss_vf_limit")) {
+               var limitbox = document.getElementById("limitbox");
+               limitbox.value = getCookie("ttrss_vf_limit");
        }
 
+//     if (getCookie("ttrss_vf_actfeed")) {
+//             viewfeed(getCookie("ttrss_vf_actfeed"), 0, '');
+//     }
+
 }
 
-function localHotkeyHandler(keycode) {
+function quickMenuGo() {
+       var chooser = document.getElementById("quickMenuChooser");
 
-       if (keycode == 78) {
-               return moveToPost('next');
-       }
+       var opname = chooser[chooser.selectedIndex].text;
 
-       if (keycode == 80) {
-               return moveToPost('prev');
+       if (opname == "Preferences") {
+               gotoPreferences();
        }
 
-       if (keycode == 82) {
-               return scheduleFeedUpdate(true);
+       if (opname == "Extended search") {
+               displayDlg("search");
+               return;
        }
 
-       if (keycode == 85) {
-               return viewfeed(active_feed_id, active_offset, "ForceUpdate");
+       if (opname.match("Add new feed")) {
+               displayDlg("quickAddFeed");
+               return;
        }
 
-//     notify("KC: " + keycode);
+       if (opname.match("Remove this feed")) {
+               var actid = getActiveFeedId();
 
+               if (!actid) {
+                       notify("Please select some feed first.");
+                       return;
+               }
+       
+               displayDlg("quickDelFeed", actid);
+               return;
+       }
 }
 
-function toggleMark(id, toggle) {
-
-//     notify("Toggle mark: " + id + ", " + toggle);
+function qafAdd() {
 
-       if (!xmlhttp_ready(xmlhttp_rpc)) {
+       if (!xmlhttp_ready(xmlhttp)) {
                printLockingError();
-               return;
+               return
        }
 
-       var mark_img = document.getElementById("FMARKPIC-" + id);
-
-       var query = "backend.php?op=rpc&id=" + id + "&subop=mark";
+       var link = document.getElementById("qafInput");
 
-       if (toggle == true) {
-               mark_img.src = "images/mark_set.png";
-               mark_img.alt = "Reset mark";
-               mark_img.setAttribute('onclick', 'javascript:toggleMark('+id+', false)');
-               query = query + "&mark=1";
+       if (link.value.length == 0) {
+               notify("Missing feed URL.");
        } else {
-               mark_img.src = "images/mark_unset.png";
-               mark_img.alt = "Set mark";
-               mark_img.setAttribute('onclick', 'javascript:toggleMark('+id+', true)');
-               query = query + "&mark=0";
+               notify("Adding feed...");
+               
+               var feeds_doc = window.frames["feeds-frame"].document;
+
+               feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
+
+               xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=add&link=" +
+                       param_escape(link.value), true);
+               xmlhttp.onreadystatechange=dlg_frefresh_callback;
+               xmlhttp.send(null);
+
+               link.value = "";
+
        }
+}
 
-       xmlhttp_rpc.open("GET", query, true);
-       xmlhttp_rpc.onreadystatechange=rpc_notify_callback;
-       xmlhttp_rpc.send(null);
+function displayDlg(id, param) {
+
+       notify("");
+
+       xmlhttp.open("GET", "backend.php?op=dlg&id=" +
+               param_escape(id) + "&param=" + param_escape(param), true);
+       xmlhttp.onreadystatechange=dialog_refresh_callback;
+       xmlhttp.send(null);
 
 }
 
-function init() {
+function closeDlg() {
+       var dlg = document.getElementById("userDlg");
+       dlg.style.display = "none";
+}
+
+function qfdDelete(feed_id) {
+
+       notify("Removing feed...");
+
+       var feeds_doc = window.frames["feeds-frame"].document;
+       feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
 
-       // IE kludge
+       xmlhttp.open("GET", "backend.php?op=pref-feeds&subop=remove&ids=" + feed_id);
+       xmlhttp.onreadystatechange=dlg_frefresh_callback;
+       xmlhttp.send(null);
+}
+
+
+function allFeedsMenuGo() {
+       var chooser = document.getElementById("allFeedsChooser");
 
-       if (xmlhttp && !xmlhttp_rpc) {
-               xmlhttp_rpc = xmlhttp;
-               xmlhttp_view = xmlhttp;
+       var opname = chooser[chooser.selectedIndex].text;
+
+       if (opname == "Update") {
+               scheduleFeedUpdate(true);
+               return;
        }
 
-       if (!xmlhttp || !xmlhttp_rpc || !xmlhttp_view) {
-               document.getElementById("headlines").innerHTML = 
-                       "<b>Fatal error:</b> This program needs XmlHttpRequest " + 
-                       "to function properly. Your browser doesn't seem to support it.";
+       if (opname == "Mark as read") {
+               catchupAllFeeds();
                return;
        }
 
-       updateFeedList(false, false);
-       document.onkeydown = hotkey_handler;
-       setTimeout("timeout()", 1800*1000);
+       if (opname == "Toggle display read") {
+               toggleDispRead();
+               return;
+       }
+
+}
+
+function toggleDispRead() {
+       var hide_read_feeds = (getCookie("ttrss_vf_hreadf") == 1);
+
+       hide_read_feeds = !hide_read_feeds;
+
+       var feeds_doc = window.frames["feeds-frame"].document;
+
+       hideOrShowFeeds(feeds_doc, hide_read_feeds);
+
+       if (hide_read_feeds) {
+               setCookie("ttrss_vf_hreadf", 1);
+       } else {
+               setCookie("ttrss_vf_hreadf", 0);
+       }
 
-       var content = document.getElementById("content");
 }