-var total_unread = 0;
var global_unread = -1;
-var firsttime_update = true;
-var _active_feed_id = undefined;
-var _active_feed_is_cat = false;
var hotkey_prefix = false;
var hotkey_prefix_pressed = false;
-var _force_scheduled_update = false;
-var last_scheduled_update = false;
var _widescreen_mode = false;
-
var _rpc_seq = 0;
+var _active_feed_id = 0;
+var _active_feed_is_cat = false;
function next_seq() {
_rpc_seq += 1;
function getActiveFeedId() {
try {
- //console.log("gAFID: " + _active_feed_id);
return _active_feed_id;
} catch (e) {
exception_error("getActiveFeedId", e);
function setActiveFeedId(id, is_cat) {
try {
- _active_feed_id = id;
+ hash_set('f', id);
+ hash_set('c', is_cat ? 1 : 0);
- if (is_cat != undefined) {
- _active_feed_is_cat = is_cat;
- }
+ _active_feed_id = id;
+ _active_feed_is_cat = is_cat;
selectFeed(id, is_cat);
} catch (e) {
});
var tree = new fox.FeedTree({
- persist: false,
model: treeModel,
- onOpen: function (item, node) {
- var id = String(item.id);
- var cat_id = id.substr(id.indexOf(":")+1);
-
- new Ajax.Request("backend.php",
- { parameters: "backend.php?op=feeds&method=collapse&cid=" +
- param_escape(cat_id) + "&mode=0" } );
- },
- onClose: function (item, node) {
- var id = String(item.id);
- var cat_id = id.substr(id.indexOf(":")+1);
-
- new Ajax.Request("backend.php",
- { parameters: "backend.php?op=feeds&method=collapse&cid=" +
- param_escape(cat_id) + "&mode=1" } );
-
- },
onClick: function (item, node) {
var id = String(item.id);
var is_cat = id.match("^CAT:");
id: "feedTree",
}, "feedTree");
- _force_scheduled_update = true;
-
/* var menu = new dijit.Menu({id: 'feedMenu'});
menu.addChild(new dijit.MenuItem({
dojo.disconnect(tmph);
Element.hide("feedlistLoading");
- tree.collapseHiddenCats();
-
feedlist_init();
// var node = dijit.byId("feedTree")._itemNodesMap['FEED:-2'][0].domNode
}
function timeout() {
- if (getInitParam("bw_limit") == "1") return;
-
- try {
- var date = new Date();
- var ts = Math.round(date.getTime() / 1000);
-
- if (ts - last_scheduled_update > 10 || _force_scheduled_update) {
-
- //console.log("timeout()");
-
- window.clearTimeout(counter_timeout_id);
-
- var query_str = "?op=rpc&method=getAllCounters&seq=" + next_seq();
-
- var omode;
-
- if (firsttime_update && !navigator.userAgent.match("Opera")) {
- firsttime_update = false;
- omode = "T";
- } else {
- omode = "flc";
- }
-
- query_str = query_str + "&omode=" + omode;
-
- if (!_force_scheduled_update)
- query_str = query_str + "&last_article_id=" + getInitParam("last_article_id");
-
- //console.log("[timeout]" + query_str);
-
- new Ajax.Request("backend.php", {
- parameters: query_str,
- onComplete: function(transport) {
- handle_rpc_json(transport, !_force_scheduled_update);
- _force_scheduled_update = false;
- } });
-
- last_scheduled_update = ts;
- }
-
- } catch (e) {
- exception_error("timeout", e);
+ if (getInitParam("bw_limit") != "1") {
+ request_counters();
+ setTimeout("timeout()", 60*1000);
}
-
- setTimeout("timeout()", 3000);
}
function search() {
feeds_sort_by_unread = getInitParam("feeds_sort_by_unread") == 1;
+ var hash_feed_id = hash_get('f');
+ var hash_feed_is_cat = hash_get('c') == "1";
+
+ if (hash_feed_id != undefined) {
+ setActiveFeedId(hash_feed_id, hash_feed_is_cat);
+ }
+
loading_set_progress(30);
// can't use cache_clear() here because viewfeed might not have initialized yet
function quickMenuGo(opid) {
try {
- if (opid == "qmcPrefs") {
+ switch (opid) {
+ case "qmcPrefs":
gotoPreferences();
- }
-
- if (opid == "qmcTagCloud") {
+ break;
+ case "qmcLogout":
+ gotoLogout();
+ break;
+ case "qmcTagCloud":
displayDlg("printTagCloud");
- }
-
- if (opid == "qmcTagSelect") {
+ break;
+ case "qmcTagSelect":
displayDlg("printTagSelect");
- }
-
- if (opid == "qmcSearch") {
+ break;
+ case "qmcSearch":
search();
- return;
- }
-
- if (opid == "qmcAddFeed") {
+ break;
+ case "qmcAddFeed":
quickAddFeed();
- return;
- }
-
- if (opid == "qmcDigest") {
+ break;
+ case "qmcDigest":
window.location.href = "backend.php?op=digest";
- return;
- }
-
- if (opid == "qmcEditFeed") {
+ break;
+ case "qmcEditFeed":
if (activeFeedIsCat())
alert(__("You can't edit this kind of feed."));
else
editFeed(getActiveFeedId());
- return;
- }
-
- if (opid == "qmcRemoveFeed") {
+ break;
+ case "qmcRemoveFeed":
var actid = getActiveFeedId();
if (activeFeedIsCat()) {
if (confirm(pr)) {
unsubscribeFeed(actid);
}
-
- return;
- }
-
- if (opid == "qmcCatchupAll") {
+ break;
+ case "qmcCatchupAll":
catchupAllFeeds();
- return;
- }
-
- if (opid == "qmcShowOnlyUnread") {
+ break;
+ case "qmcShowOnlyUnread":
toggleDispRead();
- return;
- }
-
- if (opid == "qmcAddFilter") {
+ break;
+ case "qmcAddFilter":
quickAddFilter();
- return;
- }
-
- if (opid == "qmcAddLabel") {
+ break;
+ case "qmcAddLabel":
addLabel();
- return;
- }
-
- if (opid == "qmcRescoreFeed") {
+ break;
+ case "qmcRescoreFeed":
rescoreCurrentFeed();
- return;
- }
-
- if (opid == "qmcToggleWidescreen") {
+ break;
+ case "qmcToggleWidescreen":
if (!isCdmMode()) {
_widescreen_mode = !_widescreen_mode;
switchPanelMode(_widescreen_mode);
}
- return;
- }
-
- if (opid == "qmcHKhelp") {
+ break;
+ case "qmcHKhelp":
helpDialog("main");
+ break;
+ default:
+ console.log("quickMenuGo: unknown action: " + opid);
}
} catch (e) {
// console.log("RI: " + k + " => " + v);
if (k == "new_version_available") {
- var icon = $("newVersionIcon");
- if (icon) {
- if (v == "1") {
- icon.style.display = "inline";
- } else {
- icon.style.display = "none";
- }
+ if (v == "1") {
+ Element.show(dijit.byId("newVersionIcon").domNode);
+ } else {
+ Element.hide(dijit.byId("newVersionIcon").domNode);
}
return;
}
return viewCurrentFeed('');
}
-/* function adjustArticleScore(id, score) {
- try {
-
- var pr = prompt(__("Assign score to article:"), score);
-
- if (pr != undefined) {
- var query = "?op=rpc&method=setScore&id=" + id + "&score=" + pr;
-
- new Ajax.Request("backend.php", {
- parameters: query,
- onComplete: function(transport) {
- viewCurrentFeed();
- } });
-
- }
- } catch (e) {
- exception_error("adjustArticleScore", e);
- }
-} */
-
function rescoreCurrentFeed() {
var actid = getActiveFeedId();
case "prev_article":
moveToPost('prev');
return false;
+ case "next_article_noscroll":
+ moveToPost('next', true);
+ return false;
+ case "prev_article_noscroll":
+ moveToPost('prev', true);
+ return false;
case "search_dialog":
search();
return ;
if (message == "UPDATE_COUNTERS") {
console.log("need to refresh counters...");
setInitParam("last_article_id", -1);
- _force_scheduled_update = true;
+ request_counters(true);
}
}
hideOrShowFeeds(getInitParam("hide_read_feeds") == 1);
- Element.hide("net-alert");
+ Element.hide(dijit.byId("net-alert").domNode);
} else {
//notify_error("Error communicating with server.");
- Element.show("net-alert");
+ Element.show(dijit.byId("net-alert").domNode);
}
} catch (e) {
- Element.show("net-alert");
+ Element.show(dijit.byId("net-alert").domNode);
//notify_error("Error communicating with server.");
console.log(e);
//exception_error("handle_rpc_json", e, transport);
dijit.byId("content-insert").domNode.setStyle({width: '50%',
height: 'auto',
+ borderLeftWidth: '1px',
+ borderLeftColor: '#c0c0c0',
borderTopWidth: '0px' });
$("headlines-toolbar").setStyle({ borderBottomWidth: '0px' });
dijit.byId("content-insert").domNode.setStyle({width: 'auto',
height: '50%',
- borderTopWidthidth: '1px'});
+ borderLeftWidth: '0px',
+ borderTopWidth: '1px'});
$("headlines-toolbar").setStyle({ borderBottomWidth: '1px' });
}
exception_error("update_random_feed", e);
}
}
+
+function hash_get(key) {
+ try {
+ kv = window.location.hash.substring(1).toQueryParams();
+ return kv[key];
+ } catch (e) {
+ exception_error("hash_set", e);
+ }
+}
+function hash_set(key, value) {
+ try {
+ kv = window.location.hash.substring(1).toQueryParams();
+ kv[key] = value;
+ window.location.hash = $H(kv).toQueryString();
+ } catch (e) {
+ exception_error("hash_set", e);
+ }
+}