Article, Headlines: shorten several method names

master
Andrew Dolgov 6 years ago
parent d8ac5474ec
commit 3678315bea

@ -727,7 +727,7 @@ class Article extends Handler_Protected {
if (!$zoom_mode) { if (!$zoom_mode) {
$rv['content'] .= "<span id=\"ATSTR-$id\">$tags_str</span> $rv['content'] .= "<span id=\"ATSTR-$id\">$tags_str</span>
<a title=\"".__('Edit tags for this article')."\" <a title=\"".__('Edit tags for this article')."\"
href=\"#\" onclick=\"Article.editArticleTags($id, $feed_id)\">(+)</a>"; href=\"#\" onclick=\"Article.editTags($id)\">(+)</a>";
$rv['content'] .= "<div dojoType=\"dijit.Tooltip\" $rv['content'] .= "<div dojoType=\"dijit.Tooltip\"
id=\"ATSTRTIP-$id\" connectId=\"ATSTR-$id\" id=\"ATSTRTIP-$id\" connectId=\"ATSTR-$id\"

@ -29,7 +29,7 @@ class Feeds extends Handler_Protected {
$tog_marked_link = "Headlines.selectionToggleMarked()"; $tog_marked_link = "Headlines.selectionToggleMarked()";
$tog_published_link = "Headlines.selectionTogglePublished()"; $tog_published_link = "Headlines.selectionTogglePublished()";
$set_score_link = "Article.setSelectionScore()"; $set_score_link = "Article.selectionSetScore()";
if ($is_cat) $cat_q = "&is_cat=$is_cat"; if ($is_cat) $cat_q = "&is_cat=$is_cat";
@ -345,7 +345,7 @@ class Feeds extends Handler_Protected {
$score_pic = "images/" . get_score_pic($score); $score_pic = "images/" . get_score_pic($score);
$score_pic = "<img class='score-pic' score='$score' onclick='Article.changeScore($id, this)' src=\"$score_pic\" $score_pic = "<img class='score-pic' score='$score' onclick='Article.setScore($id, this)' src=\"$score_pic\"
title=\"$score\">"; title=\"$score\">";
if ($score > 500) { if ($score > 500) {

@ -212,7 +212,7 @@ const Feeds = {
Utils.setLoadingProgress(50); Utils.setLoadingProgress(50);
document.onkeydown = () => { App.hotkeyHandler(event) }; document.onkeydown = () => { App.hotkeyHandler(event) };
window.setInterval(() => { Headlines.catchupBatchedArticles() }, 10 * 1000); window.setInterval(() => { Headlines.catchupBatched() }, 10 * 1000);
if (!this.getActiveFeedId()) { if (!this.getActiveFeedId()) {
this.viewfeed({feed: -3}); this.viewfeed({feed: -3});
@ -304,7 +304,7 @@ const Feeds = {
if (feed != this.getActiveFeedId() || this.activeFeedIsCat() != is_cat) { if (feed != this.getActiveFeedId() || this.activeFeedIsCat() != is_cat) {
this._search_query = false; this._search_query = false;
Article.setActiveArticleId(0); Article.setActive(0);
} }
if (offset != 0) { if (offset != 0) {
@ -371,7 +371,7 @@ const Feeds = {
window.clearTimeout(this._viewfeed_wait_timeout); window.clearTimeout(this._viewfeed_wait_timeout);
this._viewfeed_wait_timeout = window.setTimeout(() => { this._viewfeed_wait_timeout = window.setTimeout(() => {
Headlines.catchupBatchedArticles(() => { Headlines.catchupBatched(() => {
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
try { try {
window.clearTimeout(this._infscroll_timeout); window.clearTimeout(this._infscroll_timeout);
@ -494,7 +494,7 @@ const Feeds = {
rows.each(function (row) { rows.each(function (row) {
row.removeClassName("Unread"); row.removeClassName("Unread");
if (row.getAttribute("data-article-id") != Article.getActiveArticleId()) { if (row.getAttribute("data-article-id") != Article.getActive()) {
new Effect.Fade(row, {duration: 0.5}); new Effect.Fade(row, {duration: 0.5});
} }

@ -1454,7 +1454,7 @@ const Filters = {
} else { } else {
const query = {op: "rpc", method: "getlinktitlebyid", id: Article.getActiveArticleId()}; const query = {op: "rpc", method: "getlinktitlebyid", id: Article.getActive()};
xhrPost("backend.php", query, (transport) => { xhrPost("backend.php", query, (transport) => {
const reply = JSON.parse(transport.responseText); const reply = JSON.parse(transport.responseText);

@ -90,7 +90,7 @@ const App = {
}, },
initSecondStage: function () { initSecondStage: function () {
Feeds.reload(); Feeds.reload();
Article.closeArticlePanel(); Article.close();
if (parseInt(getCookie("ttrss_fh_width")) > 0) { if (parseInt(getCookie("ttrss_fh_width")) > 0) {
dijit.byId("feeds-holder").domNode.setStyle( dijit.byId("feeds-holder").domNode.setStyle(
@ -190,7 +190,7 @@ const App = {
switchPanelMode: function(wide) { switchPanelMode: function(wide) {
if (App.isCombinedMode()) return; if (App.isCombinedMode()) return;
const article_id = Article.getActiveArticleId(); const article_id = Article.getActive();
if (wide) { if (wide) {
dijit.byId("headlines-wrap-inner").attr("design", 'sidebar'); dijit.byId("headlines-wrap-inner").attr("design", 'sidebar');
@ -226,7 +226,7 @@ const App = {
} }
Article.closeArticlePanel(); Article.close();
if (article_id) Article.view(article_id); if (article_id) Article.view(article_id);
@ -246,22 +246,22 @@ const App = {
if (rv) Feeds.viewfeed({feed: rv[0], is_cat: rv[1], delayed: true}) if (rv) Feeds.viewfeed({feed: rv[0], is_cat: rv[1], delayed: true})
}; };
this.hotkey_actions["next_article"] = function () { this.hotkey_actions["next_article"] = function () {
Headlines.moveToPost('next'); Headlines.move('next');
}; };
this.hotkey_actions["prev_article"] = function () { this.hotkey_actions["prev_article"] = function () {
Headlines.moveToPost('prev'); Headlines.move('prev');
}; };
this.hotkey_actions["next_article_noscroll"] = function () { this.hotkey_actions["next_article_noscroll"] = function () {
Headlines.moveToPost('next', true); Headlines.move('next', true);
}; };
this.hotkey_actions["prev_article_noscroll"] = function () { this.hotkey_actions["prev_article_noscroll"] = function () {
Headlines.moveToPost('prev', true); Headlines.move('prev', true);
}; };
this.hotkey_actions["next_article_noexpand"] = function () { this.hotkey_actions["next_article_noexpand"] = function () {
Headlines.moveToPost('next', true, true); Headlines.move('next', true, true);
}; };
this.hotkey_actions["prev_article_noexpand"] = function () { this.hotkey_actions["prev_article_noexpand"] = function () {
Headlines.moveToPost('prev', true, true); Headlines.move('prev', true, true);
}; };
this.hotkey_actions["search_dialog"] = function () { this.hotkey_actions["search_dialog"] = function () {
Feeds.search(); Feeds.search();
@ -276,33 +276,33 @@ const App = {
Headlines.selectionToggleUnread({no_error: 1}); Headlines.selectionToggleUnread({no_error: 1});
}; };
this.hotkey_actions["edit_tags"] = function () { this.hotkey_actions["edit_tags"] = function () {
const id = Article.getActiveArticleId(); const id = Article.getActive();
if (id) { if (id) {
Article.editArticleTags(id); Article.editTags(id);
} }
}; };
this.hotkey_actions["open_in_new_window"] = function () { this.hotkey_actions["open_in_new_window"] = function () {
if (Article.getActiveArticleId()) { if (Article.getActive()) {
Article.openArticleInNewWindow(Article.getActiveArticleId()); Article.openInNewWindow(Article.getActive());
} }
}; };
this.hotkey_actions["catchup_below"] = function () { this.hotkey_actions["catchup_below"] = function () {
Headlines.catchupRelativeToArticle(1); Headlines.catchupRelativeTo(1);
}; };
this.hotkey_actions["catchup_above"] = function () { this.hotkey_actions["catchup_above"] = function () {
Headlines.catchupRelativeToArticle(0); Headlines.catchupRelativeTo(0);
}; };
this.hotkey_actions["article_scroll_down"] = function () { this.hotkey_actions["article_scroll_down"] = function () {
Article.scrollArticle(40); Article.scroll(40);
}; };
this.hotkey_actions["article_scroll_up"] = function () { this.hotkey_actions["article_scroll_up"] = function () {
Article.scrollArticle(-40); Article.scroll(-40);
}; };
this.hotkey_actions["close_article"] = function () { this.hotkey_actions["close_article"] = function () {
if (App.isCombinedMode()) { if (App.isCombinedMode()) {
Article.cdmCollapseActive(); Article.cdmUnsetActive();
} else { } else {
Article.closeArticlePanel(); Article.close();
} }
}; };
this.hotkey_actions["email_article"] = function () { this.hotkey_actions["email_article"] = function () {
@ -368,7 +368,7 @@ const App = {
} }
}; };
this.hotkey_actions["feed_reverse"] = function () { this.hotkey_actions["feed_reverse"] = function () {
Headlines.reverseHeadlineOrder(); Headlines.reverse();
}; };
this.hotkey_actions["feed_toggle_vgroup"] = function () { this.hotkey_actions["feed_toggle_vgroup"] = function () {
xhrPost("backend.php", {op: "rpc", method: "togglepref", key: "VFEED_GROUP_BY_FEED"}, () => { xhrPost("backend.php", {op: "rpc", method: "togglepref", key: "VFEED_GROUP_BY_FEED"}, () => {
@ -402,7 +402,7 @@ const App = {
document.location.href = "prefs.php"; document.location.href = "prefs.php";
}; };
this.hotkey_actions["select_article_cursor"] = function () { this.hotkey_actions["select_article_cursor"] = function () {
const id = Article.getArticleUnderPointer(); const id = Article.getUnderPointer();
if (id) { if (id) {
const row = $("RROW-" + id); const row = $("RROW-" + id);
@ -431,8 +431,8 @@ const App = {
}; };
this.hotkey_actions["toggle_embed_original"] = function () { this.hotkey_actions["toggle_embed_original"] = function () {
if (typeof embedOriginalArticle != "undefined") { if (typeof embedOriginalArticle != "undefined") {
if (Article.getActiveArticleId()) if (Article.getActive())
embedOriginalArticle(Article.getActiveArticleId()); embedOriginalArticle(Article.getActive());
} else { } else {
alert(__("Please enable embed_original plugin first.")); alert(__("Please enable embed_original plugin first."));
} }
@ -462,7 +462,7 @@ const App = {
setInitParam("combined_display_mode", setInitParam("combined_display_mode",
!getInitParam("combined_display_mode")); !getInitParam("combined_display_mode"));
Article.closeArticlePanel(); Article.close();
Feeds.viewCurrentFeed(); Feeds.viewCurrentFeed();
}) })
}; };

@ -26,8 +26,8 @@ const ArticleCache = {
const Article = { const Article = {
_active_article_id: 0, _active_article_id: 0,
setSelectionScore: function() { selectionSetScore: function() {
const ids = Headlines.getSelectedArticleIds2(); const ids = Headlines.getSelected();
if (ids.length > 0) { if (ids.length > 0) {
console.log(ids); console.log(ids);
@ -63,7 +63,7 @@ const Article = {
alert(__("No articles are selected.")); alert(__("No articles are selected."));
} }
}, },
changeScore: function(id, pic) { setScore: function(id, pic) {
const score = pic.getAttribute("score"); const score = pic.getAttribute("score");
const new_score = prompt(__("Please enter new score for this article:"), score); const new_score = prompt(__("Please enter new score for this article:"), score);
@ -80,12 +80,30 @@ const Article = {
}); });
} }
}, },
closeArticlePanel: function () { cdmUnsetActive: function(event) {
const row = $("RROW-" + Article.getActive());
if (row) {
row.removeClassName("active");
const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]);
if (cb && !row.hasClassName("Selected"))
cb.attr("checked", false);
Article.setActive(0);
if (event)
event.stopPropagation();
return false;
}
},
close: function () {
if (dijit.byId("content-insert")) if (dijit.byId("content-insert"))
dijit.byId("headlines-wrap-inner").removeChild( dijit.byId("headlines-wrap-inner").removeChild(
dijit.byId("content-insert")); dijit.byId("content-insert"));
}, },
displayArticleUrl: function (id) { displayUrl: function (id) {
const query = {op: "rpc", method: "getlinktitlebyid", id: id}; const query = {op: "rpc", method: "getlinktitlebyid", id: id};
xhrJson("backend.php", query, (reply) => { xhrJson("backend.php", query, (reply) => {
@ -94,14 +112,14 @@ const Article = {
} }
}); });
}, },
openArticleInNewWindow: function (id) { openInNewWindow: function (id) {
const w = window.open(""); const w = window.open("");
w.opener = null; w.opener = null;
w.location = "backend.php?op=article&method=redirect&id=" + id; w.location = "backend.php?op=article&method=redirect&id=" + id;
Article.setActiveArticleId(id); Article.setActive(id);
}, },
renderArticle: function (article) { render: function (article) {
Utils.cleanupMemory("content-insert"); Utils.cleanupMemory("content-insert");
dijit.byId("headlines-wrap-inner").addChild( dijit.byId("headlines-wrap-inner").addChild(
@ -117,7 +135,7 @@ const Article = {
c.attr('content', article); c.attr('content', article);
PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED, c.domNode); PluginHost.run(PluginHost.HOOK_ARTICLE_RENDERED, c.domNode);
Headlines.correctHeadlinesOffset(Article.getActiveArticleId()); Headlines.correctHeadlinesOffset(Article.getActive());
try { try {
c.focus(); c.focus();
@ -125,7 +143,7 @@ const Article = {
} }
}, },
view: function(id, noexpand) { view: function(id, noexpand) {
this.setActiveArticleId(id); this.setActive(id);
if (!noexpand) { if (!noexpand) {
console.log("loading article", id); console.log("loading article", id);
@ -134,7 +152,7 @@ const Article = {
/* only request uncached articles */ /* only request uncached articles */
this.getRelativePostIds(id).each((n) => { this.getRelativeIds(id).each((n) => {
if (!ArticleCache.get(n)) if (!ArticleCache.get(n))
cids.push(n); cids.push(n);
}); });
@ -143,7 +161,7 @@ const Article = {
if (cached_article) { if (cached_article) {
console.log('rendering cached', id); console.log('rendering cached', id);
this.renderArticle(cached_article); this.render(cached_article);
return false; return false;
} }
@ -154,8 +172,8 @@ const Article = {
if (reply) { if (reply) {
reply.each(function (article) { reply.each(function (article) {
if (Article.getActiveArticleId() == article['id']) { if (Article.getActive() == article['id']) {
Article.renderArticle(article['content']); Article.render(article['content']);
} }
ArticleCache.set(article['id'], article['content']); ArticleCache.set(article['id'], article['content']);
}); });
@ -163,7 +181,7 @@ const Article = {
} else { } else {
console.error("Invalid object received: " + transport.responseText); console.error("Invalid object received: " + transport.responseText);
Article.renderArticle("<div class='whiteBox'>" + Article.render("<div class='whiteBox'>" +
__('Could not display article (invalid object received - see error console for details)') + "</div>"); __('Could not display article (invalid object received - see error console for details)') + "</div>");
} }
@ -180,25 +198,7 @@ const Article = {
return false; return false;
}, },
cdmCollapseActive: function(event) { editTags: function(id) {
const row = $("RROW-" + Article.getActiveArticleId());
if (row) {
row.removeClassName("active");
const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]);
if (cb && !row.hasClassName("Selected"))
cb.attr("checked", false);
Article.setActiveArticleId(0);
if (event)
event.stopPropagation();
return false;
}
},
editArticleTags: function(id) {
const query = "backend.php?op=article&method=editArticleTags&param=" + param_escape(id); const query = "backend.php?op=article&method=editArticleTags&param=" + param_escape(id);
if (dijit.byId("editTagsDlg")) if (dijit.byId("editTagsDlg"))
@ -247,7 +247,7 @@ const Article = {
dialog.show(); dialog.show();
}, },
cdmScrollToArticleId: function(id, force) { cdmScrollToId: function(id, force) {
const ctr = $("headlines-frame"); const ctr = $("headlines-frame");
const e = $("RROW-" + id); const e = $("RROW-" + id);
@ -262,8 +262,8 @@ const Article = {
Element.hide("floatingTitle"); Element.hide("floatingTitle");
} }
}, },
setActiveArticleId: function(id) { setActive: function(id) {
console.log("setActiveArticleId", id); console.log("setActive", id);
$$("div[id*=RROW][class*=active]").each((e) => { $$("div[id*=RROW][class*=active]").each((e) => {
e.removeClassName("active"); e.removeClassName("active");
@ -290,7 +290,7 @@ const Article = {
if (row.hasClassName("Unread")) { if (row.hasClassName("Unread")) {
Headlines.catchupBatchedArticles(() => { Headlines.catchupBatched(() => {
Feeds.decrementFeedCounter(Feeds.getActiveFeedId(), Feeds.activeFeedIsCat()); Feeds.decrementFeedCounter(Feeds.getActiveFeedId(), Feeds.activeFeedIsCat());
Headlines.toggleUnread(id, 0); Headlines.toggleUnread(id, 0);
Headlines.updateFloatingTitle(true); Headlines.updateFloatingTitle(true);
@ -310,10 +310,10 @@ const Article = {
Headlines.updateSelectedPrompt(); Headlines.updateSelectedPrompt();
}, },
getActiveArticleId: function() { getActive: function() {
return this._active_article_id; return this._active_article_id;
}, },
scrollArticle: function(offset) { scroll: function(offset) {
if (!App.isCombinedMode()) { if (!App.isCombinedMode()) {
const ci = $("content-insert"); const ci = $("content-insert");
if (ci) { if (ci) {
@ -327,13 +327,13 @@ const Article = {
} }
}, },
getRelativePostIds: function(id, limit) { getRelativeIds: function(id, limit) {
const tmp = []; const tmp = [];
if (!limit) limit = 6; //3 if (!limit) limit = 6; //3
const ids = Headlines.getLoadedArticleIds(); const ids = Headlines.getLoaded();
for (let i = 0; i < ids.length; i++) { for (let i = 0; i < ids.length; i++) {
if (ids[i] == id) { if (ids[i] == id) {
@ -353,7 +353,7 @@ const Article = {
mouseOut: function(id) { mouseOut: function(id) {
this.post_under_pointer = false; this.post_under_pointer = false;
}, },
getArticleUnderPointer: function() { getUnderPointer: function() {
return this.post_under_pointer; return this.post_under_pointer;
} }
}; };
@ -369,21 +369,21 @@ const Headlines = {
if (App.isCombinedMode()) { if (App.isCombinedMode()) {
if (!in_body && (event.ctrlKey || id == Article.getActiveArticleId() || getInitParam("cdm_expanded"))) { if (!in_body && (event.ctrlKey || id == Article.getActive() || getInitParam("cdm_expanded"))) {
Article.openArticleInNewWindow(id); Article.openInNewWindow(id);
} }
Article.setActiveArticleId(id); Article.setActive(id);
if (!getInitParam("cdm_expanded")) if (!getInitParam("cdm_expanded"))
Article.cdmScrollToArticleId(id); Article.cdmScrollToId(id);
return in_body; return in_body;
} else { } else {
if (event.ctrlKey) { if (event.ctrlKey) {
Article.openArticleInNewWindow(id); Article.openInNewWindow(id);
Article.setActiveArticleId(id); Article.setActive(id);
} else { } else {
Article.view(id); Article.view(id);
} }
@ -400,7 +400,7 @@ const Headlines = {
}, 50); }, 50);
} }
}, },
loadMoreHeadlines: function() { loadMore: function() {
const view_mode = document.forms["main_toolbar_form"].view_mode.value; const view_mode = document.forms["main_toolbar_form"].view_mode.value;
const unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length; const unread_in_buffer = $$("#headlines-frame > div[id*=RROW][class*=Unread]").length;
const num_all = $$("#headlines-frame > div[id*=RROW]").length; const num_all = $$("#headlines-frame > div[id*=RROW]").length;
@ -413,7 +413,7 @@ const Headlines = {
switch (view_mode) { switch (view_mode) {
case "marked": case "marked":
case "published": case "published":
console.warn("loadMoreHeadlines: ", view_mode, "not implemented"); console.warn("loadMore: ", view_mode, "not implemented");
break; break;
case "unread": case "unread":
offset = unread_in_buffer; offset = unread_in_buffer;
@ -424,13 +424,13 @@ const Headlines = {
break; break;
} }
console.log("loadMoreHeadlines, offset=", offset); console.log("loadMore, offset=", offset);
Feeds.viewfeed({feed: Feeds.getActiveFeedId(), is_cat: Feeds.activeFeedIsCat(), offset: offset}); Feeds.viewfeed({feed: Feeds.getActiveFeedId(), is_cat: Feeds.activeFeedIsCat(), offset: offset});
}, },
scrollHandler: function() { scrollHandler: function() {
try { try {
Headlines.unpackVisibleArticles(); Headlines.unpackVisible();
if (App.isCombinedMode()) { if (App.isCombinedMode()) {
Headlines.updateFloatingTitle(); Headlines.updateFloatingTitle();
@ -447,9 +447,9 @@ const Headlines = {
if ($("headlines-frame").scrollTop <= row.offsetTop && if ($("headlines-frame").scrollTop <= row.offsetTop &&
row.offsetTop - $("headlines-frame").scrollTop < 100 && row.offsetTop - $("headlines-frame").scrollTop < 100 &&
row.getAttribute("data-article-id") != Article.getActiveArticleId()) { row.getAttribute("data-article-id") != Article.getActive()) {
Article.setActiveArticleId(row.getAttribute("data-article-id")); Article.setActive(row.getAttribute("data-article-id"));
break; break;
} }
} }
@ -465,7 +465,7 @@ const Headlines = {
hsp.innerHTML = "<span class='loading'><img src='images/indicator_tiny.gif'> " + hsp.innerHTML = "<span class='loading'><img src='images/indicator_tiny.gif'> " +
__("Loading, please wait...") + "</span>"; __("Loading, please wait...") + "</span>";
Headlines.loadMoreHeadlines(); Headlines.loadMore();
return; return;
} }
} }
@ -527,7 +527,7 @@ const Headlines = {
ft.setAttribute("data-article-id", id); ft.setAttribute("data-article-id", id);
ft.innerHTML = header.innerHTML; ft.innerHTML = header.innerHTML;
ft.firstChild.innerHTML = "<img class='anchor marked-pic' src='images/page_white_go.png' " + ft.firstChild.innerHTML = "<img class='anchor marked-pic' src='images/page_white_go.png' " +
"onclick=\"Article.cdmScrollToArticleId(" + id + ", true)\">" + ft.firstChild.innerHTML; "onclick=\"Article.cdmScrollToId(" + id + ", true)\">" + ft.firstChild.innerHTML;
this.initFloatingMenu(); this.initFloatingMenu();
@ -557,7 +557,7 @@ const Headlines = {
} }
} }
}, },
unpackVisibleArticles: function() { unpackVisible: function() {
if (!App.isCombinedMode() || !getInitParam("cdm_expanded")) return; if (!App.isCombinedMode() || !getInitParam("cdm_expanded")) return;
const rows = $$("#headlines-frame div[id*=RROW][data-content]"); const rows = $$("#headlines-frame div[id*=RROW][data-content]");
@ -665,7 +665,7 @@ const Headlines = {
} else if (headlines_count > 0 && feed_id == Feeds.getActiveFeedId() && is_cat == Feeds.activeFeedIsCat()) { } else if (headlines_count > 0 && feed_id == Feeds.getActiveFeedId() && is_cat == Feeds.activeFeedIsCat()) {
const c = dijit.byId("headlines-frame"); const c = dijit.byId("headlines-frame");
//const ids = Headlines.getSelectedArticleIds2(); //const ids = Headlines.getSelected();
let hsp = $("headlines-spacer"); let hsp = $("headlines-spacer");
@ -740,7 +740,7 @@ const Headlines = {
notify(""); notify("");
}, },
reverseHeadlineOrder: function() { reverse: function() {
const toolbar = document.forms["main_toolbar_form"]; const toolbar = document.forms["main_toolbar_form"];
const order_by = dijit.getEnclosingWidget(toolbar.order_by); const order_by = dijit.getEnclosingWidget(toolbar.order_by);
@ -761,7 +761,7 @@ const Headlines = {
const cmode = params.cmode || 2; const cmode = params.cmode || 2;
const callback = params.callback; const callback = params.callback;
const no_error = params.no_error || false; const no_error = params.no_error || false;
const ids = params.ids || Headlines.getSelectedArticleIds2(); const ids = params.ids || Headlines.getSelected();
if (ids.length == 0) { if (ids.length == 0) {
if (!no_error) if (!no_error)
@ -800,7 +800,7 @@ const Headlines = {
}); });
}, },
selectionToggleMarked: function(ids) { selectionToggleMarked: function(ids) {
const rows = ids || Headlines.getSelectedArticleIds2(); const rows = ids || Headlines.getSelected();
if (rows.length == 0) { if (rows.length == 0) {
alert(__("No articles are selected.")); alert(__("No articles are selected."));
@ -821,7 +821,7 @@ const Headlines = {
}); });
}, },
selectionTogglePublished: function(ids) { selectionTogglePublished: function(ids) {
const rows = ids || Headlines.getSelectedArticleIds2(); const rows = ids || Headlines.getSelected();
if (rows.length == 0) { if (rows.length == 0) {
alert(__("No articles are selected.")); alert(__("No articles are selected."));
@ -895,28 +895,28 @@ const Headlines = {
} }
}, },
moveToPost: function(mode, noscroll, noexpand) { move: function(mode, noscroll, noexpand) {
const rows = Headlines.getLoadedArticleIds(); const rows = Headlines.getLoaded();
let prev_id = false; let prev_id = false;
let next_id = false; let next_id = false;
if (!$('RROW-' + Article.getActiveArticleId())) { if (!$('RROW-' + Article.getActive())) {
Article.setActiveArticleId(0); Article.setActive(0);
} }
if (!Article.getActiveArticleId()) { if (!Article.getActive()) {
next_id = rows[0]; next_id = rows[0];
prev_id = rows[rows.length - 1] prev_id = rows[rows.length - 1]
} else { } else {
for (let i = 0; i < rows.length; i++) { for (let i = 0; i < rows.length; i++) {
if (rows[i] == Article.getActiveArticleId()) { if (rows[i] == Article.getActive()) {
// Account for adjacent identical article ids. // Account for adjacent identical article ids.
if (i > 0) prev_id = rows[i - 1]; if (i > 0) prev_id = rows[i - 1];
for (let j = i + 1; j < rows.length; j++) { for (let j = i + 1; j < rows.length; j++) {
if (rows[j] != Article.getActiveArticleId()) { if (rows[j] != Article.getActive()) {
next_id = rows[j]; next_id = rows[j];
break; break;
} }
@ -926,23 +926,23 @@ const Headlines = {
} }
} }
console.log("cur: " + Article.getActiveArticleId() + " next: " + next_id); console.log("cur: " + Article.getActive() + " next: " + next_id);
if (mode == "next") { if (mode == "next") {
if (next_id || Article.getActiveArticleId()) { if (next_id || Article.getActive()) {
if (App.isCombinedMode()) { if (App.isCombinedMode()) {
const article = $("RROW-" + Article.getActiveArticleId()); const article = $("RROW-" + Article.getActive());
const ctr = $("headlines-frame"); const ctr = $("headlines-frame");
if (!noscroll && article && article.offsetTop + article.offsetHeight > if (!noscroll && article && article.offsetTop + article.offsetHeight >
ctr.scrollTop + ctr.offsetHeight) { ctr.scrollTop + ctr.offsetHeight) {
Article.scrollArticle(ctr.offsetHeight / 4); Article.scroll(ctr.offsetHeight / 4);
} else if (next_id) { } else if (next_id) {
Article.setActiveArticleId(next_id); Article.setActive(next_id);
Article.cdmScrollToArticleId(next_id, true); Article.cdmScrollToId(next_id, true);
} }
} else if (next_id) { } else if (next_id) {
@ -953,21 +953,21 @@ const Headlines = {
} }
if (mode == "prev") { if (mode == "prev") {
if (prev_id || Article.getActiveArticleId()) { if (prev_id || Article.getActive()) {
if (App.isCombinedMode()) { if (App.isCombinedMode()) {
const article = $("RROW-" + Article.getActiveArticleId()); const article = $("RROW-" + Article.getActive());
const prev_article = $("RROW-" + prev_id); const prev_article = $("RROW-" + prev_id);
const ctr = $("headlines-frame"); const ctr = $("headlines-frame");
if (!noscroll && article && article.offsetTop < ctr.scrollTop) { if (!noscroll && article && article.offsetTop < ctr.scrollTop) {
Article.scrollArticle(-ctr.offsetHeight / 3); Article.scroll(-ctr.offsetHeight / 3);
} else if (!noscroll && prev_article && } else if (!noscroll && prev_article &&
prev_article.offsetTop < ctr.scrollTop) { prev_article.offsetTop < ctr.scrollTop) {
Article.scrollArticle(-ctr.offsetHeight / 4); Article.scroll(-ctr.offsetHeight / 4);
} else if (prev_id) { } else if (prev_id) {
Article.setActiveArticleId(prev_id); Article.setActive(prev_id);
Article.cdmScrollToArticleId(prev_id, noscroll); Article.cdmScrollToId(prev_id, noscroll);
} }
} else if (prev_id) { } else if (prev_id) {
@ -978,7 +978,7 @@ const Headlines = {
} }
}, },
updateSelectedPrompt: function() { updateSelectedPrompt: function() {
const count = Headlines.getSelectedArticleIds2().length; const count = Headlines.getSelected().length;
const elem = $("selected_prompt"); const elem = $("selected_prompt");
if (elem) { if (elem) {
@ -1016,7 +1016,7 @@ const Headlines = {
} }
}, },
selectionRemoveLabel: function(id, ids) { selectionRemoveLabel: function(id, ids) {
if (!ids) ids = Headlines.getSelectedArticleIds2(); if (!ids) ids = Headlines.getSelected();
if (ids.length == 0) { if (ids.length == 0) {
alert(__("No articles are selected.")); alert(__("No articles are selected."));
@ -1034,7 +1034,7 @@ const Headlines = {
}); });
}, },
selectionAssignLabel: function(id, ids) { selectionAssignLabel: function(id, ids) {
if (!ids) ids = Headlines.getSelectedArticleIds2(); if (!ids) ids = Headlines.getSelected();
if (ids.length == 0) { if (ids.length == 0) {
alert(__("No articles are selected.")); alert(__("No articles are selected."));
@ -1052,7 +1052,7 @@ const Headlines = {
}); });
}, },
deleteSelection: function() { deleteSelection: function() {
const rows = Headlines.getSelectedArticleIds2(); const rows = Headlines.getSelected();
if (rows.length == 0) { if (rows.length == 0) {
alert(__("No articles are selected.")); alert(__("No articles are selected."));
@ -1082,7 +1082,7 @@ const Headlines = {
Feeds.viewCurrentFeed(); Feeds.viewCurrentFeed();
}); });
}, },
getSelectedArticleIds2: function() { getSelected: function() {
const rv = []; const rv = [];
$$("#headlines-frame > div[id*=RROW][class*=Selected]").each( $$("#headlines-frame > div[id*=RROW][class*=Selected]").each(
@ -1091,12 +1091,12 @@ const Headlines = {
}); });
// consider active article a honorary member of selected articles // consider active article a honorary member of selected articles
if (Article.getActiveArticleId()) if (Article.getActive())
rv.push(Article.getActiveArticleId()); rv.push(Article.getActive());
return rv.uniq(); return rv.uniq();
}, },
getLoadedArticleIds: function() { getLoaded: function() {
const rv = []; const rv = [];
const children = $$("#headlines-frame > div[id*=RROW-]"); const children = $$("#headlines-frame > div[id*=RROW-]");
@ -1164,7 +1164,7 @@ const Headlines = {
} }
}, },
archiveSelection: function() { archiveSelection: function() {
const rows = Headlines.getSelectedArticleIds2(); const rows = Headlines.getSelected();
if (rows.length == 0) { if (rows.length == 0) {
alert(__("No articles are selected.")); alert(__("No articles are selected."));
@ -1204,7 +1204,7 @@ const Headlines = {
}); });
}, },
catchupSelection: function() { catchupSelection: function() {
const rows = Headlines.getSelectedArticleIds2(); const rows = Headlines.getSelected();
if (rows.length == 0) { if (rows.length == 0) {
alert(__("No articles are selected.")); alert(__("No articles are selected."));
@ -1224,8 +1224,8 @@ const Headlines = {
Headlines.selectionToggleUnread({callback: Feeds.viewCurrentFeed, no_error: 1}); Headlines.selectionToggleUnread({callback: Feeds.viewCurrentFeed, no_error: 1});
}, },
catchupBatchedArticles: function(callback) { catchupBatched: function(callback) {
console.log("catchupBatchedArticles, size=", this.catchup_id_batch.length); console.log("catchupBatched, size=", this.catchup_id_batch.length);
if (this.catchup_id_batch.length > 0) { if (this.catchup_id_batch.length > 0) {
@ -1257,16 +1257,16 @@ const Headlines = {
if (callback) callback(); if (callback) callback();
} }
}, },
catchupRelativeToArticle: function(below, id) { catchupRelativeTo: function(below, id) {
if (!id) id = Article.getActiveArticleId(); if (!id) id = Article.getActive();
if (!id) { if (!id) {
alert(__("No article is selected.")); alert(__("No article is selected."));
return; return;
} }
const visible_ids = this.getLoadedArticleIds(); const visible_ids = this.getLoaded();
const ids_to_mark = []; const ids_to_mark = [];
@ -1372,14 +1372,14 @@ const Headlines = {
menu.addChild(new dijit.MenuItem({ menu.addChild(new dijit.MenuItem({
label: __("Open original article"), label: __("Open original article"),
onClick: function (event) { onClick: function (event) {
Article.openArticleInNewWindow(this.getParent().currentTarget.getAttribute("data-article-id")); Article.openInNewWindow(this.getParent().currentTarget.getAttribute("data-article-id"));
} }
})); }));
menu.addChild(new dijit.MenuItem({ menu.addChild(new dijit.MenuItem({
label: __("Display article URL"), label: __("Display article URL"),
onClick: function (event) { onClick: function (event) {
Article.displayArticleUrl(this.getParent().currentTarget.getAttribute("data-article-id")); Article.displayUrl(this.getParent().currentTarget.getAttribute("data-article-id"));
} }
})); }));
@ -1389,7 +1389,7 @@ const Headlines = {
label: __("Toggle unread"), label: __("Toggle unread"),
onClick: function () { onClick: function () {
let ids = Headlines.getSelectedArticleIds2(); let ids = Headlines.getSelected();
// cast to string // cast to string
const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + ""; const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + "";
ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id]; ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id];
@ -1401,7 +1401,7 @@ const Headlines = {
menu.addChild(new dijit.MenuItem({ menu.addChild(new dijit.MenuItem({
label: __("Toggle starred"), label: __("Toggle starred"),
onClick: function () { onClick: function () {
let ids = Headlines.getSelectedArticleIds2(); let ids = Headlines.getSelected();
// cast to string // cast to string
const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + ""; const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + "";
ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id]; ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id];
@ -1413,7 +1413,7 @@ const Headlines = {
menu.addChild(new dijit.MenuItem({ menu.addChild(new dijit.MenuItem({
label: __("Toggle published"), label: __("Toggle published"),
onClick: function () { onClick: function () {
let ids = Headlines.getSelectedArticleIds2(); let ids = Headlines.getSelected();
// cast to string // cast to string
const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + ""; const id = (this.getParent().currentTarget.getAttribute("data-article-id")) + "";
ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id]; ids = ids.length != 0 && ids.indexOf(id) != -1 ? ids : [id];
@ -1427,14 +1427,14 @@ const Headlines = {
menu.addChild(new dijit.MenuItem({ menu.addChild(new dijit.MenuItem({
label: __("Mark above as read"), label: __("Mark above as read"),
onClick: function () { onClick: function () {
Headlines.catchupRelativeToArticle(0, this.getParent().currentTarget.getAttribute("data-article-id")); Headlines.catchupRelativeTo(0, this.getParent().currentTarget.getAttribute("data-article-id"));
} }
})); }));
menu.addChild(new dijit.MenuItem({ menu.addChild(new dijit.MenuItem({
label: __("Mark below as read"), label: __("Mark below as read"),
onClick: function () { onClick: function () {
Headlines.catchupRelativeToArticle(1, this.getParent().currentTarget.getAttribute("data-article-id")); Headlines.catchupRelativeTo(1, this.getParent().currentTarget.getAttribute("data-article-id"));
} }
})); }));
@ -1457,7 +1457,7 @@ const Headlines = {
labelId: bare_id, labelId: bare_id,
onClick: function () { onClick: function () {
let ids = Headlines.getSelectedArticleIds2(); let ids = Headlines.getSelected();
// cast to string // cast to string
const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + ""; const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + "";
@ -1471,7 +1471,7 @@ const Headlines = {
label: name, label: name,
labelId: bare_id, labelId: bare_id,
onClick: function () { onClick: function () {
let ids = Headlines.getSelectedArticleIds2(); let ids = Headlines.getSelected();
// cast to string // cast to string
const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + ""; const id = (this.getParent().ownerMenu.currentTarget.getAttribute("data-article-id")) + "";

@ -21,7 +21,7 @@ class Close_Button extends Plugin {
if (!get_pref("COMBINED_DISPLAY_MODE")) { if (!get_pref("COMBINED_DISPLAY_MODE")) {
$rv = "<img src=\"plugins/close_button/button.png\" $rv = "<img src=\"plugins/close_button/button.png\"
class='tagsPic' style=\"cursor : pointer\" class='tagsPic' style=\"cursor : pointer\"
onclick=\"Article.closeArticlePanel()\" onclick=\"Article.close()\"
title='".__('Close article')."'>"; title='".__('Close article')."'>";
} }

@ -11,7 +11,7 @@ function embedOriginalArticle(id) {
if (App.isCombinedMode()) { if (App.isCombinedMode()) {
c = $$("div#RROW-" + id + " div[class=content-inner]")[0]; c = $$("div#RROW-" + id + " div[class=content-inner]")[0];
} else if (id == Article.getActiveArticleId()) { } else if (id == Article.getActive()) {
c = $$(".post .content")[0]; c = $$(".post .content")[0];
} }
@ -23,7 +23,7 @@ function embedOriginalArticle(id) {
c.parentNode.removeChild(iframe); c.parentNode.removeChild(iframe);
if (App.isCombinedMode()) { if (App.isCombinedMode()) {
Article.cdmScrollToArticleId(id, true); Article.cdmScrollToId(id, true);
} }
return; return;
@ -48,7 +48,7 @@ function embedOriginalArticle(id) {
c.parentNode.insertBefore(iframe, c); c.parentNode.insertBefore(iframe, c);
if (App.isCombinedMode()) { if (App.isCombinedMode()) {
Article.cdmScrollToArticleId(id, true); Article.cdmScrollToId(id, true);
} }
} }
} }

@ -1,7 +1,7 @@
function emailArticle(id) { function emailArticle(id) {
try { try {
if (!id) { if (!id) {
var ids = Headlines.getSelectedArticleIds2(); var ids = Headlines.getSelected();
if (ids.length == 0) { if (ids.length == 0) {
alert(__("No articles are selected.")); alert(__("No articles are selected."));

@ -1,7 +1,7 @@
function mailtoArticle(id) { function mailtoArticle(id) {
try { try {
if (!id) { if (!id) {
const ids = Headlines.getSelectedArticleIds2(); const ids = Headlines.getSelected();
if (ids.length == 0) { if (ids.length == 0) {
alert(__("No articles are selected.")); alert(__("No articles are selected."));

Loading…
Cancel
Save