var hotkeys_enabled = true;
var debug_mode_enabled = false;
var xmlhttp_rpc = Ajax.getTransport();
-var hotkey_prefix = false;
-var hotkey_zone = 0;
+var notify_silent = false;
/* add method to remove element from array */
debug("open_article_callback, received link: " + link);
- if (link) {
- debug("link url: " + link.firstChild.nodeValue);
+ if (link && id) {
- var w = window.open(link.firstChild.nodeValue, "_blank");
+ var wname = "ttrss_article_" + id.firstChild.nodeValue;
+
+ debug("link url: " + link.firstChild.nodeValue + ", wname " + wname);
+
+ var w = window.open(link.firstChild.nodeValue, wname);
if (!w) { notify_error("Failed to load article in new window"); }
}
}
+function notify_silent_next() {
+ notify_silent = true;
+}
+
function notify_real(msg, no_hide, n_type) {
+ if (notify_silent) {
+ notify_silent = false;
+ return;
+ }
+
var n = document.getElementById("notify");
var nb = document.getElementById("notify_body");
notify_info("Please wait until operation finishes.");
}
-function hotkey_handler(e) {
-
- try {
-
- var keycode;
- var shift_key = false;
-
- var feedlist = document.getElementById('feedList');
-
- try {
- shift_key = e.shiftKey;
- } catch (e) {
-
- }
-
- if (window.event) {
- keycode = window.event.keyCode;
- } else if (e) {
- keycode = e.which;
- }
-
- if (keycode == 27) { // escape
- if (Element.visible("hotkey_help_overlay")) {
- Element.hide("hotkey_help_overlay");
- }
- hotkey_prefix = false;
- closeInfoBox();
- }
-
- if (!hotkeys_enabled) {
- debug("hotkeys disabled");
- return;
- }
-
- if (keycode == 16) return; // ignore lone shift
-
- if ((keycode == 70 || keycode == 67) && !hotkey_prefix) {
- hotkey_prefix = keycode;
- debug("KP: PREFIX=" + keycode);
- return;
- }
-
- if (Element.visible("hotkey_help_overlay")) {
- Element.hide("hotkey_help_overlay");
- }
-
- /* Global hotkeys */
-
- if (!hotkey_prefix) {
-
- if (keycode == 68 && shift_key) { // d
- if (!debug_mode_enabled) {
- document.getElementById('debug_output').style.display = 'block';
- debug('debug mode activated');
- } else {
- document.getElementById('debug_output').style.display = 'none';
- }
-
- debug_mode_enabled = !debug_mode_enabled;
- return;
- }
-
- if (keycode == 191 && shift_key) { // ?
- if (!Element.visible("hotkey_help_overlay")) {
- Element.show("hotkey_help_overlay");
- } else {
- Element.hide("hotkey_help_overlay");
- }
- return;
- }
-
- if (keycode == 191) { // /
- return displayDlg("search", getActiveFeedId());
- }
-
- if (keycode == 74) { // j
- var feed = getActiveFeedId();
- var new_feed = getRelativeFeedId(feedlist, feed, 'prev');
- if (new_feed) viewfeed(new_feed, '');
- return;
- }
-
- if (keycode == 75) { // k
- var feed = getActiveFeedId();
- var new_feed = getRelativeFeedId(feedlist, feed, 'next');
- if (new_feed) viewfeed(new_feed, '');
- return;
- }
-
- if (keycode == 78 || keycode == 40) { // n, down
- if (typeof moveToPost != 'undefined') {
- return moveToPost('next');
- }
- }
-
- if (keycode == 80 || keycode == 38) { // p, up
- if (typeof moveToPost != 'undefined') {
- return moveToPost('prev');
- }
- }
-
- if (keycode == 83 && shift_key) { // S
- var id = getActiveArticleId();
- if (id) {
- togglePub(id);
- }
- return;
- }
-
- if (keycode == 83) { // s
- var id = getActiveArticleId();
- if (id) {
- toggleMark(id);
- }
- return;
- }
-
-
- if (keycode == 85) { // u
- var id = getActiveArticleId();
- if (id) {
- toggleUnread(id);
- }
- return;
- }
-
- if (keycode == 84) { // t
- /* FIXME: edit tags */
- return notify_error("Function not implemented");
- }
-
- if (keycode == 84) { // t
- /* FIXME: edit tags */
- return notify_error("Function not implemented");
- }
-
- if (keycode == 79) { // o
- if (getActiveArticleId()) {
- openArticleInNewWindow(getActiveArticleId());
- }
- }
-
- }
-
- /* Prefix f */
-
- if (hotkey_prefix == 70) { // f
-
- hotkey_prefix = false;
-
- if (keycode == 65) { // a
- return toggleDispRead();
- }
-
- if (keycode == 85 && shift_key) { // r
- return scheduleFeedUpdate(true);
- }
-
- if (keycode == 85) { // u
- if (getActiveFeedId()) {
- return viewfeed(getActiveFeedId(), "ForceUpdate");
- }
- }
-
- if (keycode == 69) { // e
- return editFeedDlg(getActiveFeedId());
- }
-
- if (keycode == 83) { // s
- return displayDlg("quickAddFeed");
- }
-
- if (keycode == 67 && shift_key) { // C
- if (typeof catchupAllFeeds != 'undefined') {
- return catchupAllFeeds();
- }
- }
-
- if (keycode == 67) { // c
- if (getActiveFeedId()) {
- return catchupCurrentFeed();
- }
- }
-
- }
-
- /* Prefix c */
-
- if (hotkey_prefix == 67) { // c
- hotkey_prefix = false;
-
- if (keycode == 70) { // f
- return displayDlg("quickAddFilter", getActiveFeedId());
- }
-
- if (keycode == 83) { // s
- if (typeof collapse_feedlist != 'undefined') {
- return collapse_feedlist();
- }
- }
-
- }
-/*
- if (keycode == 48) { // 0
- return setHotkeyZone(0);
- }
-
- if (keycode == 49) { // 1
- return setHotkeyZone(1);
- }
-
- if (keycode == 50) { // 2
- return setHotkeyZone(2);
- }
-
- if (keycode == 51) { // 3
- return setHotkeyZone(3);
- }
-
- if (keycode == 82) { // r
- return scheduleFeedUpdate(true);
- }
-
- if (keycode == 83) { // s
- return displayDlg("search", getActiveFeedId());
- }
-
- if (keycode == 85) { // u
- if (getActiveFeedId()) {
- return viewfeed(getActiveFeedId(), "ForceUpdate");
- }
- }
-
- if (keycode == 65) { // a
- return toggleDispRead();
- }
-
- var feedlist = document.getElementById('feedList');
-
- if (keycode == 74) { // j
- var feed = getActiveFeedId();
- var new_feed = getRelativeFeedId(feedlist, feed, 'prev');
- if (new_feed) viewfeed(new_feed, '');
- }
-
- if (keycode == 75) { // k
- var feed = getActiveFeedId();
- var new_feed = getRelativeFeedId(feedlist, feed, 'next');
- if (new_feed) viewfeed(new_feed, '');
- }
-
- if (shift_key && (keycode == 78 || keycode == 40)) { // shift - n, down
- return catchupRelativeToArticle(1);
- }
-
- if (shift_key && (keycode == 80 || keycode == 38)) { // shift - p, up
- return catchupRelativeToArticle(0);
- }
-
- if (keycode == 78 || keycode == 40) { // n, down
- if (typeof moveToPost != 'undefined') {
- return moveToPost('next');
- }
- }
-
- if (keycode == 80 || keycode == 38) { // p, up
- if (typeof moveToPost != 'undefined') {
- return moveToPost('prev');
- }
- }
-
- if (keycode == 68 && shift_key) { // d
- if (!debug_mode_enabled) {
- document.getElementById('debug_output').style.display = 'block';
- debug('debug mode activated');
- } else {
- document.getElementById('debug_output').style.display = 'none';
- }
-
- debug_mode_enabled = !debug_mode_enabled;
- }
-
- if (keycode == 191 && shift_key) { // ?
- if (!Element.visible("hotkey_help_overlay")) {
- Element.show("hotkey_help_overlay");
- } else {
- Element.hide("hotkey_help_overlay");
- }
- }
-
- if (keycode == 69 && shift_key) { // e
- return editFeedDlg(getActiveFeedId());
- }
-
- if (keycode == 70 && shift_key) { // f
- if (getActiveFeedId()) {
- return catchupCurrentFeed();
- }
- }
-
- if (keycode == 80 && shift_key) { // p
- if (getActiveFeedId()) {
- return catchupPage();
- }
- }
-
- if (keycode == 86) { // v
- if (getActiveArticleId()) {
- openArticleInNewWindow(getActiveArticleId());
- }
- }
-
- if (keycode == 84) { // t
-
- var id = getActiveArticleId();
-
- if (id) {
-
- var cb = document.getElementById("RCHK-" + id);
-
- if (cb) {
- cb.checked = !cb.checked;
- toggleSelectRowById(cb, "RROW-" + id);
- }
- }
- }
-
- if (keycode == 67) { // c
- var id = getActiveArticleId();
-
- if (id) {
- toggleUnread(id, 0);
- }
- }
-
- if (keycode == 67 && shift_key) { // c
- if (typeof collapse_feedlist != 'undefined') {
- return collapse_feedlist();
- }
- }
-
- if (keycode == 81 && shift_key) { // shift + q
- if (typeof catchupAllFeeds != 'undefined') {
- return catchupAllFeeds();
- }
- }
-
- if (keycode == 73 && shift_key) { // shift + i
- if (document.getElementById("subtoolbar_search")) {
- if (Element.visible("subtoolbar_search")) {
- Element.hide("subtoolbar_search");
- Element.show("subtoolbar_ftitle");
- setTimeout("Element.focus('subtoolbar_search_box')", 100);
- } else {
- Element.show("subtoolbar_search");
- Element.hide("subtoolbar_ftitle");
- }
- }
- }
-
- if (keycode == 27) { // escape
- if (Element.visible("hotkey_help_overlay")) {
- Element.hide("hotkey_help_overlay");
- }
- } */
-
- if (typeof localHotkeyHandler != 'undefined') {
- try {
- return localHotkeyHandler(e);
- } catch (e) {
- exception_error("hotkey_handler, local:", e);
- }
- }
-
- if (hotkey_prefix) {
- debug("KP: PREFIX=" + hotkey_prefix + " CODE=" + keycode);
-
- } else {
- debug("KP: CODE=" + keycode);
- }
-
-
- } catch (e) {
- exception_error("hotkey_handler", e);
- }
-}
-
function cleanSelectedList(element) {
var content = document.getElementById(element);
}
function getFirstVisibleHeadlineId() {
- var rows = getVisibleHeadlineIds();
- return rows[0];
+ if (isCdmMode()) {
+ var rows = cdmGetVisibleArticles();
+ return rows[0];
+ } else {
+ var rows = getVisibleHeadlineIds();
+ return rows[0];
+ }
}
function getLastVisibleHeadlineId() {
- var rows = getVisibleHeadlineIds();
- return rows[rows.length-1];
+ if (isCdmMode()) {
+ var rows = cdmGetVisibleArticles();
+ return rows[rows.length-1];
+ } else {
+ var rows = getVisibleHeadlineIds();
+ return rows[rows.length-1];
+ }
}
function markHeadline(id) {
try {
// called from prefs, reload tab
- if (active_tab) {
+ if (typeof active_tab != 'undefined' && active_tab) {
selectTab(active_tab, false);
}
} catch (e) { }
{ tokens: ',', paramName: "search" });
}
+ disableHotkeys();
+
notify("");
} catch (e) {
exception_error("infobox_callback2", e);
function createFilter() {
- var form = document.forms['filter_add_form'];
- var reg_exp = form.reg_exp.value;
-
- if (reg_exp == "") {
- alert(__("Can't add filter: nothing to match on."));
- return false;
- }
-
- var query = Form.serialize("filter_add_form");
+ try {
- new Ajax.Request("backend.php?" + query, {
- onComplete: function (transport) {
- infobox_submit_callback2(transport);
- } });
+ var form = document.forms['filter_add_form'];
+ var reg_exp = form.reg_exp.value;
- return true;
+ if (reg_exp == "") {
+ alert(__("Can't add filter: nothing to match on."));
+ return false;
+ }
+
+ var query = Form.serialize("filter_add_form");
+
+ // we can be called from some other tab in Prefs
+ if (typeof active_tab != 'undefined' && active_tab) {
+ active_tab = "filterConfig";
+ }
+
+ new Ajax.Request("backend.php?" + query, {
+ onComplete: function (transport) {
+ infobox_submit_callback2(transport);
+ } });
+
+ return true;
+
+ } catch (e) {
+ exception_error("createFilter", e);
+ }
}
function toggleSubmitNotEmpty(e, submit_id) {
}
} catch (e) {
- exception_error(e, "filterDlgCheckAction");
+ exception_error("filterDlgCheckAction", e);
}
}
}
// this only searches loaded headlines list, not in CDM
-function getRelativePostIds(id) {
+function getRelativePostIds(id, limit) {
- debug("getRelativePostIds: " + id);
+ if (!limit) limit = 3;
+
+ debug("getRelativePostIds: " + id + " limit=" + limit);
var ids = new Array();
var container = document.getElementById("headlinesList");
var r_id = rows[i].id.replace("RROW-", "");
if (r_id == id) {
- if (i > 0) ids.push(rows[i-1].id.replace("RROW-", ""));
+/* if (i > 0) ids.push(rows[i-1].id.replace("RROW-", ""));
if (i > 1) ids.push(rows[i-2].id.replace("RROW-", ""));
if (i > 2) ids.push(rows[i-3].id.replace("RROW-", ""));
if (i < rows.length-1) ids.push(rows[i+1].id.replace("RROW-", ""));
if (i < rows.length-2) ids.push(rows[i+2].id.replace("RROW-", ""));
- if (i < rows.length-3) ids.push(rows[i+3].id.replace("RROW-", ""));
+ if (i < rows.length-3) ids.push(rows[i+3].id.replace("RROW-", "")); */
+
+ for (var k = 1; k <= limit; k++) {
+ var nid = false;
+
+ if (i > k-1) var nid = rows[i-k].id.replace("RROW-", "");
+ if (nid) ids.push(nid);
+
+ if (i < rows.length-k) nid = rows[i+k].id.replace("RROW-", "");
+ if (nid) ids.push(nid);
+ }
return ids;
}
debug("openArticleInNewWindow: " + id);
var query = "backend.php?op=rpc&subop=getArticleLink&id=" + id;
+ var wname = "ttrss_article_" + id;
+
+ debug(query + " " + wname);
- debug(query);
+ var w = window.open("", wname);
+
+ if (!w) notify_error("Failed to open window for the article");
new Ajax.Request(query, {
onComplete: function(transport) {
return false;
}
-var _border_color_normal = "#88b0f0";
-var _border_color_highlight = "#72eda8";
-var _border_color_flash = "#f0fff0";
-
-function highlightHotkeyZone(zone) {
+function focus_element(id) {
try {
- var feeds = document.getElementById("feeds-holder");
- var headlines = document.getElementById("headlines-frame");
- var content = document.getElementById("content-frame");
-
- feeds.style.borderColor = _border_color_normal;
- headlines.style.borderColor = _border_color_normal;
- content.style.borderColor = _border_color_normal;
-
- if (zone == 1) {
- feeds.style.borderColor = _border_color_highlight;
-
- new Effect.Highlight(feeds, {duration: 0.5, startcolor:
- _border_color_flash,
- queue: { position:'end', scope: 'EFCHL-Q', limit: 1 } } );
- }
-
- if (zone == 2) {
- headlines.style.borderColor = _border_color_highlight;
-
- new Effect.Highlight(headlines, {duration: 0.5, startcolor:
- _border_color_flash,
- queue: { position:'end', scope: 'EFCHL-Q', limit: 1 } } );
- }
-
- if (zone == 3 && content) {
- content.style.borderColor = _border_color_highlight;
-
- new Effect.Highlight(content, {duration: 0.5, startcolor:
- _border_color_flash,
- queue: { position:'end', scope: 'EFCHL-Q', limit: 1 } } );
- }
-
+ var e = document.getElementById(id);
+ if (e) e.focus();
} catch (e) {
- exception_error("highlightHotkeyZone", e);
+ exception_error("focus_element", e);
}
+ return false;
}
-
-function setHotkeyZone(zone) {
+function loading_set_progress(v) {
try {
- hotkey_zone = zone;
-
- highlightHotkeyZone(zone);
-
+ var o = document.getElementById("l_progress_i");
+ o.style.width = (v*2) + "px";
} catch (e) {
- exception_error("setHotkeyZone", e);
+ exception_error("loading_set_progress", e);
}
}
-