From d5ed5446d13807ff4a737a059a695d0ef0f97217 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 13 Sep 2010 15:40:35 +0400 Subject: [PATCH 1/3] functions: code cleanup --- feedlist.js | 20 +++++++++---- functions.js | 81 ---------------------------------------------------- viewfeed.js | 2 +- 3 files changed, 15 insertions(+), 88 deletions(-) diff --git a/feedlist.js b/feedlist.js index 8860424b1..3d9acafd1 100644 --- a/feedlist.js +++ b/feedlist.js @@ -163,14 +163,22 @@ function viewfeed(feed, subop, is_cat, subop_param, skip_history, offset) { var feedlist = $('feedList'); - var next_unread_feed = getRelativeFeedId(feedlist, - feed, "next", true); - + var next_unread_feed = getRelativeFeedId2(feed, false, + "next", true); + + /* gRFI2 also returns categories which we don't really + * need here, so we skip them */ + + while (next_unread_feed && next_unread_feed.match("CAT:")) + next_unread_feed = getRelativeFeedId2( + next_unread_feed.replace("CAT:", ""), + true, "next", true); + if (!next_unread_feed) { - next_unread_feed = getRelativeFeedId(feedlist, - -3, "next", true); + next_unread_feed = getRelativeFeedId2(-3, true, + "next", true); } - + if (next_unread_feed) { query = query + "&nuf=" + param_escape(next_unread_feed); //setActiveFeedId(next_unread_feed); diff --git a/functions.js b/functions.js index 2266bfc25..43de38c98 100644 --- a/functions.js +++ b/functions.js @@ -1093,70 +1093,6 @@ function getRelativeFeedId2(id, is_cat, direction, unread_only) { } } -function getRelativeFeedId(list, id, direction, unread_only) { - var rows = list.getElementsByTagName("LI"); - var feeds = new Array(); - - for (var i = 0; i < rows.length; i++) { - if (rows[i].id.match("FEEDR-")) { - - if (rows[i].id == "FEEDR-" + id || (Element.visible(rows[i]) && Element.visible(rows[i].parentNode))) { - - if (!unread_only || - (rows[i].className.match("Unread") || rows[i].id == "FEEDR-" + id)) { - feeds.push(rows[i].id.replace("FEEDR-", "")); - } - } - } - } - - if (!id) { - if (direction == "next") { - return feeds.shift(); - } else { - return feeds.pop(); - } - } else { - if (direction == "next") { - var idx = feeds.indexOf(id); - if (idx != -1 && idx < feeds.length) { - return feeds[idx+1]; - } else { - return getRelativeFeedId(list, false, direction, unread_only); - } - } else { - var idx = feeds.indexOf(id); - if (idx > 0) { - return feeds[idx-1]; - } else { - return getRelativeFeedId(list, false, direction, unread_only); - } - } - - } -} - -function showBlockElement(id, h_id) { - var elem = $(id); - - if (elem) { - elem.style.display = "block"; - - if (h_id) { - elem = $(h_id); - if (elem) { - elem.style.display = "none"; - } - } - } else { - alert("[showBlockElement] can't find element with id " + id); - } -} - -function appearBlockElement_afh(effect) { - -} - function checkboxToggleElement(elem, id) { if (elem.checked) { Effect.Appear(id, {duration : 0.5}); @@ -1165,23 +1101,6 @@ function checkboxToggleElement(elem, id) { } } -function appearBlockElement(id, h_id) { - - try { - if (h_id) { - Effect.Fade(h_id); - } - Effect.SlideDown(id, {duration : 1.0, afterFinish: appearBlockElement_afh}); - } catch (e) { - exception_error("appearBlockElement", e); - } - -} - -function hideParentElement(e) { - e.parentNode.style.display = "none"; -} - function dropboxSelect(e, v) { for (i = 0; i < e.length; i++) { if (e[i].value == v) { diff --git a/viewfeed.js b/viewfeed.js index 4a7cc9e7f..73ad35f0a 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -2062,7 +2062,7 @@ function cdmExpandArticle(a_id) { } catch (e) { - exception_error("appearBlockElementF", e); + exception_error("cdmExpandArticle", e); } } From 63def06ca88cacdfc0688d450a22ff17f499ef88 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 13 Sep 2010 15:54:24 +0400 Subject: [PATCH 2/3] check_for_update: fix typo which caused incorrect output of print_runtime_error() which caused RPC errors when DEFAULT_UPDATE_METHOD was set to SimplePie --- functions.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/functions.php b/functions.php index 2f895cd30..e7d95c152 100644 --- a/functions.php +++ b/functions.php @@ -3966,7 +3966,7 @@ } error_reporting(0); - if (DEFAULT_UPDATE_INTERVAL == "1") { + if (DEFAULT_UPDATE_METHOD == "1") { $rss = new SimplePie(); $rss->set_useragent(SIMPLEPIE_USERAGENT . MAGPIE_USER_AGENT_EXT); // $rss->set_timeout(MAGPIE_FETCH_TIME_OUT); From 91c5f22946ab93d1eaf1bccc2f0c5c3dece6bc43 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 13 Sep 2010 16:00:05 +0400 Subject: [PATCH 3/3] skip new version checking right after login to speed up startup --- functions.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/functions.php b/functions.php index e7d95c152..115bdfebd 100644 --- a/functions.php +++ b/functions.php @@ -1850,6 +1850,8 @@ $_SESSION["ip_address"] = $_SERVER["REMOTE_ADDR"]; $_SESSION["pwd_hash"] = db_fetch_result($result, 0, "pwd_hash"); + + $_SESSION["last_version_check"] = time(); initialize_user_prefs($link, $_SESSION["uid"]);