]> git.wh0rd.org - tt-rss.git/blobdiff - functions.js
do not allow offline browsing when DB is empty
[tt-rss.git] / functions.js
index 6827420c6b0a2da7bce37a846ff6cc075caaa73f..837a6b42f35e7ae8d248f5cb9e547226f8de0562 100644 (file)
@@ -1,5 +1,4 @@
 var hotkeys_enabled = true;
-var xmlhttp_rpc = Ajax.getTransport();
 var notify_silent = false;
 var last_progress_point = 0;
 var async_counters_work = false;
@@ -83,10 +82,6 @@ function enableHotkeys() {
        hotkeys_enabled = true;
 }
 
-function xmlhttp_ready(obj) {
-       return obj.readyState == 4 || obj.readyState == 0 || !obj.readyState;
-}
-
 function open_article_callback(transport) {
        try {
 
@@ -583,6 +578,12 @@ function parse_counters(reply, scheduled_call) {
                                debug("Subscribed feed number changed, refreshing feedlist");
                                setTimeout('updateFeedList(false, false)', 50);
                        }
+               } else {
+/*                     var fl = document.getElementById("feeds-frame").innerHTML;
+                       if (fl) {
+                               cache_invalidate("FEEDLIST");
+                               cache_inject("FEEDLIST", fl, getInitParam("num_feeds"));
+                       } */
                }
 
        } catch (e) {
@@ -626,6 +627,8 @@ function parse_counters_reply(transport, scheduled_call) {
 function all_counters_callback2(transport, async_call) {
        try {
                if (async_call) async_counters_work = true;
+               
+               if (offline_mode) return;
 
                debug("<b>all_counters_callback2 IN: " + transport + "</b>");
                parse_counters_reply(transport);
@@ -853,25 +856,28 @@ function hideOrShowFeedsCategory(id, hide) {
                }       
        
        //      debug("end cat: " + node.id + " unread " + cat_unread);
-       
-               if (cat_unread == 0) {
-                       if (cat_node.style == undefined) {
-                               debug("ERROR: supplied cat_node " + cat_node + 
-                                       " has no styles. WTF?");
-                               return;
-                       }
-                       if (hide) {
-                               //cat_node.style.display = "none";
-                               Effect.Fade(cat_node, {duration : 0.3, 
-                                       queue: { position: 'end', scope: 'CFADE-' + node.id, limit: 1 }});
+
+               if (cat_node) {
+
+                       if (cat_unread == 0) {
+                               if (cat_node.style == undefined) {
+                                       debug("ERROR: supplied cat_node " + cat_node + 
+                                               " has no styles. WTF?");
+                                       return;
+                               }
+                               if (hide) {
+                                       //cat_node.style.display = "none";
+                                       Effect.Fade(cat_node, {duration : 0.3, 
+                                               queue: { position: 'end', scope: 'CFADE-' + node.id, limit: 1 }});
+                               } else {
+                                       cat_node.style.display = "list-item";
+                               }
                        } else {
-                               cat_node.style.display = "list-item";
-                       }
-               } else {
-                       try {
-                               cat_node.style.display = "list-item";
-                       } catch (e) {
-                               debug(e);
+                               try {
+                                       cat_node.style.display = "list-item";
+                               } catch (e) {
+                                       debug(e);
+                               }
                        }
                }
 
@@ -2108,3 +2114,13 @@ function transport_error_check(transport) {
        return true;
 }
 
+function strip_tags(s) {
+       return s.replace(/<\/?[^>]+(>|$)/g, "");
+}
+
+function truncate_string(s, length) {
+       if (!length) length = 30;
+       var tmp = s.substring(0, length);
+       if (s.length > length) tmp += "&hellip;";
+       return tmp;
+}