]> git.wh0rd.org - tt-rss.git/blobdiff - functions.js
help uses popup window, recolor infoBox, use subscribe dialog in prefs
[tt-rss.git] / functions.js
index 1172a49f71541e28e351949137079e36f54411b9..21a0da7992b7a3973b19f89d09d16959f87e4f6b 100644 (file)
@@ -7,6 +7,10 @@ function browser_has_opacity() {
                navigator.userAgent.match("Opera") != null;
 }
 
+function is_msie() {
+       return navigator.userAgent.match("MSIE");
+}
+
 function is_opera() {
        return navigator.userAgent.match("Opera");
 }
@@ -1145,7 +1149,7 @@ function getRelativeFeedId(list, id, direction, unread_only) {
                if (direction == "prev") {
                        for (i = list.childNodes.length-1; i >= 0; i--) {
                                var child = list.childNodes[i];                         
-                               if (child.id == "feedCatHolder") {
+                               if (child.id == "feedCatHolder" && child.className != "invisible") {
                                        if (child.firstChild) {
                                                var cr = getRelativeFeedId(child.firstChild, id, direction);
                                                if (cr) return cr;                                      
@@ -1154,7 +1158,7 @@ function getRelativeFeedId(list, id, direction, unread_only) {
                                
                                        if (getInitParam("hide_read_feeds") == 1) {
                                                if (child.className != "feed") {
-                                                       alert(child.className);
+//                                                     alert(child.className);
                                                        return child.id.replace('FEEDR-', '');                                          
                                                }                                                       
                                        } else {
@@ -1203,7 +1207,10 @@ function getRelativeFeedId(list, id, direction, unread_only) {
                                if (e) {
                                        if (!unread_only || (unread_only && e.className != "feed" &&
                                                        e.className.match("feed")))     {
-                                               return e.id.replace("FEEDR-", "");
+                                               if (e.parentNode.parentNode && e.parentNode.parentNode.className 
+                                                       != "invisible") {
+                                                       return e.id.replace("FEEDR-", "");
+                                               }
                                        }
                                }
                        }
@@ -1240,7 +1247,10 @@ function getRelativeFeedId(list, id, direction, unread_only) {
                                if (e) {
                                        if (!unread_only || (unread_only && e.className != "feed" && 
                                                        e.className.match("feed")))     {
-                                               return e.id.replace("FEEDR-", "");
+                                               if (e.parentNode.parentNode && e.parentNode.parentNode.className 
+                                                       != "invisible") {
+                                                       return e.id.replace("FEEDR-", "");
+                                               }
                                        }
                                }
                        }
@@ -1248,11 +1258,18 @@ function getRelativeFeedId(list, id, direction, unread_only) {
        }
 }
 
-function showBlockElement(id) {
+function showBlockElement(id, h_id) {
        var elem = document.getElementById(id);
 
        if (elem) {
                elem.style.display = "block";
+
+               if (h_id) {
+                       elem = document.getElementById(h_id);
+                       if (elem) {
+                               elem.style.display = "none";
+                       }
+               }
        } else {
                alert("[showBlockElement] can't find element with id " + id);
        } 
@@ -1372,6 +1389,22 @@ function infobox_callback() {
        }
 }
 
+function helpbox_callback() {
+       if (xmlhttp.readyState == 4) {
+               var box = document.getElementById('helpBox');
+               var shadow = document.getElementById('helpBoxShadow');
+               if (box) {                      
+                       box.innerHTML=xmlhttp.responseText;                     
+                       if (shadow) {
+                               shadow.style.display = "block";
+                       } else {
+                               box.style.display = "block";                            
+                       }
+               }
+               notify("");
+       }
+}
+
 function addFilter() {
 
        if (!xmlhttp_ready(xmlhttp)) {
@@ -1433,9 +1466,16 @@ function qaddFeed() {
        
        var query = Form.serialize("feed_add_form");
        
-       xmlhttp.open("GET", "backend.php?" + query, true);
+       debug("subscribe q: " + query);
+
+/*     xmlhttp.open("GET", "backend.php?" + query, true);
        xmlhttp.onreadystatechange=dlg_frefresh_callback;
-       xmlhttp.send(null);
+       xmlhttp.send(null); */
+
+       xmlhttp.open("POST", "backend.php", true);
+       xmlhttp.onreadystatechange=dlg_frefresh_callback;
+       xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
+       xmlhttp.send(query);
 
        return false;
 }
@@ -1502,71 +1542,14 @@ function debug(msg) {
 }
 
 function getInitParam(key) {
-       var c = getCookie("TTIP:" + key);
-       if (c) {
-               return c;
-       } else {
-               return getMainContext().init_params[key];
-       }
+       return init_params[key];
 }
 
 function storeInitParam(key, value) {
-       try {
-               init_params[key] = value;
-               debug("storeInitParam: " + key + " => " + value + 
-                       " (" + getInitParam("cookie_lifetime") + ")");
-               if (getInitParam("cookie_lifetime") > 0) {
-                       setCookie("TTIP:" + key, value, getInitParam("cookie_lifetime"));
-               } else {
-                       setCookie("TTIP:" + key, value);
-               }
-       } catch (e) {
-               exception_error("storeInitParam", e);
-       }
+       debug("<b>storeInitParam is OBSOLETE: " + key + " => " + value + "</b>");
+       init_params[key] = value;
 }
 
-
-/*
-function storeInitParam(key, value, is_client) {
-       try {
-               if (!is_client) {
-                       if (getMainContext().init_params[key] != value) {
-                               debug("storeInitParam: " + key + " => " + value);
-                               //new Ajax.Request("backend.php?op=rpc&subop=storeParam&key=" + 
-                               //      param_escape(key) + "&value=" + param_escape(value));   
-                               var f = getMainContext().document.getElementById("backReqBox");
-                               f.src = "backend.php?op=rpc&subop=storeParam&key=" + 
-                                       param_escape(key) + "&value=" + param_escape(value);
-                       }
-               }
-               getMainContext().init_params[key] = value;
-       } catch (e) {
-               exception_error("storeInitParam", e);
-       }
-} */
-
-/*
-function storeInitParams(params, is_client) {
-       try {
-               var s = "";
-
-               for (k in params) {
-                       if (getMainContext().init_params[k] != params[k]) {
-                               s += k + "=" + params[k] + ";";
-                               getMainContext().init_params[k] = params[k];
-                       }
-               } 
-
-               debug("storeInitParams: " + s);
-       
-               if (!is_client) {
-                       new Ajax.Request("backend.php?op=rpc&subop=storeParams&str=" + s);
-               }
-       } catch (e) {
-               exception_error("storeInitParams", e);
-       }
-}*/
-
 function fatalError(code, message) {
        try {