]> git.wh0rd.org - tt-rss.git/blobdiff - functions.js
loading progress bar for main window
[tt-rss.git] / functions.js
index e309c5e70ccd270ea27a4a05bfc5428e060e89f0..c37a7812c60e87c284ca09911370be31b0335e76 100644 (file)
@@ -1,7 +1,7 @@
 var hotkeys_enabled = true;
 var debug_mode_enabled = false;
 var xmlhttp_rpc = Ajax.getTransport();
-var hotkey_zone = 0;
+var notify_silent = false;
 
 /* add method to remove element from array */
 
@@ -75,10 +75,13 @@ function open_article_callback(transport) {
 
                        debug("open_article_callback, received link: " + link);
 
-                       if (link) {
-                               debug("link url: " + link.firstChild.nodeValue);
+                       if (link && id) {
 
-                               var w = window.open(link.firstChild.nodeValue, "_blank");
+                               var wname = "ttrss_article_" + id.firstChild.nodeValue;
+
+                               debug("link url: " + link.firstChild.nodeValue + ", wname " + wname);
+
+                               var w = window.open(link.firstChild.nodeValue, wname);
 
                                if (!w) { notify_error("Failed to load article in new window"); }
 
@@ -132,8 +135,17 @@ function hide_notify() {
        }
 } 
 
+function notify_silent_next() {
+       notify_silent = true;
+}
+
 function notify_real(msg, no_hide, n_type) {
 
+       if (notify_silent) {
+               notify_silent = false;
+               return;
+       }
+
        var n = document.getElementById("notify");
        var nb = document.getElementById("notify_body");
 
@@ -1191,7 +1203,7 @@ function infobox_submit_callback2(transport) {
 
        try {
                // called from prefs, reload tab
-               if (active_tab) {
+               if (typeof active_tab != 'undefined' && active_tab) {
                        selectTab(active_tab, false);
                }
        } catch (e) { }
@@ -1247,25 +1259,33 @@ function infobox_callback2(transport) {
 
 function createFilter() {
 
-       var form = document.forms['filter_add_form'];
-       var reg_exp = form.reg_exp.value;
-
-       if (reg_exp == "") {
-               alert(__("Can't add filter: nothing to match on."));
-               return false;
-       }
-
-       var query = Form.serialize("filter_add_form");
-
-       // we can be called from some other tab in Prefs
-       if (active_tab) active_tab = "filterConfig";
+       try {
 
-       new Ajax.Request("backend.php?" + query, {
-               onComplete: function (transport) {
-                       infobox_submit_callback2(transport);
-               } });
+               var form = document.forms['filter_add_form'];
+               var reg_exp = form.reg_exp.value;
        
-       return true;
+               if (reg_exp == "") {
+                       alert(__("Can't add filter: nothing to match on."));
+                       return false;
+               }
+       
+               var query = Form.serialize("filter_add_form");
+       
+               // we can be called from some other tab in Prefs                
+               if (typeof active_tab != 'undefined' && active_tab) {
+                       active_tab = "filterConfig";
+               }
+       
+               new Ajax.Request("backend.php?" + query, {
+                       onComplete: function (transport) {
+                               infobox_submit_callback2(transport);
+                       } });
+               
+               return true;
+
+       } catch (e) {
+               exception_error("createFilter", e);
+       }
 }
 
 function toggleSubmitNotEmpty(e, submit_id) {
@@ -1457,7 +1477,7 @@ function filterDlgCheckAction(sender) {
                }
 
        } catch (e) {
-               exception_error(e, "filterDlgCheckAction");
+               exception_error("filterDlgCheckAction", e);
        }
 
 }
@@ -1467,9 +1487,11 @@ function explainError(code) {
 }
 
 // this only searches loaded headlines list, not in CDM
-function getRelativePostIds(id) {
+function getRelativePostIds(id, limit) {
 
-       debug("getRelativePostIds: " + id);
+       if (!limit) limit = 3;
+
+       debug("getRelativePostIds: " + id + " limit=" + limit);
 
        var ids = new Array();
        var container = document.getElementById("headlinesList");
@@ -1481,13 +1503,23 @@ function getRelativePostIds(id) {
                        var r_id = rows[i].id.replace("RROW-", "");
 
                        if (r_id == id) {
-                               if (i > 0) ids.push(rows[i-1].id.replace("RROW-", ""));
+/*                             if (i > 0) ids.push(rows[i-1].id.replace("RROW-", ""));
                                if (i > 1) ids.push(rows[i-2].id.replace("RROW-", ""));
                                if (i > 2) ids.push(rows[i-3].id.replace("RROW-", ""));
 
                                if (i < rows.length-1) ids.push(rows[i+1].id.replace("RROW-", ""));
                                if (i < rows.length-2) ids.push(rows[i+2].id.replace("RROW-", ""));
-                               if (i < rows.length-3) ids.push(rows[i+3].id.replace("RROW-", ""));
+                               if (i < rows.length-3) ids.push(rows[i+3].id.replace("RROW-", "")); */
+
+                               for (var k = 1; k <= limit; k++) {
+                                       var nid = false;
+
+                                       if (i > k-1) var nid = rows[i-k].id.replace("RROW-", "");
+                                       if (nid) ids.push(nid);
+
+                                       if (i < rows.length-k) nid = rows[i+k].id.replace("RROW-", "");
+                                       if (nid) ids.push(nid);
+                               }
 
                                return ids;
                        }
@@ -1502,8 +1534,13 @@ function openArticleInNewWindow(id) {
                debug("openArticleInNewWindow: " + id);
 
                var query = "backend.php?op=rpc&subop=getArticleLink&id=" + id;
+               var wname = "ttrss_article_" + id;
 
-               debug(query);
+               debug(query + " " + wname);
+
+               var w = window.open("", wname);
+
+               if (!w) notify_error("Failed to open window for the article");
 
                new Ajax.Request(query, {
                        onComplete: function(transport) { 
@@ -1624,59 +1661,22 @@ function displayHelpInfobox(topic_id) {
        return false;
 }
 
-var _border_color_normal = "#88b0f0";
-var _border_color_highlight = "#72eda8";
-var _border_color_flash = "#f0fff0";
-
-function highlightHotkeyZone(zone) {
+function focus_element(id) {
        try {
-               var feeds = document.getElementById("feeds-holder");
-               var headlines = document.getElementById("headlines-frame");
-               var content = document.getElementById("content-frame");
-
-               feeds.style.borderColor = _border_color_normal;
-               headlines.style.borderColor = _border_color_normal;
-               content.style.borderColor = _border_color_normal;
-
-               if (zone == 1) {
-                       feeds.style.borderColor = _border_color_highlight;
-
-                       new Effect.Highlight(feeds, {duration: 0.5, startcolor: 
-                               _border_color_flash,
-                               queue: { position:'end', scope: 'EFCHL-Q', limit: 1 } } );
-               }
-
-               if (zone == 2) {
-                       headlines.style.borderColor = _border_color_highlight;
-
-                       new Effect.Highlight(headlines, {duration: 0.5, startcolor: 
-                               _border_color_flash,
-                               queue: { position:'end', scope: 'EFCHL-Q', limit: 1 } } );
-               }
-
-               if (zone == 3 && content) {                     
-                       content.style.borderColor = _border_color_highlight;
-
-                       new Effect.Highlight(content, {duration: 0.5, startcolor: 
-                               _border_color_flash,
-                               queue: { position:'end', scope: 'EFCHL-Q', limit: 1 } } );
-               }
-
+               var e = document.getElementById(id);
+               if (e) e.focus();
        } catch (e) {
-               exception_error("highlightHotkeyZone", e);
+               exception_error("focus_element", e);
        }
+       return false;
 }
 
-
-function setHotkeyZone(zone) {
+function loading_set_progress(v) {
        try {
-               hotkey_zone = zone;
-
-               highlightHotkeyZone(zone);
-
+               var o = document.getElementById("l_progress_i");
+               o.style.width = (v*2) + "px";
 
        } catch (e) {
-               exception_error("setHotkeyZone", e);
+               exception_error("loading_set_progress", e);
        }
 }
-