diff options
author | Andrew Dolgov <[email protected]> | 2005-09-05 13:41:59 +0100 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2005-09-05 13:41:59 +0100 |
commit | bb7cfaceb1f76bd6dba7d0687ee2e338fd61df5b (patch) | |
tree | c29c84aa399704cfb6e3672e810472d44a73dff7 | |
parent | 72763620765b994f400682189dd9a2108a31c9ff (diff) |
further javascript cleanups
-rw-r--r-- | backend.php | 2 | ||||
-rw-r--r-- | functions.js | 13 | ||||
-rw-r--r-- | functions.php | 10 | ||||
-rw-r--r-- | tt-rss.js | 109 | ||||
-rw-r--r-- | tt-rss.php | 2 | ||||
-rw-r--r-- | viewfeed.js | 55 |
6 files changed, 64 insertions, 127 deletions
diff --git a/backend.php b/backend.php index a2236c3a6..88d19641f 100644 --- a/backend.php +++ b/backend.php @@ -486,6 +486,8 @@ // kludge, because iframe doesn't seem to support onload() print "<script type=\"text/javascript\"> + document.onkeydown = hotkey_handler; + var feedr = parent.document.getElementById(\"FEEDR-\" + $feed); var feedt = parent.document.getElementById(\"FEEDT-\" + $feed); var feedu = parent.document.getElementById(\"FEEDU-\" + $feed); diff --git a/functions.js b/functions.js index cb241ada6..f0d76769d 100644 --- a/functions.js +++ b/functions.js @@ -91,12 +91,15 @@ function hotkey_handler(e) { var piggie = document.getElementById("piggie"); - if (seq.match("807371717369")) { - localPiggieFunction(true); - } else { - localPiggieFunction(false); - } + if (piggie) { + if (seq.match("807371717369")) { + localPiggieFunction(true); + } else { + localPiggieFunction(false); + } + } + if (typeof localHotkeyHandler != 'undefined') { localHotkeyHandler(keycode); } diff --git a/functions.php b/functions.php index e6ef6589a..b56e9a93a 100644 --- a/functions.php +++ b/functions.php @@ -238,10 +238,6 @@ $last_read_qpart = ""; -// if ("$orig_title" != "$entry_title") { -// $last_read_qpart = 'last_read = null,'; -// } - if ($orig_content_hash != $content_hash) { if (UPDATE_POST_ON_CHECKSUM_CHANGE) { $last_read_qpart = 'last_read = null,'; @@ -257,10 +253,6 @@ $entry_is_modified = true; } -// if (!$no_orig_date && $orig_timestamp < $entry_timestamp) { -// $last_read_qpart = 'last_read = null,'; -// } - if ($entry_is_modified) { $entry_comments = pg_escape_string($entry_comments); @@ -268,8 +260,6 @@ $entry_title = pg_escape_string($entry_title); $entry_link = pg_escape_string($entry_link); -// print "update object $entry_guid<br>"; - $query = "UPDATE ttrss_entries SET $last_read_qpart @@ -57,59 +57,6 @@ function feedlist_callback() { } } -/* -function viewfeed_callback() { - var container = document.getElementById('headlines'); - if (xmlhttp.readyState == 4) { - container.innerHTML = xmlhttp.responseText; - - var factive = document.getElementById("FACTIVE"); - var funread = document.getElementById("FUNREAD"); - var ftotal = document.getElementById("FTOTAL"); - - if (_viewfeed_autoselect_first == true) { - _viewfeed_autoselect_first = false; - view(getFirstVisibleHeadlineId(), active_feed_id); - } - - if (_viewfeed_autoselect_last == true) { - _viewfeed_autoselect_last = false; - view(getLastVisibleHeadlineId(), active_feed_id); - } - - if (ftotal && factive && funread) { - var feed_id = factive.innerHTML; - - var feedr = document.getElementById("FEEDR-" + feed_id); - var feedt = document.getElementById("FEEDT-" + feed_id); - var feedu = document.getElementById("FEEDU-" + feed_id); - - feedt.innerHTML = ftotal.innerHTML; - feedu.innerHTML = funread.innerHTML; - - total_feed_entries = ftotal.innerHTML; - - if (feedu.innerHTML > 0 && !feedr.className.match("Unread")) { - feedr.className = feedr.className + "Unread"; - } else if (feedu.innerHTML <= 0) { - feedr.className = feedr.className.replace("Unread", ""); - } - - cleanSelected("feedsList"); - - feedr.className = feedr.className + "Selected"; - } - - var searchbox = document.getElementById("searchbox"); - searchbox.value = search_query; - - markHeadline(active_post_id); - - notify(""); - - } -} */ - function refetch_callback() { if (xmlhttp_rpc.readyState == 4) { @@ -337,62 +284,6 @@ function viewfeed(feed, skip, subop) { } -/* -function view(id,feed_id) { - - enableHotkeys(); - - if (!xmlhttp_ready(xmlhttp_view)) { - printLockingError(); - return - } - - var crow = document.getElementById("RROW-" + id); - - if (crow.className.match("Unread")) { - var umark = document.getElementById("FEEDU-" + feed_id); - umark.innerHTML = umark.innerHTML - 1; - crow.className = crow.className.replace("Unread", ""); - - if (umark.innerHTML == "0") { - var feedr = document.getElementById("FEEDR-" + feed_id); - feedr.className = feedr.className.replace("Unread", ""); - } - - total_unread--; - } - - cleanSelected("headlinesList"); -// crow.className = crow.className + "Selected"; - - var upd_img_pic = document.getElementById("FUPDPIC-" + id); - - if (upd_img_pic) { - upd_img_pic.innerHTML = ""; - } - -// document.getElementById('content').innerHTML='Loading, please wait...'; - - var unread_rows = getVisibleUnreadHeadlines(); - - if (unread_rows.length == 0) { - var button = document.getElementById("btnCatchupPage"); - if (button) { - button.className = "disabledButton"; - button.href = ""; - } - } - - active_post_id = id; - - var content = document.getElementById("content-frame"); - - content.src = "backend.php?op=view&addheader=true&id=" + param_escape(id); - markHeadline(active_post_id); - -} -*/ - function timeout() { scheduleFeedUpdate(true); setTimeout("timeout()", 1800*1000); diff --git a/tt-rss.php b/tt-rss.php index ec4e8b6ef..b30c4fcce 100644 --- a/tt-rss.php +++ b/tt-rss.php @@ -73,7 +73,7 @@ <iframe name="headlines-frame" id="headlines-frame" class="headlinesFrame"> </iframe> </td> -</tr> +</tr><tr> <td class="content" id="content" valign="top"> <iframe name="content-frame" id="content-frame" class="contentFrame"> </iframe> </td> diff --git a/viewfeed.js b/viewfeed.js index e8b305dcf..6866c278c 100644 --- a/viewfeed.js +++ b/viewfeed.js @@ -1,4 +1,5 @@ -var active_post_id; +var active_feed_id = false; +var active_post_id = false; var total_unread = 0; var xmlhttp_rpc = false; @@ -22,7 +23,7 @@ if (!xmlhttp_rpc && typeof XMLHttpRequest!='undefined') { xmlhttp_rpc = new XMLHttpRequest(); } -function view(id,feed_id) { +function view(id, feed_id) { enableHotkeys(); @@ -60,6 +61,7 @@ function view(id,feed_id) { } active_post_id = id; + active_feed_id = feed_id; var content = parent.document.getElementById("content-frame"); @@ -100,4 +102,53 @@ function toggleMark(id, toggle) { } +function moveToPost(mode) { + var rows = getVisibleHeadlineIds(); + + var prev_id; + var next_id; + + if (active_post_id == false) { + next_id = getFirstVisibleHeadlineId(); + prev_id = getLastVisibleHeadlineId(); + } else { + for (var i = 0; i < rows.length; i++) { + if (rows[i] == active_post_id) { + prev_id = rows[i-1]; + next_id = rows[i+1]; + } + } + } + + if (mode == "next") { + if (next_id != undefined) { + view(next_id, active_feed_id); + } + } + + if (mode == "prev") { + if ( prev_id != undefined) { + view(prev_id, active_feed_id); + } + } +} + +function localHotkeyHandler(keycode) { + + if (keycode == 78) { + return moveToPost('next'); + } + + if (keycode == 80) { + return moveToPost('prev'); + } + +// FIXME +// if (keycode == 85) { +// return viewfeed(active_feed_id, active_offset, "ForceUpdate"); +// } + +// alert("KC: " + keycode); + +} |