further effocts to wrap JS stuff into objects

This commit is contained in:
Andrew Dolgov 2018-12-01 21:01:53 +03:00
parent 4bed9be57d
commit 642c37ea61
11 changed files with 659 additions and 685 deletions

View File

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

View File

@ -15,19 +15,19 @@ class Feeds extends Handler_Protected {
$feed_id, $is_cat, $search,
$error, $feed_last_updated) {
$catchup_sel_link = "catchupSelection()";
$catchup_sel_link = "Headlines.catchupSelection()";
$archive_sel_link = "archiveSelection()";
$delete_sel_link = "deleteSelection()";
$archive_sel_link = "Headlines.archiveSelection()";
$delete_sel_link = "Headlines.deleteSelection()";
$sel_all_link = "selectArticles('all')";
$sel_unread_link = "selectArticles('unread')";
$sel_none_link = "selectArticles('none')";
$sel_inv_link = "selectArticles('invert')";
$sel_all_link = "Headlines.selectArticles('all')";
$sel_unread_link = "Headlines.selectArticles('unread')";
$sel_none_link = "Headlines.selectArticles('none')";
$sel_inv_link = "Headlines.selectArticles('invert')";
$tog_unread_link = "selectionToggleUnread()";
$tog_marked_link = "selectionToggleMarked()";
$tog_published_link = "selectionTogglePublished()";
$tog_unread_link = "Headlines.selectionToggleUnread()";
$tog_marked_link = "Headlines.selectionToggleMarked()";
$tog_published_link = "Headlines.selectionTogglePublished()";
$set_score_link = "Article.setSelectionScore()";
@ -331,11 +331,11 @@ class Feeds extends Handler_Protected {
$marked_pic_src = $line["marked"] ? "mark_set.png" : "mark_unset.png";
$class .= $line["marked"] ? " marked" : "";
$marked_pic = "<img src=\"images/$marked_pic_src\" class=\"marked-pic marked-$id\" onclick='toggleMark($id)'>";
$marked_pic = "<img src=\"images/$marked_pic_src\" class=\"marked-pic marked-$id\" onclick='Headlines.toggleMark($id)'>";
$published_pic_src = $line["published"] ? "pub_set.png" : "pub_unset.png";
$class .= $line["published"] ? " published" : "";
$published_pic = "<img src=\"images/$published_pic_src\" class=\"pub-pic pub-$id\" onclick='togglePub($id)'>";
$published_pic = "<img src=\"images/$published_pic_src\" class=\"pub-pic pub-$id\" onclick='Headlines.togglePub($id)'>";
$updated_fmt = make_local_datetime($line["updated"], false, false, false, true);
$date_entered_fmt = T_sprintf("Imported at %s",
@ -628,7 +628,7 @@ class Feeds extends Handler_Protected {
$tmp_content .= "<img src='images/tag.png' alt='Tags' title='Tags'>
<span id=\"ATSTR-$id\">$tags_str</span>
<a title=\"".__('Edit tags for this article')."\"
href=\"#\" onclick=\"editArticleTags($id)\">(+)</a>";
href=\"#\" onclick=\"Article.editArticleTags($id)\">(+)</a>";
$num_comments = (int) $line["num_comments"];
$entry_comments = "";

View File

@ -207,8 +207,8 @@ const Feeds = {
Utils.setLoadingProgress(50);
document.onkeydown = App.hotkeyHandler;
setInterval(hotkeyPrefixTimeout, 3 * 1000);
setInterval(catchupBatchedArticles, 10 * 1000);
window.setInterval(() => { hotkeyPrefixTimeout() }, 3 * 1000);
window.setInterval(() => { Headlines.catchupBatchedArticles() }, 10 * 1000);
if (!this.getActiveFeedId()) {
this.viewfeed({feed: -3});
@ -246,10 +246,7 @@ const Feeds = {
} else {
setTimeout(() => {
this.requestCounters(true);
setInterval(() => {
this.requestCounters();
}, 60 * 1000)
setInterval(() => { this.requestCounters(); }, 60 * 1000)
}, 250);
}
},
@ -271,7 +268,7 @@ const Feeds = {
this.selectFeed(id, is_cat);
PluginHost.run(PluginHost.HOOK_FEED_SET_ACTIVE, _active_article_id);
PluginHost.run(PluginHost.HOOK_FEED_SET_ACTIVE, [this._active_feed_id, this._active_feed_is_cat]);
},
selectFeed: function(feed, is_cat) {
const tree = dijit.byId("feedTree");
@ -303,7 +300,7 @@ const Feeds = {
if (feed != this.getActiveFeedId() || this.activeFeedIsCat() != is_cat) {
this._search_query = false;
setActiveArticleId(0);
Article.setActiveArticleId(0);
}
if (offset != 0) {
@ -330,8 +327,8 @@ const Feeds = {
if (method) query.m = method;
if (offset > 0) {
if (current_first_id) {
query.fid = current_first_id;
if (Headlines.current_first_id) {
query.fid = Headlines.current_first_id;
}
}
@ -343,8 +340,8 @@ const Feeds = {
query.skip = offset;
// to prevent duplicate feed titles when showing grouped vfeeds
if (vgroup_last_feed) {
query.vgrlf = vgroup_last_feed;
if (Headlines.vgroup_last_feed != undefined) {
query.vgrlf = Headlines.vgroup_last_feed;
}
} else if (!is_cat && feed == this.getActiveFeedId() && !params.method) {
query.m = "ForceUpdate";
@ -370,7 +367,7 @@ const Feeds = {
window.clearTimeout(this._viewfeed_wait_timeout);
this._viewfeed_wait_timeout = window.setTimeout(() => {
catchupBatchedArticles(() => {
Headlines.catchupBatchedArticles(() => {
xhrPost("backend.php", query, (transport) => {
try {
this.setFeedExpandoIcon(feed, is_cat, 'images/blank_icon.gif');
@ -492,7 +489,7 @@ const Feeds = {
rows.each(function (row) {
row.removeClassName("Unread");
if (row.getAttribute("data-article-id") != getActiveArticleId()) {
if (row.getAttribute("data-article-id") != Article.getActiveArticleId()) {
new Effect.Fade(row, {duration: 0.5});
}

View File

@ -878,7 +878,7 @@ function toggleSelectRow2(sender, row, is_cdm) {
row.removeClassName('Selected');
if (typeof updateSelectedPrompt != undefined)
updateSelectedPrompt();
Headlines.updateSelectedPrompt();
}
@ -892,7 +892,7 @@ function toggleSelectRow(sender, row) {
row.removeClassName('Selected');
if (typeof updateSelectedPrompt != undefined)
updateSelectedPrompt();
Headlines.updateSelectedPrompt();
}
// noinspection JSUnusedGlobalSymbols
@ -1412,7 +1412,7 @@ function quickAddFilter() {
} else {
const query = { op: "rpc", method: "getlinktitlebyid", id: getActiveArticleId() };
const query = { op: "rpc", method: "getlinktitlebyid", id: Article.getActiveArticleId() };
xhrPost("backend.php", query, (transport) => {
const reply = JSON.parse(transport.responseText);

View File

@ -86,7 +86,7 @@ const App = {
}, 100);
}
setInterval(hotkeyPrefixTimeout, 5 * 1000);
setInterval(() => { hotkeyPrefixTimeout() }, 5 * 1000);
},
hotkeyHandler: function (event) {
if (event.target.nodeName == "INPUT" || event.target.nodeName == "TEXTAREA") return;

View File

@ -143,7 +143,7 @@ const App = {
if (getInitParam("simple_update")) {
console.log("scheduling simple feed updater...");
window.setInterval(Feeds.updateRandomFeed, 30 * 1000);
window.setInterval(() => { Feeds.updateRandomFeed() }, 30 * 1000);
}
console.log("second stage ok");
@ -191,7 +191,7 @@ const App = {
switchPanelMode: function(wide) {
if (App.isCombinedMode()) return;
const article_id = getActiveArticleId();
const article_id = Article.getActiveArticleId();
if (wide) {
dijit.byId("headlines-wrap-inner").attr("design", 'sidebar');
@ -249,44 +249,44 @@ function init_hotkey_actions() {
if (rv) Feeds.viewfeed({feed: rv[0], is_cat: rv[1], delayed: true})
};
hotkey_actions["next_article"] = function () {
moveToPost('next');
Headlines.moveToPost('next');
};
hotkey_actions["prev_article"] = function () {
moveToPost('prev');
Headlines.moveToPost('prev');
};
hotkey_actions["next_article_noscroll"] = function () {
moveToPost('next', true);
Headlines.moveToPost('next', true);
};
hotkey_actions["prev_article_noscroll"] = function () {
moveToPost('prev', true);
Headlines.moveToPost('prev', true);
};
hotkey_actions["next_article_noexpand"] = function () {
moveToPost('next', true, true);
Headlines.moveToPost('next', true, true);
};
hotkey_actions["prev_article_noexpand"] = function () {
moveToPost('prev', true, true);
Headlines.moveToPost('prev', true, true);
};
hotkey_actions["search_dialog"] = function () {
Feeds.search();
};
hotkey_actions["toggle_mark"] = function () {
selectionToggleMarked();
Headlines.selectionToggleMarked();
};
hotkey_actions["toggle_publ"] = function () {
selectionTogglePublished();
Headlines.selectionTogglePublished();
};
hotkey_actions["toggle_unread"] = function () {
selectionToggleUnread({no_error: 1});
Headlines.selectionToggleUnread({no_error: 1});
};
hotkey_actions["edit_tags"] = function () {
const id = getActiveArticleId();
const id = Article.getActiveArticleId();
if (id) {
editArticleTags(id);
Article.editArticleTags(id);
}
}
hotkey_actions["open_in_new_window"] = function () {
if (getActiveArticleId()) {
Article.openArticleInNewWindow(getActiveArticleId());
if (Article.getActiveArticleId()) {
Article.openArticleInNewWindow(Article.getActiveArticleId());
}
};
hotkey_actions["catchup_below"] = function () {
@ -318,22 +318,22 @@ function init_hotkey_actions() {
}
};
hotkey_actions["select_all"] = function () {
selectArticles('all');
Headlines.selectArticles('all');
};
hotkey_actions["select_unread"] = function () {
selectArticles('unread');
Headlines.selectArticles('unread');
};
hotkey_actions["select_marked"] = function () {
selectArticles('marked');
Headlines.selectArticles('marked');
};
hotkey_actions["select_published"] = function () {
selectArticles('published');
Headlines.selectArticles('published');
};
hotkey_actions["select_invert"] = function () {
selectArticles('invert');
Headlines.selectArticles('invert');
};
hotkey_actions["select_none"] = function () {
selectArticles('none');
Headlines.selectArticles('none');
};
hotkey_actions["feed_refresh"] = function () {
if (Feeds.getActiveFeedId() != undefined) {
@ -434,8 +434,8 @@ function init_hotkey_actions() {
};
hotkey_actions["toggle_embed_original"] = function () {
if (typeof embedOriginalArticle != "undefined") {
if (getActiveArticleId())
embedOriginalArticle(getActiveArticleId());
if (Article.getActiveArticleId())
embedOriginalArticle(Article.getActiveArticleId());
} else {
alert(__("Please enable embed_original plugin first."));
}

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

@ -23,12 +23,12 @@ class Mark_Button extends Plugin {
$marked_pic = "<img
src=\"images/mark_set.png\"
class=\"marked-pic marked-$id\" alt=\"Unstar article\"
onclick='toggleMark($id)'>";
onclick='Headlines.toggleMark($id)'>";
} else {
$marked_pic = "<img
src=\"images/mark_unset.png\"
class=\"marked-pic marked-$id\" alt=\"Star article\"
onclick='toggleMark($id)'>";
onclick='Headlines.toggleMark($id)'>";
}
}