code cleanups, start work on sepUpdateFeed mechanism
This commit is contained in:
parent
7fdd55fb41
commit
caa4e57f27
30
backend.php
30
backend.php
|
@ -91,6 +91,9 @@
|
|||
|
||||
print "</table>";
|
||||
|
||||
print "<div class=\"invisible\" id=\"FEEDTU\">$total_unread</div>";
|
||||
|
||||
/*
|
||||
print "<p align=\"center\">All feeds:
|
||||
<a class=\"button\"
|
||||
href=\"javascript:scheduleFeedUpdate(true)\">Update</a>";
|
||||
|
@ -99,7 +102,7 @@
|
|||
href=\"javascript:catchupAllFeeds()\">Mark as read</a></p>";
|
||||
|
||||
print "<div class=\"invisible\" id=\"FEEDTU\">$total_unread</div>";
|
||||
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
@ -109,29 +112,20 @@
|
|||
|
||||
$subop = $_GET["subop"];
|
||||
|
||||
if ($subop == "getRelativeId") {
|
||||
$mode = $_GET["mode"];
|
||||
$id = $_GET["id"];
|
||||
if ($subop == "updateFeed") {
|
||||
$feed_id = $_GET["feed"];
|
||||
|
||||
if ($id != 'false' && $feed_id != 'false') {
|
||||
$result = pg_query($link,
|
||||
"SELECT feed_url FROM ttrss_feeds WHERE id = '$feed_id'");
|
||||
|
||||
if ($mode == 'next') {
|
||||
$check_qpart = "updated >= ";
|
||||
} else {
|
||||
$idcheck_qpart = "id < '$id'";
|
||||
if (pg_num_rows($result) > 0) {
|
||||
$feed_url = pg_fetch_result($result, 0, "feed_url");
|
||||
// update_rss_feed($link, $feed_url, $feed_id);
|
||||
}
|
||||
|
||||
$result = pg_query("SELECT id FROM ttrss_entries WHERE
|
||||
$check_qpart AND
|
||||
feed_id = '$feed_id'
|
||||
ORDER BY updated DESC LIMIT 1");
|
||||
print "DONE-$feed_id";
|
||||
|
||||
$result_id = pg_fetch_result($result, 0, "id");
|
||||
|
||||
print "M $mode : P $id -> P $result_id : F $feed_id";
|
||||
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ($subop == "forceUpdateAllFeeds") {
|
||||
|
|
50
tt-rss.js
50
tt-rss.js
|
@ -19,6 +19,9 @@ var total_feed_entries = false;
|
|||
var _viewfeed_autoselect_first = false;
|
||||
var _viewfeed_autoselect_last = false;
|
||||
|
||||
var _update_ids;
|
||||
var _update_num_ids;
|
||||
|
||||
var search_query = "";
|
||||
|
||||
/*@cc_on @*/
|
||||
|
@ -60,6 +63,14 @@ function feedlist_callback() {
|
|||
}
|
||||
}
|
||||
|
||||
function feed_update_callback() {
|
||||
if (xmlhttp_rpc.readyState == 4) {
|
||||
var result = xmlhttp_rpc.responseText;
|
||||
notify(_update_ids);
|
||||
updateFeed(_update_ids.shift());
|
||||
}
|
||||
}
|
||||
|
||||
function viewfeed_callback() {
|
||||
var container = document.getElementById('headlines');
|
||||
if (xmlhttp.readyState == 4) {
|
||||
|
@ -130,6 +141,30 @@ function refetch_callback() {
|
|||
}
|
||||
}
|
||||
|
||||
function updateFeed(feed_id) {
|
||||
|
||||
var query_str = "backend.php?op=rpc&subop=updateFeed&feed=" + feed_id;
|
||||
|
||||
if (xmlhttp_ready(xmlhttp_rpc)) {
|
||||
xmlhttp_rpc.open("GET", query_str, true);
|
||||
xmlhttp_rpc.onreadystatechange=feed_update_callback;
|
||||
xmlhttp_rpc.send(null);
|
||||
} else {
|
||||
printLockingError();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function scheduleSepFeedUpdate(force) {
|
||||
notify("Updating feeds in background (M2)...");
|
||||
|
||||
_update_ids = getFeedIds();
|
||||
_update_num_ids = _update_ids.length;
|
||||
|
||||
updateFeed(_update_ids.pop());
|
||||
|
||||
}
|
||||
|
||||
function scheduleFeedUpdate(force) {
|
||||
|
||||
notify("Updating feeds in background...");
|
||||
|
@ -297,6 +332,21 @@ function markHeadline(id) {
|
|||
}
|
||||
}
|
||||
|
||||
function getFeedIds() {
|
||||
var content = document.getElementById("feedsList");
|
||||
|
||||
var rows = new Array();
|
||||
|
||||
for (i = 0; i < content.rows.length; i++) {
|
||||
var id = content.rows[i].id.replace("FEEDR-", "");
|
||||
if (id.length > 0) {
|
||||
rows.push(id);
|
||||
}
|
||||
}
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
function cleanSelected(element) {
|
||||
var content = document.getElementById(element);
|
||||
|
||||
|
|
14
tt-rss.php
14
tt-rss.php
|
@ -28,8 +28,18 @@
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" rowspan="2" id="feeds" class="feeds">
|
||||
|
||||
<td valign="top" rowspan="2" class="feeds">
|
||||
|
||||
<div id="feeds"> </div>
|
||||
|
||||
<p align="center">All feeds:
|
||||
|
||||
<a class="button"
|
||||
href="javascript:scheduleFeedUpdate(true)">Update</a>
|
||||
|
||||
<a class="button"
|
||||
href="javascript:catchupAllFeeds()">Mark as read</a></p>
|
||||
|
||||
</td>
|
||||
<td id="headlines" class="headlines" valign="top">
|
||||
Please select the feed.
|
||||
|
|
Loading…
Reference in New Issue