remove google gears

This commit is contained in:
Andrew Dolgov 2010-11-14 21:50:13 +03:00
parent b71a7df9ed
commit 75c510323b
12 changed files with 79 additions and 2452 deletions

View File

@ -1,9 +1,6 @@
var last_feeds = [];
var init_params = {};
var db = false;
var store = false;
var _active_feed_id = false;
var _active_feed_offset = false;
var _update_timeout = false;

View File

@ -67,8 +67,6 @@ function viewfeed(feed, subop, is_cat, offset) {
try {
if (is_cat == undefined) is_cat = false;
if (offline_mode) return viewfeed_offline(feed, subop, is_cat, offset);
// if (!offset) page_offset = 0;
last_requested_article = 0;
@ -147,8 +145,6 @@ function viewfeed(feed, subop, is_cat, offset) {
if (subop == "MarkAllRead") {
catchup_local_feed(feed, is_cat);
var show_next_feed = getInitParam("on_catchup_show_next_feed") == "1";
if (show_next_feed) {
@ -367,8 +363,6 @@ function toggleCollapseCat(cat) {
{ parameters: "backend.php?op=feeds&subop=collapse&cid=" +
param_escape(cat) } );
local_collapse_cat(cat);
} catch (e) {
exception_error("toggleCollapseCat", e);
}
@ -418,8 +412,6 @@ function feedlist_init() {
document.onmousedown = mouse_down_handler;
document.onmouseup = mouse_up_handler;
if (!offline_mode) setTimeout("timeout()", 1);
setTimeout("hotkey_prefix_timeout()", 5*1000);
if (getActiveFeedId()) {
@ -579,10 +571,6 @@ function mouse_up_handler(e) {
document.onselectstart = null;
var e = $("headlineActionsBody");
if (e) Element.hide(e);
var e = $("offlineModeDrop");
if (e) Element.hide(e);
}
} catch (e) {
@ -591,11 +579,7 @@ function mouse_up_handler(e) {
}
function request_counters_real() {
try {
if (offline_mode) return;
console.log("requesting counters...");
var query = "?op=rpc&subop=getAllCounters&seq=" + next_seq();
@ -683,11 +667,6 @@ function parse_counters(reply, scheduled_call) {
var xmsg = elems[l].xmsg;
if (id == "global-unread") {
if (ctr > global_unread) {
offlineDownloadStart(1);
}
global_unread = ctr;
updateTitle();
continue;

View File

@ -1227,16 +1227,9 @@ function backend_sanity_check_callback(transport) {
fatalError(3, "Sanity check: Received reply is not XML",
transport.responseText);
return;
} else {
init_offline();
return;
}
}
if (getURLParam("offline")) {
return init_offline();
}
var reply = transport.responseXML.getElementsByTagName("error")[0];
if (!reply) {
@ -1261,16 +1254,8 @@ function backend_sanity_check_callback(transport) {
if (params) {
for (k in params) {
var v = params[k];
console.log("IP: " + k + " => " + v);
if (db) {
db.execute("DELETE FROM init_params WHERE key = ?", [k]);
db.execute("INSERT INTO init_params (key,value) VALUES (?, ?)",
[k, v]);
}
}
}

View File

@ -1,87 +0,0 @@
// Copyright 2007, Google Inc.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// 3. Neither the name of Google Inc. nor the names of its contributors may be
// used to endorse or promote products derived from this software without
// specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// Sets up google.gears.*, which is *the only* supported way to access Gears.
//
// Circumvent this file at your own risk!
//
// In the future, Gears may automatically define google.gears.* without this
// file. Gears may use these objects to transparently fix bugs and compatibility
// issues. Applications that use the code below will continue to work seamlessly
// when that happens.
(function() {
// We are already defined. Hooray!
if (window.google && google.gears) {
return;
}
var factory = null;
// Firefox
if (typeof GearsFactory != 'undefined') {
factory = new GearsFactory();
} else {
// IE
try {
factory = new ActiveXObject('Gears.Factory');
// privateSetGlobalObject is only required and supported on IE Mobile on
// WinCE.
if (factory.getBuildInfo().indexOf('ie_mobile') != -1) {
factory.privateSetGlobalObject(this);
}
} catch (e) {
// Safari
if ((typeof navigator.mimeTypes != 'undefined')
&& navigator.mimeTypes["application/x-googlegears"]) {
factory = document.createElement("object");
factory.style.display = "none";
factory.width = 0;
factory.height = 0;
factory.type = "application/x-googlegears";
document.documentElement.appendChild(factory);
}
}
}
// *Do not* define any objects if Gears is not installed. This mimics the
// behavior of Gears defining the objects in the future.
if (!factory) {
return;
}
// Now set up the objects, being careful not to overwrite anything.
//
// Note: In Internet Explorer for Windows Mobile, you can't add properties to
// the window object. However, global objects are automatically added as
// properties of the window object in all browsers.
if (!window.google) {
google = {};
}
if (!google.gears) {
google.gears = {factory: factory};
}
})();

View File

@ -1,70 +0,0 @@
<?php
header("Content-Type: text/plain");
$manifest_formatted = array();
$manifest_files = array(
"localized_js.php",
"tt-rss.php",
"tt-rss.css",
"viewfeed.js",
"feedlist.js",
"functions.js",
"offline.js",
"tt-rss.js",
"images/blank_icon.gif",
"images/button.png",
"images/c1.png",
"images/c2.png",
"images/c3.png",
"images/c4.png",
"images/archive.png",
"images/cat-collapse.png",
"images/down_arrow.png",
"images/footer.png",
"images/fresh.png",
"images/indicator_white.gif",
"images/label.png",
"images/mark_set.png",
"images/mark_unset.png",
"images/online.png",
"images/overlay.png",
"images/resize_handle_horiz.png",
"images/resize_horiz.png",
"images/resizer.png",
"images/shadow_dark.png",
"images/shadow-grid.gif",
"images/shadow.png",
"images/shadow_white.png",
"images/sign_excl.png",
"images/sign_info.png",
"images/sign_quest.png",
"images/small_question.png",
"images/tag.png",
"images/toolbar.png",
"images/ttrss_logo.png",
"lib/scriptaculous/effects.js",
"lib/scriptaculous/controls.js",
"lib/scriptaculous/dragdrop.js",
"lib/scriptaculous/scriptaculous.js",
"lib/prototype.js",
"gears_init.js");
$mtime_max = 0;
foreach ($manifest_files as $f) {
$tmp = filemtime($f);
if ($tmp > $mtime_max) {
$mtime_max = $tmp;
}
array_push($manifest_formatted, "{ \"url\": \"$f\" }");
}
?>
{
"betaManifestVersion": 1,
"version": "<?php echo date("Y.m.d H:i:s", $mtime_max) ?>",
"entries": [
<?php echo join(",\n ", $manifest_formatted); ?>
]
}

View File

@ -713,220 +713,6 @@
return;
}
if ($subop == "download") {
$stage = (int) $_REQUEST["stage"];
$cidt = (int)db_escape_string($_REQUEST["cidt"]);
$cidb = (int)db_escape_string($_REQUEST["cidb"]);
$sync = db_escape_string($_REQUEST["sync"]);
//$amount = (int) $_REQUEST["amount"];
//$unread_only = db_escape_string($_REQUEST["unread_only"]);
//if (!$amount) $amount = 50;
/* Amount is not used by the frontend offline.js anymore, it goes by
* date_qpart below + cidb/cidt IDs */
$amount = 2000;
$unread_only = true;
print "<rpc-reply>";
$sync = split(";", $sync);
print "<sync>";
if (count($sync) > 0) {
if (strtotime($sync[0])) {
$last_online = db_escape_string($sync[0]);
print "<sync-point><![CDATA[$last_online]]></sync-point>";
for ($i = 1; $i < count($sync); $i++) {
$e = split(",", $sync[$i]);
if (count($e) == 3) {
$id = (int) $e[0];
$unread = bool_to_sql_bool((bool) $e[1]);
$marked = (bool)$e[2];
if ($marked) {
$marked = bool_to_sql_bool($marked);
$marked_qpart = "marked = $marked,";
}
$query = "UPDATE ttrss_user_entries SET
$marked_qpart
unread = $unread,
last_read = '$last_online'
WHERE ref_id = '$id' AND
(last_read IS NULL OR last_read < '$last_online') AND
owner_uid = ".$_SESSION["uid"];
$result = db_query($link, $query);
print "<sync-ok id=\"$id\"/>";
}
}
/* Maybe we need to further update local DB for this client */
$query = "SELECT ref_id,unread,marked FROM ttrss_user_entries
WHERE last_read >= '$last_online' AND
owner_uid = ".$_SESSION["uid"] . " LIMIT 1000";
$result = db_query($link, $query);
while ($line = db_fetch_assoc($result)) {
$unread = (int) sql_bool_to_bool($line["unread"]);
$marked = (int) sql_bool_to_bool($line["marked"]);
print "<sync-ok unread=\"$unread\" marked=\"$marked\"
id=\"".$line["ref_id"]."\"/>";
}
}
}
print "</sync>";
if ($stage == 0) {
print "<feeds>";
$result = db_query($link, "SELECT id, title, cat_id FROM
ttrss_feeds WHERE owner_uid = ".$_SESSION["uid"]);
while ($line = db_fetch_assoc($result)) {
$has_icon = (int) feed_has_icon($line["id"]);
print "<feed has_icon=\"$has_icon\"
cat_id=\"".(int)$line["cat_id"]."\" id=\"".$line["id"]."\"><![CDATA[";
print $line["title"];
print "]]></feed>";
}
print "</feeds>";
print "<feed-categories>";
$result = db_query($link, "SELECT id, title, collapsed FROM
ttrss_feed_categories WHERE owner_uid = ".$_SESSION["uid"]);
print "<category id=\"0\" collapsed=\"".
(int)get_pref($link, "_COLLAPSED_UNCAT")."\"><![CDATA[";
print __("Uncategorized");
print "]]></category>";
print "<category id=\"-1\" collapsed=\"".
(int)get_pref($link, "_COLLAPSED_SPECIAL")."\"><![CDATA[";
print __("Special");
print "]]></category>";
print "<category id=\"-2\" collapsed=\"".
(int)get_pref($link, "_COLLAPSED_LABELS")."\"><![CDATA[";
print __("Labels");
print "]]></category>";
while ($line = db_fetch_assoc($result)) {
print "<category
id=\"".$line["id"]."\"
collapsed=\"".(int)sql_bool_to_bool($line["collapsed"])."\"><![CDATA[";
print $line["title"];
print "]]></category>";
}
print "</feed-categories>";
print "<labels>";
$result = db_query($link, "SELECT * FROM
ttrss_labels2 WHERE owner_uid = ".$_SESSION["uid"]);
while ($line = db_fetch_assoc($result)) {
print "<label
id=\"".$line["id"]."\"
fg_color=\"".$line["fg_color"]."\"
bg_color=\"".$line["bg_color"]."\"
><![CDATA[";
print $line["caption"];
print "]]></label>";
}
print "</labels>";
}
if ($stage > 0) {
print "<articles>";
$limit = 10;
$skip = $limit*($stage-1);
print "<limit value=\"$limit\"/>";
if ($amount > 0) $amount -= $skip;
if ($amount > 0) {
$limit = min($limit, $amount);
if ($unread_only) {
$unread_qpart = "(unread = true OR marked = true) AND ";
}
if ($cidt && $cidb) {
$cid_qpart = "(ttrss_entries.id > $cidt OR ttrss_entries.id < $cidb) AND ";
}
if (DB_TYPE == "pgsql") {
$date_qpart = "updated >= NOW() - INTERVAL '1 week' AND";
} else {
$date_qpart = "updated >= DATE_SUB(NOW(), INTERVAL 1 WEEK) AND";
}
$result = db_query($link,
"SELECT DISTINCT ttrss_entries.id,ttrss_entries.title,
guid,link,comments,
feed_id,content,updated,unread,marked FROM
ttrss_user_entries,ttrss_entries,ttrss_feeds
WHERE $unread_qpart $cid_qpart $date_qpart
ttrss_feeds.id = feed_id AND
ref_id = ttrss_entries.id AND
ttrss_user_entries.owner_uid = ".$_SESSION["uid"]."
ORDER BY updated DESC LIMIT $limit OFFSET $skip");
if (function_exists('json_encode')) {
while ($line = db_fetch_assoc($result)) {
print "<article><![CDATA[";
$line["marked"] = (int)sql_bool_to_bool($line["marked"]);
$line["unread"] = (int)sql_bool_to_bool($line["unread"]);
$line["labels"] = get_article_labels($link, $line["id"]);
// too slow :(
// $line["tags"] = format_tags_string(
// get_article_tags($link, $line["id"]), $line["id"]);
print json_encode($line);
print "]]></article>";
}
}
}
print "</articles>";
}
print "</rpc-reply>";
return;
}
if ($subop == "digest-get-contents") {
$article_id = db_escape_string($_REQUEST['article_id']);

View File

@ -14,7 +14,8 @@
$subop = $_REQUEST["subop"];
$prefs_blacklist = array("HIDE_FEEDLIST", "SYNC_COUNTERS", "ENABLE_LABELS",
"ENABLE_SEARCH_TOOLBAR", "HIDE_READ_FEEDS", "ENABLE_FEED_ICONS");
"ENABLE_SEARCH_TOOLBAR", "HIDE_READ_FEEDS", "ENABLE_FEED_ICONS",
"ENABLE_OFFLINE_READING");
$profile_blacklist = array("ALLOW_DUPLICATE_POSTS", "PURGE_OLD_DAYS",
"PURGE_UNREAD_ARTICLES", "DIGEST_ENABLE", "DIGEST_CATCHUP",

1770
offline.js

File diff suppressed because it is too large Load Diff

View File

@ -11,9 +11,6 @@ var color_picker_active = false;
var selection_disabled = false;
var mouse_is_down = false;
var db = false;
var store = false;
var seq = "";
function feedlist_callback2(transport) {

View File

@ -101,8 +101,6 @@ function updateFeedList() {
try {
//console.log("updateFeedList");
if (offline_mode) return render_offline_feedlist();
var query_str = "backend.php?op=feeds";
if (display_tags) {
@ -241,11 +239,7 @@ function genericSanityCheck() {
}
function init() {
try {
init_gears();
Form.disable("main_toolbar_form");
if (!genericSanityCheck())
@ -378,8 +372,6 @@ function init_second_stage() {
resize_headlines();
enable_offline_reading();
if (has_local_storage())
localStorage.clear();
@ -1226,13 +1218,6 @@ function showFeedsWithErrors() {
function handle_rpc_reply(transport, scheduled_call) {
try {
if (offline_mode) return false;
if (!transport.responseText && db) {
offlineConfirmModeChange();
return false;
}
if (transport.responseXML) {
if (!transport_error_check(transport)) return false;

View File

@ -48,9 +48,7 @@
<script type="text/javascript" charset="utf-8" src="functions.js?<?php echo $dt_add ?>"></script>
<script type="text/javascript" charset="utf-8" src="feedlist.js?<?php echo $dt_add ?>"></script>
<script type="text/javascript" charset="utf-8" src="viewfeed.js?<?php echo $dt_add ?>"></script>
<script type="text/javascript" charset="utf-8" src="offline.js?<?php echo $dt_add ?>"></script>
<script type="text/javascript" src="gears_init.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript">
@ -103,8 +101,6 @@
<div id="header">
<div class="topLinks" id="topLinks">
<span id="topLinksOnline">
<?php if (!SINGLE_USER_MODE) { ?>
<?php echo __('Hello,') ?> <b><?php echo $_SESSION["name"] ?></b> |
<?php } ?>
@ -119,42 +115,12 @@
| <a href="logout.php"><?php echo __('Logout') ?></a>
<?php } ?>
<img id="offlineModePic"
onmouseover="enable_selection(false)"
onmouseout="enable_selection(true)"
onclick="toggleOfflineModeInfo()"
src="images/offline.png" style="display:none"
width="16" height="16"
title="<?php echo __('Offline reading') ?>"/>
<div id="offlineModeDrop" style="display : none">
<div id="offlineModeSyncMsg">---</div>
<div class="showWhenSyncing" style="display : none">
<a href="javascript:offlineDownloadStop()">
<?php echo __('Cancel synchronization') ?></a></div>
<div class="hideWhenSyncing">
<a href="javascript:offlineDownloadStart()">
<?php echo __('Synchronize') ?></a></div>
<div class="hideWhenSyncing"><a href="javascript:offlineClearData()">
<?php echo __('Remove stored data') ?></a></div>
<div><a href="javascript:gotoOffline()">
<?php echo __('Go offline') ?></a></div>
</div>
<img id="newVersionIcon" style="display:none;" onclick="javascript:explainError(2)"
width="13" height="13"
src="<?php echo theme_image($link, 'images/new_version.png') ?>"
title="<?php echo __('New version of Tiny Tiny RSS is available!') ?>"
alt="new_version_icon"/>
</span>
<span id="topLinksOffline" style="display : none">
<img id="restartOnlinePic" src="images/online.png"
height="13" width="13" onclick="gotoOnline()" title="<?php echo __('Go online') ?>"/>
</span>
</div>
<img src="<?php echo theme_image($link, 'images/ttrss_logo.png') ?>" alt="Tiny Tiny RSS"/>

View File

@ -360,10 +360,6 @@ function article_callback2(transport, id) {
// showArticleInHeadlines(id);
if (db) {
db.execute("UPDATE articles SET unread = 0 WHERE id = ?", [id]);
}
var reply = transport.responseXML.firstChild.firstChild;
} else {
@ -392,8 +388,6 @@ function view(id) {
try {
console.log("loading article: " + id);
if (offline_mode) return view_offline(id);
var cached_article = cache_find(id);
console.log("cache check result: " + (cached_article != false));
@ -518,22 +512,12 @@ function toggleMark(id, client_only) {
img.alt = __("Unstar article");
query = query + "&mark=1";
if (db) {
db.execute("UPDATE articles SET marked = 1 WHERE id = ?", [id]);
}
} else {
img.src = img.src.replace("mark_set", "mark_unset");
img.alt = __("Star article");
query = query + "&mark=0";
if (db) {
db.execute("UPDATE articles SET marked = 0 WHERE id = ?", [id]);
}
}
update_local_feedlist_counters();
if (!client_only) {
new Ajax.Request("backend.php", {
parameters: query,
@ -714,11 +698,6 @@ function toggleUnread(id, cmode, effect) {
row.addClassName("Unread");
}
if (db) {
db.execute("UPDATE articles SET unread = not unread "+
"WHERE id = ?", [id]);
}
} else if (cmode == 0) {
row.removeClassName("Unread");
@ -729,23 +708,10 @@ function toggleUnread(id, cmode, effect) {
queue: { position:'end', scope: 'TMRQ-' + id, limit: 1 } } );
}
if (db) {
db.execute("UPDATE articles SET unread = 0 "+
"WHERE id = ?", [id]);
}
} else if (cmode == 1) {
row.addClassName("Unread");
if (db) {
db.execute("UPDATE articles SET unread = 1 "+
"WHERE id = ?", [id]);
}
}
update_local_feedlist_counters();
if (cmode == undefined) cmode = 2;
var query = "?op=rpc&subop=catchupSelected" +
@ -860,36 +826,20 @@ function selectionToggleUnread(set_state, callback_func, no_error) {
} else {
row.addClassName("Unread");
}
if (db) {
db.execute("UPDATE articles SET unread = NOT unread WHERE id = ?",
[rows[i]]);
}
}
if (set_state == false) {
row.removeClassName("Unread");
if (db) {
db.execute("UPDATE articles SET unread = 0 WHERE id = ?",
[rows[i]]);
}
}
if (set_state == true) {
row.addClassName("Unread");
if (db) {
db.execute("UPDATE articles SET unread = 1 WHERE id = ?",
[rows[i]]);
}
}
}
}
if (rows.length > 0) {
update_local_feedlist_counters();
var cmode = "";
if (set_state == undefined) {
@ -932,8 +882,6 @@ function selectionToggleMarked() {
toggleMark(rows[i], true, true);
}
update_local_feedlist_counters();
if (rows.length > 0) {
var query = "?op=rpc&subop=markSelected&ids=" +
@ -1376,28 +1324,21 @@ function cache_inject(id, article, param) {
var date = new Date();
var ts = Math.round(date.getTime() / 1000);
if (db) {
db.execute("INSERT INTO cache (id, article, param, added) VALUES (?, ?, ?, ?)",
[id, article, param, ts]);
} else {
var cache_obj = {};
var cache_obj = {};
cache_obj["id"] = id;
cache_obj["data"] = article;
cache_obj["param"] = param;
cache_obj["id"] = id;
cache_obj["data"] = article;
cache_obj["param"] = param;
if (param) id = id + ":" + param;
if (param) id = id + ":" + param;
cache_added["TS:" + id] = ts;
cache_added["TS:" + id] = ts;
if (has_local_storage())
localStorage.setItem(id, JSON.stringify(cache_obj));
else
article_cache.push(cache_obj);
if (has_local_storage())
localStorage.setItem(id, JSON.stringify(cache_obj));
else
article_cache.push(cache_obj);
}
} else {
//console.log("cache_article: hit: " + id + " [p=" + param + "]");
}
@ -1408,35 +1349,20 @@ function cache_inject(id, article, param) {
function cache_find(id) {
if (db) {
var rs = db.execute("SELECT article FROM cache WHERE id = ?", [id]);
var a = false;
if (has_local_storage()) {
var cache_obj = localStorage.getItem(id);
if (rs.isValidRow()) {
var a = rs.field(0);
if (cache_obj) {
cache_obj = JSON.parse(cache_obj);
if (cache_obj)
return cache_obj['data'];
}
rs.close();
return a;
} else {
if (has_local_storage()) {
var cache_obj = localStorage.getItem(id);
if (cache_obj) {
cache_obj = JSON.parse(cache_obj);
if (cache_obj)
return cache_obj['data'];
}
} else {
for (var i = 0; i < article_cache.length; i++) {
if (article_cache[i]["id"] == id) {
return article_cache[i]["data"];
}
for (var i = 0; i < article_cache.length; i++) {
if (article_cache[i]["id"] == id) {
return article_cache[i]["data"];
}
}
}
@ -1445,69 +1371,38 @@ function cache_find(id) {
function cache_find_param(id, param) {
if (db) {
var rs = db.execute("SELECT article FROM cache WHERE id = ? AND param = ?",
[id, param]);
var a = false;
if (has_local_storage()) {
if (rs.isValidRow()) {
a = rs.field(0);
if (param) id = id + ":" + param;
var cache_obj = localStorage.getItem(id);
if (cache_obj) {
cache_obj = JSON.parse(cache_obj);
if (cache_obj)
return cache_obj['data'];
}
rs.close();
return a;
} else {
if (has_local_storage()) {
if (param) id = id + ":" + param;
var cache_obj = localStorage.getItem(id);
if (cache_obj) {
cache_obj = JSON.parse(cache_obj);
if (cache_obj)
return cache_obj['data'];
}
} else {
for (var i = 0; i < article_cache.length; i++) {
if (article_cache[i]["id"] == id && article_cache[i]["param"] == param) {
return article_cache[i]["data"];
}
for (var i = 0; i < article_cache.length; i++) {
if (article_cache[i]["id"] == id && article_cache[i]["param"] == param) {
return article_cache[i]["data"];
}
}
}
return false;
}
function cache_check(id) {
if (db) {
var rs = db.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ?",
[id]);
var a = false;
if (rs.isValidRow()) {
a = rs.field(0) != "0";
}
rs.close();
return a;
if (has_local_storage()) {
if (localStorage.getItem(id))
return true;
} else {
if (has_local_storage()) {
if (localStorage.getItem(id))
for (var i = 0; i < article_cache.length; i++) {
if (article_cache[i]["id"] == id) {
return true;
} else {
for (var i = 0; i < article_cache.length; i++) {
if (article_cache[i]["id"] == id) {
return true;
}
}
}
}
@ -1515,34 +1410,17 @@ function cache_check(id) {
}
function cache_check_param(id, param) {
if (has_local_storage()) {
if (db) {
var rs = db.execute("SELECT COUNT(*) AS c FROM cache WHERE id = ? AND param = ?",
[id, param]);
var a = false;
if (param) id = id + ":" + param;
if (rs.isValidRow()) {
a = rs.field(0) != "0";
}
rs.close();
return a;
if (localStorage.getItem(id))
return true;
} else {
if (has_local_storage()) {
if (param) id = id + ":" + param;
if (localStorage.getItem(id))
for (var i = 0; i < article_cache.length; i++) {
if (article_cache[i]["id"] == id && article_cache[i]["param"] == param) {
return true;
} else {
for (var i = 0; i < article_cache.length; i++) {
if (article_cache[i]["id"] == id && article_cache[i]["param"] == param) {
return true;
}
}
}
}
@ -1550,42 +1428,29 @@ function cache_check_param(id, param) {
}
function cache_expire() {
if (db) {
if (has_local_storage()) {
var date = new Date();
var ts = Math.round(date.getTime() / 1000);
var timestamp = Math.round(date.getTime() / 1000);
db.execute("DELETE FROM cache WHERE added < ? - 1800 AND id LIKE 'FEEDLIST'", [ts]);
db.execute("DELETE FROM cache WHERE added < ? - 600 AND (id LIKE 'F:%' OR id LIKE 'C:%')", [ts]);
db.execute("DELETE FROM cache WHERE added < ? - 86400", [ts]);
for (var i = 0; i < localStorage.length; i++) {
var id = localStorage.key(i);
if (timestamp - cache_added["TS:" + id] > 180) {
localStorage.removeItem(id);
}
}
} else {
if (has_local_storage()) {
var date = new Date();
var timestamp = Math.round(date.getTime() / 1000);
for (var i = 0; i < localStorage.length; i++) {
var id = localStorage.key(i);
if (timestamp - cache_added["TS:" + id] > 180) {
localStorage.removeItem(id);
}
}
} else {
while (article_cache.length > 25) {
article_cache.shift();
}
while (article_cache.length > 25) {
article_cache.shift();
}
}
}
function cache_flush() {
if (db) {
db.execute("DELETE FROM cache");
} else if (has_local_storage()) {
if (has_local_storage()) {
localStorage.clear();
} else {
article_cache = new Array();
@ -1594,41 +1459,34 @@ function cache_flush() {
function cache_invalidate(id) {
try {
if (has_local_storage()) {
if (db) {
rs = db.execute("DELETE FROM cache WHERE id = ?", [id]);
return rs.rowsAffected != 0;
} else {
var found = false;
if (has_local_storage()) {
var found = false;
for (var i = 0; i < localStorage.length; i++) {
var key = localStorage.key(i);
for (var i = 0; i < localStorage.length; i++) {
var key = localStorage.key(i);
// console.warn("cache_invalidate: " + key_id + " cmp " + id);
if (key == id || key.indexOf(id + ":") == 0) {
localStorage.removeItem(key);
found = true;
break;
}
if (key == id || key.indexOf(id + ":") == 0) {
localStorage.removeItem(key);
found = true;
break;
}
}
return found;
return found;
} else {
var i = 0
} else {
var i = 0
while (i < article_cache.length) {
if (article_cache[i]["id"] == id) {
//console.log("cache_invalidate: removed id " + id);
article_cache.splice(i, 1);
return true;
}
i++;
while (i < article_cache.length) {
if (article_cache[i]["id"] == id) {
//console.log("cache_invalidate: removed id " + id);
article_cache.splice(i, 1);
return true;
}
i++;
}
}