function init_offline() {
try {
offline_mode = true;
+ store.enabled = true;
Element.hide("dispSwitchPrompt");
Element.hide("feedBrowserPrompt");
}
offlineSyncShowHideElems(true);
+ offlineUpdateStore();
sync_in_progress = true;
store = localServer.createManagedStore("tt-rss");
store.manifestUrl = "manifest.json.php";
+ store.enabled = false;
db = google.gears.factory.create('beta.database');
db.open('tt-rss');
if (confirm(__("Switch Tiny Tiny RSS into offline mode?"))) {
+ store.enabled = true;
store.checkForUpdate();
notify_progress("Preparing offline mode...", true);
//window.location.href = "tt-rss.php";
offlineDownloadStop();
- offline_mode = true;
init_offline();
notify_info("Tiny Tiny RSS is in offline mode.");
}
function gotoOnline() {
- if (confirm(__("You won't be able to access offline version of Tiny Tiny RSS until you switch it into offline mode again. Go online?"))) {
- localServer.removeManagedStore("tt-rss");
+// if (confirm(__("You won't be able to access offline version of Tiny Tiny RSS until you switch it into offline mode again. Go online?"))) {
+ if (confirm(__("Tiny Tiny RSS will reload. Go online?"))) {
+ //localServer.removeManagedStore("tt-rss");
window.location.href = "tt-rss.php";
}
}
function offlineUpdateStore() {
try {
+ if (offline_mode || !store) return;
- if (offline_mode) return;
+ store.checkForUpdate();
+
+ var timerId = window.setInterval(function() {
+ if (store.currentVersion) {
+ window.clearInterval(timerId);
+ debug("[Local store] sync complete: " + store.currentVersion);
+ } else if (store.updateStatus == 3) {
+ debug("[Local store] sync error: " + store.lastErrorMessage);
+ } }, 500);
} catch (e) {
exception_error("offlineUpdateStore", e);
exception_error("offlineSyncShowHideElems", e);
}
}
+
+function offlineConfirmModeChange() {
+ try {
+
+ if (db) {
+ var ok = confirm(__("Tiny Tiny RSS has trouble accessing its server. Would you like to go offline?"));
+
+ if (ok) {
+ init_offline();
+ }
+ }
+
+ } catch (e) {
+ exception_error("offlineConfirmModeChange", e);
+ }
+}
}
if (!transport.responseXML) {
- fatalError(3, "Sanity check: Received reply is not XML", transport.responseText);
- return;
+ if (!store) {
+ fatalError(3, "Sanity check: Received reply is not XML",
+ transport.responseText);
+ return;
+ } else {
+ init_offline();
+ return;
+ }
}
var reply = transport.responseXML.firstChild.firstChild;
loading_set_progress(30);
- offline_mode = false;
- if (store) offline_mode = store.currentVersion;
-
- if (offline_mode) {
- init_offline();
- } else {
- new Ajax.Request("backend.php?op=rpc&subop=sanityCheck" + params, {
- onComplete: function(transport) {
- backend_sanity_check_callback(transport);
- } });
- }
+ new Ajax.Request("backend.php?op=rpc&subop=sanityCheck" + params, {
+ onComplete: function(transport) {
+ backend_sanity_check_callback(transport);
+ } });
} catch (e) {
exception_error("init", e);
function headlines_callback2(transport, feed_cur_page) {
try {
+ if (!transport.responseText && db) {
+ offlineConfirmModeChange();
+ return;
+ }
+
loading_set_progress(100);
debug("headlines_callback2 [page=" + feed_cur_page + "]");
try {
debug("article_callback2 " + id);
+ if (!transport.responseText && db) {
+ offlineConfirmModeChange();
+ return;
+ }
+
if (transport.responseXML) {
if (!transport_error_check(transport)) return;