mirror of
https://git.tt-rss.org/git/tt-rss.git
synced 2025-12-13 22:15:56 +00:00
offline: add progress indicator; tweak download intervals and amount of articles
This commit is contained in:
@@ -649,6 +649,10 @@ function mouse_up_handler(e) {
|
|||||||
document.onselectstart = null;
|
document.onselectstart = null;
|
||||||
var e = $("headlineActionsBody");
|
var e = $("headlineActionsBody");
|
||||||
if (e) Element.hide(e);
|
if (e) Element.hide(e);
|
||||||
|
|
||||||
|
var e = $("offlineModeDrop");
|
||||||
|
if (e) Element.hide(e);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
@@ -460,9 +460,7 @@ function parse_counters(reply, scheduled_call) {
|
|||||||
if (id == "global-unread") {
|
if (id == "global-unread") {
|
||||||
|
|
||||||
if (ctr > global_unread) {
|
if (ctr > global_unread) {
|
||||||
if (db && getInitParam("offline_enabled") == "1") {
|
offlineDownloadStart();
|
||||||
window.setTimeout("update_offline_data(0)", 100);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
global_unread = ctr;
|
global_unread = ctr;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@
|
|||||||
|
|
||||||
foreach ($manifest_files as $f) {
|
foreach ($manifest_files as $f) {
|
||||||
$tmp = filemtime($f);
|
$tmp = filemtime($f);
|
||||||
if ($tmp > $mtime) {
|
if ($tmp > $mtime_max) {
|
||||||
$mtime_max = $tmp;
|
$mtime_max = $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,7 +89,7 @@
|
|||||||
|
|
||||||
{
|
{
|
||||||
"betaManifestVersion": 1,
|
"betaManifestVersion": 1,
|
||||||
"version": "<?php echo $mtime_max ?>",
|
"version": "<?php echo date("Y.m.d H:i:s", $mtime_max) ?>",
|
||||||
"entries": [
|
"entries": [
|
||||||
<?php echo join(",\n ", $manifest_formatted); ?>
|
<?php echo join(",\n ", $manifest_formatted); ?>
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -569,7 +569,7 @@
|
|||||||
|
|
||||||
$query = "SELECT ref_id,unread FROM ttrss_user_entries
|
$query = "SELECT ref_id,unread FROM ttrss_user_entries
|
||||||
WHERE last_read >= '$last_online' AND
|
WHERE last_read >= '$last_online' AND
|
||||||
owner_uid = ".$_SESSION["uid"];
|
owner_uid = ".$_SESSION["uid"] . " LIMIT 500";
|
||||||
|
|
||||||
$result = db_query($link, $query);
|
$result = db_query($link, $query);
|
||||||
|
|
||||||
|
|||||||
103
offline.js
103
offline.js
@@ -4,6 +4,8 @@ var offline_mode = false;
|
|||||||
var store = false;
|
var store = false;
|
||||||
var localServer = false;
|
var localServer = false;
|
||||||
var db = false;
|
var db = false;
|
||||||
|
var articles_synced = 0;
|
||||||
|
var sync_in_progress = false;
|
||||||
|
|
||||||
function view_offline(id, feed_id) {
|
function view_offline(id, feed_id) {
|
||||||
try {
|
try {
|
||||||
@@ -564,6 +566,7 @@ function render_offline_feedlist() {
|
|||||||
function init_offline() {
|
function init_offline() {
|
||||||
try {
|
try {
|
||||||
offline_mode = true;
|
offline_mode = true;
|
||||||
|
store.enabled = true;
|
||||||
|
|
||||||
Element.hide("dispSwitchPrompt");
|
Element.hide("dispSwitchPrompt");
|
||||||
Element.hide("feedBrowserPrompt");
|
Element.hide("feedBrowserPrompt");
|
||||||
@@ -720,6 +723,12 @@ function offline_download_parse(stage, transport) {
|
|||||||
|
|
||||||
debug("downloaded articles: " + articles_found + " limit: " + limit);
|
debug("downloaded articles: " + articles_found + " limit: " + limit);
|
||||||
|
|
||||||
|
articles_synced += articles_found;
|
||||||
|
|
||||||
|
var msg =__("Synchronizing (got %d articles)...").replace("%d", articles_synced);
|
||||||
|
|
||||||
|
$("offlineModeSyncMsg").innerHTML = msg;
|
||||||
|
|
||||||
var has_sync_data = has_local_sync_data();
|
var has_sync_data = has_local_sync_data();
|
||||||
|
|
||||||
if (articles_found >= limit || has_sync_data) {
|
if (articles_found >= limit || has_sync_data) {
|
||||||
@@ -730,13 +739,34 @@ function offline_download_parse(stage, transport) {
|
|||||||
window.setTimeout("update_offline_data(0)", 180*1000);
|
window.setTimeout("update_offline_data(0)", 180*1000);
|
||||||
debug("update_offline_data: finished");
|
debug("update_offline_data: finished");
|
||||||
|
|
||||||
var pic = $("restartOfflinePic");
|
var pic = $("offlineModePic");
|
||||||
|
|
||||||
if (pic) {
|
if (pic) {
|
||||||
pic.src = "images/offline.png";
|
pic.src = "images/offline.png";
|
||||||
pic.title = __("Restart in offline mode");
|
|
||||||
|
var rs = db.execute("SELECT value FROM syncdata WHERE key = 'last_online'");
|
||||||
|
var last_sync = "";
|
||||||
|
|
||||||
|
if (rs.isValidRow()) {
|
||||||
|
last_sync = rs.field(0).substring(0,16);
|
||||||
|
}
|
||||||
|
rs.close();
|
||||||
|
|
||||||
|
var msg = __("Last sync: %s").replace("%s", last_sync);
|
||||||
|
|
||||||
|
articles_synced = 0;
|
||||||
|
|
||||||
|
$("offlineModeSyncMsg").innerHTML = msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hide_elems = $$("div.hideWhenSyncing");
|
||||||
|
|
||||||
|
for (var j = 0; j < hide_elems.length; j++) {
|
||||||
|
Element.show(hide_elems[j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_in_progress = false;
|
||||||
|
|
||||||
db.execute("DELETE FROM articles WHERE "+
|
db.execute("DELETE FROM articles WHERE "+
|
||||||
"updated < DATETIME('NOW', 'localtime', '-31 days')");
|
"updated < DATETIME('NOW', 'localtime', '-31 days')");
|
||||||
|
|
||||||
@@ -758,6 +788,7 @@ function update_offline_data(stage) {
|
|||||||
try {
|
try {
|
||||||
|
|
||||||
if (!stage) stage = 0;
|
if (!stage) stage = 0;
|
||||||
|
|
||||||
if (!db || offline_mode || getInitParam("offline_enabled") != "1") return;
|
if (!db || offline_mode || getInitParam("offline_enabled") != "1") return;
|
||||||
|
|
||||||
// notify_progress("Updating offline data... (" + stage +")", true);
|
// notify_progress("Updating offline data... (" + stage +")", true);
|
||||||
@@ -790,13 +821,23 @@ function update_offline_data(stage) {
|
|||||||
|
|
||||||
debug(query + "/" + to_sync);
|
debug(query + "/" + to_sync);
|
||||||
|
|
||||||
var pic = $("restartOfflinePic");
|
var pic = $("offlineModePic");
|
||||||
|
|
||||||
if (pic) {
|
if (pic) {
|
||||||
pic.src = "images/offline-sync.gif";
|
pic.src = "images/offline-sync.gif";
|
||||||
pic.title = __("Synchronizing offline data...");
|
if (articles_synced == 0) {
|
||||||
|
$("offlineModeSyncMsg").innerHTML = __("Synchronizing...");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var hide_elems = $$("div.hideWhenSyncing");
|
||||||
|
|
||||||
|
for (var j = 0; j < hide_elems.length; j++) {
|
||||||
|
Element.hide(hide_elems[j]);
|
||||||
|
}
|
||||||
|
|
||||||
|
sync_in_progress = true;
|
||||||
|
|
||||||
new Ajax.Request(query, {
|
new Ajax.Request(query, {
|
||||||
parameters: to_sync,
|
parameters: to_sync,
|
||||||
onComplete: function(transport) {
|
onComplete: function(transport) {
|
||||||
@@ -959,8 +1000,8 @@ function enable_offline_reading() {
|
|||||||
|
|
||||||
if (db && getInitParam("offline_enabled") == "1") {
|
if (db && getInitParam("offline_enabled") == "1") {
|
||||||
init_local_sync_data();
|
init_local_sync_data();
|
||||||
Element.show("restartOfflinePic");
|
Element.show("offlineModePic");
|
||||||
window.setTimeout("update_offline_data(0)", 100);
|
offlineDownloadStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
@@ -974,8 +1015,9 @@ function init_gears() {
|
|||||||
if (window.google && google.gears) {
|
if (window.google && google.gears) {
|
||||||
localServer = google.gears.factory.create("beta.localserver");
|
localServer = google.gears.factory.create("beta.localserver");
|
||||||
store = localServer.createManagedStore("tt-rss");
|
store = localServer.createManagedStore("tt-rss");
|
||||||
store.manifestUrl = "manifest.json.php";
|
store.manifestUrl = "manifest.json.php";
|
||||||
store.checkForUpdate();
|
store.checkForUpdate();
|
||||||
|
store.enabled = false;
|
||||||
|
|
||||||
db = google.gears.factory.create('beta.database');
|
db = google.gears.factory.create('beta.database');
|
||||||
db.open('tt-rss');
|
db.open('tt-rss');
|
||||||
@@ -1454,3 +1496,50 @@ function catchup_local_feed(id, is_cat) {
|
|||||||
exception_error("catchup_local_feed", e);
|
exception_error("catchup_local_feed", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function toggleOfflineModeInfo() {
|
||||||
|
try {
|
||||||
|
var e = $('offlineModeDrop');
|
||||||
|
var p = $('offlineModePic');
|
||||||
|
|
||||||
|
if (Element.visible(e)) {
|
||||||
|
Element.hide(e);
|
||||||
|
} else {
|
||||||
|
Element.show(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
exception_error("toggleOfflineModeInfo", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function offlineDownloadStart() {
|
||||||
|
try {
|
||||||
|
if (db && !sync_in_progress && getInitParam("offline_enabled") == "1") {
|
||||||
|
window.setTimeout("update_offline_data(0)", 100);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
exception_error("offlineDownloadStart", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function offlineClearData() {
|
||||||
|
try {
|
||||||
|
if (db) {
|
||||||
|
|
||||||
|
if (confirm(__("Remove offline data?"))) {
|
||||||
|
|
||||||
|
notify_progress("Removing offline data...");
|
||||||
|
|
||||||
|
db.execute("DELETE FROM articles");
|
||||||
|
db.execute("DELETE FROM article_labels");
|
||||||
|
db.execute("DELETE FROM labels");
|
||||||
|
db.execute("DELETE FROM feeds");
|
||||||
|
|
||||||
|
notify_info("Offline data removed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
exception_error("offlineClearData", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
23
tt-rss.css
23
tt-rss.css
@@ -1703,7 +1703,7 @@ div.topLinks img {
|
|||||||
cursor : pointer;
|
cursor : pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
#restartOfflinePic {
|
#offlineModePic {
|
||||||
margin-left : 5px;
|
margin-left : 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2137,4 +2137,25 @@ div.colorPicker {
|
|||||||
color : #909090;
|
color : #909090;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
div#offlineModeDrop div {
|
||||||
|
padding : 2px 2px 2px 2px;
|
||||||
|
text-align : center;
|
||||||
|
}
|
||||||
|
|
||||||
|
div#offlineModeDrop {
|
||||||
|
position : absolute;
|
||||||
|
margin : 0px;
|
||||||
|
padding : 2px;
|
||||||
|
background-color : white;
|
||||||
|
z-index : 2;
|
||||||
|
margin : 2px 0px 0px 0px;
|
||||||
|
top : auto;
|
||||||
|
right : 0px;
|
||||||
|
border : 1px solid #cccccc;
|
||||||
|
background : white;
|
||||||
|
margin-left : -1px;
|
||||||
|
max-height : 250px;
|
||||||
|
overflow : auto;
|
||||||
|
color : #909090;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
20
tt-rss.php
20
tt-rss.php
@@ -131,9 +131,23 @@ window.onload = init;
|
|||||||
| <a href="logout.php"><?php echo __('Logout') ?></a>
|
| <a href="logout.php"><?php echo __('Logout') ?></a>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
|
|
||||||
<img id="restartOfflinePic" src="images/offline.png" style="display:none"
|
<img id="offlineModePic"
|
||||||
onclick="gotoOffline()"
|
onmouseover="enable_selection(false)"
|
||||||
title="<?php echo __('Restart in offline mode') ?>"/>
|
onmouseout="enable_selection(true)"
|
||||||
|
onclick="toggleOfflineModeInfo()"
|
||||||
|
src="images/offline.png" style="display:none"
|
||||||
|
title="<?php echo __('Offline mode') ?>"/>
|
||||||
|
|
||||||
|
<div id="offlineModeDrop" style="display : none">
|
||||||
|
<div id="offlineModeSyncMsg">---</div>
|
||||||
|
<div class="hideWhenSyncing">
|
||||||
|
<a href="javascript:offlineDownloadStart()">
|
||||||
|
<?php echo __('Start synchronization') ?></a></div>
|
||||||
|
<div class="hideWhenSyncing"><a href="javascript:offlineClearData()">
|
||||||
|
<?php echo __('Remove offline data') ?></a></div>
|
||||||
|
<div><a href="javascript:gotoOffline()">
|
||||||
|
<?php echo __('Restart in offline mode') ?></a></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<img id="newVersionIcon" style="display:none;" onclick="javascript:explainError(2)"
|
<img id="newVersionIcon" style="display:none;" onclick="javascript:explainError(2)"
|
||||||
src="images/new_version.png" title="<?php echo __('New version of Tiny Tiny RSS is available!') ?>"
|
src="images/new_version.png" title="<?php echo __('New version of Tiny Tiny RSS is available!') ?>"
|
||||||
|
|||||||
Reference in New Issue
Block a user