-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() {
var tmp = "Tiny Tiny RSS";
if (global_unread > 0) {
- tmp = tmp + " (" + global_unread + ")";
+ tmp = "(" + global_unread + ") " + tmp;
}
if (window.fluid) {
dojo.require("fox.FeedTree");
- if (typeof themeBeforeLayout == 'function') {
- themeBeforeLayout();
- }
-
dojo.require("dijit.ColorPalette");
dojo.require("dijit.Dialog");
dojo.require("dijit.form.Button");
loading_set_progress(20);
var hasAudio = !!((myAudioTag = document.createElement('audio')).canPlayType);
+ var hasSandbox = "sandbox" in document.createElement("iframe");
new Ajax.Request("backend.php", {
- parameters: {op: "rpc", method: "sanityCheck", hasAudio: hasAudio},
+ parameters: {op: "rpc", method: "sanityCheck", hasAudio: hasAudio,
+ hasSandbox: hasSandbox},
onComplete: function(transport) {
backend_sanity_check_callback(transport);
} });
switchPanelMode(_widescreen_mode);
}
- if (typeof themeAfterLayout == 'function') {
- themeAfterLayout();
- }
-
});
delCookie("ttrss_test");
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;
}
+ if (k == "dep_ts" && parseInt(getInitParam("dep_ts")) > 0) {
+ if (parseInt(getInitParam("dep_ts")) < parseInt(v)) {
+ window.location.reload();
+ }
+ }
+
if (k == "daemon_is_running" && v != 1) {
notify_error("<span onclick=\"javascript:explainError(1)\">Update daemon is not running.</span>", true);
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();
if (keycode == 16) return; // ignore lone shift
if (keycode == 17) return; // ignore lone ctrl
- if (!shift_key) keychar = keychar.toLowerCase();
+ keychar = keychar.toLowerCase();
var hotkeys = getInitParam("hotkeys");
Element.hide(cmdline);
var hotkey = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")";
+
+ // ensure ^*char notation
+ if (shift_key) hotkey = "*" + hotkey;
if (ctrl_key) hotkey = "^" + hotkey;
+
hotkey = hotkey_prefix ? hotkey_prefix + " " + hotkey : hotkey;
hotkey_prefix = false;
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 ;
catchupRelativeToArticle(0);
return false;
case "article_scroll_down":
- scrollArticle(50);
+ var ctr = $("content_insert") ? $("content_insert") : $("headlines-frame");
+
+ scrollArticle(ctr.offsetHeight/3);
return false;
case "article_scroll_up":
- scrollArticle(-50);
+ var ctr = $("content_insert") ? $("content_insert") : $("headlines-frame");
+
+ scrollArticle(-ctr.offsetHeight/3);
return false;
case "close_article":
- closeArticlePanel();
+ if (isCdmMode()) {
+ if (!getInitParam("cdm_expanded")) {
+ cdmCollapseArticle(false, getActiveArticleId());
+ } else {
+ dismissArticle(getActiveArticleId());
+ }
+ } else {
+ closeArticlePanel();
+ }
return false;
case "email_article":
if (typeof emailArticle != "undefined") {
emailArticle();
+ } else if (typeof mailtoArticle != "undefined") {
+ mailtoArticle();
} else {
alert(__("Please enable mail plugin first."));
}
case "collapse_sidebar":
collapse_feedlist();
return false;
+ case "toggle_embed_original":
+ if (typeof embedOriginalArticle != "undefined") {
+ if (getActiveArticleId())
+ embedOriginalArticle(getActiveArticleId());
+ } else {
+ alert(__("Please enable embed_original plugin first."));
+ }
+ return false;
case "toggle_widescreen":
if (!isCdmMode()) {
_widescreen_mode = !_widescreen_mode;
return false;
case "help_dialog":
helpDialog("main");
+ return false;
+ case "toggle_combined_mode":
+ notify_progress("Loading, please wait...");
+
+ var value = isCdmMode() ? "false" : "true";
+ var query = "?op=rpc&method=setpref&key=COMBINED_DISPLAY_MODE&value=" + value;
+
+ new Ajax.Request("backend.php", {
+ parameters: query,
+ onComplete: function(transport) {
+ window.location.reload();
+ } });
+
return false;
default:
console.log("unhandled action: " + hotkey_action + "; hotkey: " + hotkey);
if (message == "UPDATE_COUNTERS") {
console.log("need to refresh counters...");
setInitParam("last_article_id", -1);
- _force_scheduled_update = true;
+ request_counters(true);
}
}
if (runtime_info)
parse_runtime_info(runtime_info);
- 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);
function switchPanelMode(wide) {
try {
+ if (isCdmMode()) return;
+
article_id = getActiveArticleId();
if (wide) {
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);
+ }
+}