]> git.wh0rd.org - tt-rss.git/blobdiff - tt-rss.js
schema: support for audio enclosure in ttrss_entries
[tt-rss.git] / tt-rss.js
index c4cd2db74714b44e0a604bebb1162ae86a62f00c..5603c01cef3c6e7b7a3b6a65f699f15e6e559a06 100644 (file)
--- a/tt-rss.js
+++ b/tt-rss.js
@@ -1,16 +1,13 @@
 var xmlhttp = false;
-
 var total_unread = 0;
 var first_run = true;
-
 var display_tags = false;
-
 var global_unread = -1;
-
 var active_title_text = "";
-
 var current_subtitle = "";
 
+var _qfd_deleted_feed = 0;
+
 /*@cc_on @*/
 /*@if (@_jscript_version >= 5)
 // JScript gives us Conditional compilation, we can cope with old IE versions.
@@ -48,6 +45,12 @@ function dlg_frefresh_callback() {
        if (xmlhttp.readyState == 4) {
                notify(xmlhttp.responseText);
                updateFeedList(false, false);
+               if (_qfd_deleted_feed) {
+                       var hframe = document.getElementById("headlines-frame");
+                       if (hframe) {
+                               hframe.src = "backend.php?op=error&msg=No%20feed%20selected.";
+                       }
+               }
                closeDlg();
        } 
 }
@@ -69,6 +72,31 @@ function dlg_display_callback() {
        } 
 }
 
+function hide_unread_callback() {
+       if (xmlhttp.readyState == 4) {
+
+               try {
+
+                       var reply = xmlhttp.responseXML.firstChild.firstChild;
+                       var value = reply.getAttribute("value");
+                       var hide_read_feeds = (value != "false")
+                       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);
+                       } 
+
+               } catch (e) {
+                       exception_error("hide_unread_callback", e);
+               }
+
+       } 
+}
+
 function refetch_callback() {
        if (xmlhttp.readyState == 4) {
                try {
@@ -92,35 +120,8 @@ function refetch_callback() {
                        }
        
                        var f_document = window.frames["feeds-frame"].document;
-       
-                       for (var l = 0; l < reply.childNodes.length; l++) {
-                               var id = reply.childNodes[l].getAttribute("id");
-                               var ctr = reply.childNodes[l].getAttribute("counter");
-       
-                               var feedctr = f_document.getElementById("FEEDCTR-" + id);
-                               var feedu = f_document.getElementById("FEEDU-" + id);
-                               var feedr = f_document.getElementById("FEEDR-" + id);
-       
-                               if (id == "global-unread") {
-                                       global_unread = ctr;
-                                       continue;
-                               }
-       
-                               if (feedctr && feedu && feedr) {
-       
-                                       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", "");
-                                       }
-                               }
-                       }  
+
+                       parse_counters(reply, f_document, window);
        
                        updateTitle("");
                        notify("All feeds updated.");
@@ -164,7 +165,7 @@ function backend_sanity_check_callback() {
 
 function scheduleFeedUpdate(force) {
 
-       notify("Updating feeds in background...");
+       notify("Updating feeds, please wait.");
 
 //     document.title = "Tiny Tiny RSS - Updating...";
 
@@ -252,7 +253,7 @@ function viewfeed(feed, skip, subop) {
 
 function timeout() {
        scheduleFeedUpdate(false);
-       setTimeout("timeout()", 1800*1000);
+       setTimeout("timeout()", 900*1000);
 }
 
 function resetSearch() {
@@ -265,6 +266,7 @@ function resetSearch() {
 }
 
 function search() {
+       closeDlg();     
        viewCurrentFeed(0, "");
 }
 
@@ -388,24 +390,11 @@ function init_second_stage() {
                updateFeedList(false, false);
                document.onkeydown = hotkey_handler;
        
-               var content = document.getElementById("content");
-       
-               if (getCookie("ttrss_vf_vmode")) {
-                       var viewbox = document.getElementById("viewbox");
-                       viewbox.value = getCookie("ttrss_vf_vmode");
-               }
-       
-               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, '');
-       //      }
-       
-       //      setTimeout("timeout()", 2*1000);
-       //      scheduleFeedUpdate(true);
+               var viewbox = document.getElementById("viewbox");                       
+               var limitbox = document.getElementById("limitbox");
+
+               dropboxSelect(viewbox, getCookie("ttrss_vf_vmode"));
+               dropboxSelect(limitbox, getCookie("ttrss_vf_limit"));
        
        } catch (e) {
                exception_error("init_second_stage", e);
@@ -421,8 +410,8 @@ function quickMenuGo() {
                gotoPreferences();
        }
 
-       if (opid == "qmcAdvSearch") {
-               displayDlg("search");
+       if (opid == "qmcSearch") {
+               displayDlg("search", getActiveFeedId());
                return;
        }
 
@@ -480,13 +469,22 @@ function qafAdd() {
                notify("Missing feed URL.");
        } else {
                notify("Adding feed...");
+       
+               var cat = document.getElementById("qafCat");
+               var cat_id = "";
                
+               if (cat) {
+                       cat_id = cat[cat.selectedIndex].id;
+               } else {
+                       cat_id = 0;
+               }
+
                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&quiet=1&subop=add&link=" +
-                       param_escape(link.value), true);
+                       param_escape(link.value) + "&cid=" + param_escape(cat_id), true);
                xmlhttp.onreadystatechange=dlg_frefresh_callback;
                xmlhttp.send(null);
 
@@ -531,6 +529,11 @@ function qaddFilter() {
 
 function displayDlg(id, param) {
 
+       if (!xmlhttp_ready(xmlhttp)) {
+               printLockingError();
+               return
+       }
+
        notify("");
 
        xmlhttp.open("GET", "backend.php?op=dlg&id=" +
@@ -538,20 +541,29 @@ function displayDlg(id, param) {
        xmlhttp.onreadystatechange=dlg_display_callback;
        xmlhttp.send(null);
 
+       disableHotkeys();
 }
 
 function closeDlg() {
        var dlg = document.getElementById("userDlgShadow");
        dlg.style.display = "none";
+       enableHotkeys();
 }
 
 function qfdDelete(feed_id) {
 
        notify("Removing feed...");
 
+       if (!xmlhttp_ready(xmlhttp)) {
+               printLockingError();
+               return
+       }
+
 //     var feeds_doc = window.frames["feeds-frame"].document;
 //     feeds_doc.location.href = "backend.php?op=error&msg=Loading,%20please wait...";
 
+       _qfd_deleted_feed = feed_id;
+
        xmlhttp.open("GET", "backend.php?op=pref-feeds&quiet=1&subop=remove&ids=" + feed_id);
        xmlhttp.onreadystatechange=dlg_frefresh_callback;
        xmlhttp.send(null);
@@ -586,19 +598,26 @@ function updateFeedTitle(t) {
 }
 
 function toggleDispRead() {
-       var hide_read_feeds = (getCookie("ttrss_vf_hreadf") == 1);
+       try {
 
-       hide_read_feeds = !hide_read_feeds;
+               if (!xmlhttp_ready(xmlhttp)) {
+                       printLockingError();
+                       return
+               }
 
-       var feeds_doc = window.frames["feeds-frame"].document;
+               var hide_read_feeds = (getCookie("ttrss_vf_hreadf") == 1);
 
-       hideOrShowFeeds(feeds_doc, hide_read_feeds);
+               hide_read_feeds = !hide_read_feeds;
+       
+               var query = "backend.php?op=rpc&subop=setpref" +
+                       "&key=HIDE_READ_FEEDS&value=" + param_escape(hide_read_feeds);
 
-       if (hide_read_feeds) {
-               setCookie("ttrss_vf_hreadf", 1);
-       } else {
-               setCookie("ttrss_vf_hreadf", 0);
+               xmlhttp.open("GET", query);
+               xmlhttp.onreadystatechange=hide_unread_callback;
+               xmlhttp.send(null);
+               
+       } catch (e) {
+               exception_error("toggleDispRead", e);
        }
-
 }