X-Git-Url: https://git.wh0rd.org/?a=blobdiff_plain;f=functions.js;h=7b7253d9f8529422d78ff96bc516b3583e051066;hb=5a6c21c71ab7cb489ef487c03cf5bae444b0da11;hp=7fe79c9a821f6ce4ea2825b848ff4082fa4fc465;hpb=bce7001fd1f1c2f105e7ebe9d1b533cf553bb3c5;p=tt-rss.git diff --git a/functions.js b/functions.js index 7fe79c9a..7b7253d9 100644 --- a/functions.js +++ b/functions.js @@ -2,6 +2,14 @@ var hotkeys_enabled = true; var debug_mode_enabled = false; var xmlhttp_rpc = Ajax.getTransport(); +/* add method to remove element from array */ + +Array.prototype.remove = function(s) { + for (var i=0; i < this.length; i++) { + if (s == this[i]) this.splice(i, 1); + } +} + function browser_has_opacity() { return navigator.userAgent.match("Gecko") != null || navigator.userAgent.match("Opera") != null; @@ -244,13 +252,13 @@ function hotkey_handler(e) { if (new_feed) viewfeed(new_feed, ''); } - if (!is_safari() && (keycode == 78 || keycode == 40)) { // n, down + if (keycode == 78 || keycode == 40) { // n, down if (typeof moveToPost != 'undefined') { return moveToPost('next'); } } - if (!is_safari() && (keycode == 80 || keycode == 38)) { // p, up + if (keycode == 80 || keycode == 38) { // p, up if (typeof moveToPost != 'undefined') { return moveToPost('prev'); } @@ -940,7 +948,8 @@ function hideOrShowFeedsCategory(doc, node, hide, cat_node) { if (node.childNodes[i].style != undefined) { - var has_unread = (node.childNodes[i].className != "feed"); + var has_unread = (node.childNodes[i].className != "feed" && + node.childNodes[i].className != "tag"); // debug(node.childNodes[i].id + " --> " + has_unread); @@ -1109,6 +1118,9 @@ function toggleSelectListRow(sender) { } } +function tSR(sender) { + return toggleSelectRow(sender); +} function toggleSelectRow(sender) { var parent_row = sender.parentNode.parentNode; @@ -1149,7 +1161,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; @@ -1158,7 +1170,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 { @@ -1207,7 +1219,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-", ""); + } } } } @@ -1244,7 +1259,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-", ""); + } } } } @@ -1252,11 +1270,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); } @@ -1306,6 +1331,14 @@ function leading_zero(p) { } function closeInfoBox(cleanup) { + + if (!is_msie() && !getInitParam("infobox_disable_overlay")) { + var overlay = document.getElementById("dialog_overlay"); + if (overlay) { + overlay.style.display = "none"; + } + } + var box = document.getElementById('infoBox'); var shadow = document.getElementById('infoBoxShadow'); @@ -1330,7 +1363,7 @@ function displayDlg(id, param) { return } - notify_progress("Loading, please wait..."); + notify_progress("Loading, please wait...", true); xmlhttp.open("GET", "backend.php?op=dlg&id=" + param_escape(id) + "¶m=" + param_escape(param), true); @@ -1362,6 +1395,14 @@ function infobox_submit_callback() { function infobox_callback() { if (xmlhttp.readyState == 4) { + + if (!is_msie() && !getInitParam("infobox_disable_overlay")) { + var overlay = document.getElementById("dialog_overlay"); + if (overlay) { + overlay.style.display = "block"; + } + } + var box = document.getElementById('infoBox'); var shadow = document.getElementById('infoBoxShadow'); if (box) { @@ -1376,6 +1417,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)) { @@ -1427,7 +1484,7 @@ function qaddFeed() { return false; } - notify_progress("Adding feed..."); + notify_progress(__("Subscribing to feed..."), true); closeInfoBox(); @@ -1437,6 +1494,8 @@ function qaddFeed() { var query = Form.serialize("feed_add_form"); + debug("subscribe q: " + query); + /* xmlhttp.open("GET", "backend.php?" + query, true); xmlhttp.onreadystatechange=dlg_frefresh_callback; xmlhttp.send(null); */ @@ -1516,6 +1575,7 @@ function getInitParam(key) { function storeInitParam(key, value) { debug("storeInitParam is OBSOLETE: " + key + " => " + value + ""); + init_params[key] = value; } function fatalError(code, message) { @@ -1619,3 +1679,34 @@ function logoutUser() { exception_error("logoutUser", e); } } + +// this only searches loaded headlines list, not in CDM +function getRelativePostIds(id) { + + debug("getRelativePostIds: " + id); + + var ids = new Array(); + var container = document.getElementById("headlinesList"); + + if (container) { + var rows = container.rows; + + for (var i = 0; i < rows.length; i++) { + 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 > 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-", "")); + + return ids; + } + } + } + + return false; +}