summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2018-12-01 17:54:16 +0300
committerAndrew Dolgov <[email protected]>2018-12-01 17:54:16 +0300
commit97df81d8d9d9ebcbf5a41dd736924d7a61855fbc (patch)
tree2ed6e123dffba1d4f14950333e7400e0f2815457 /js
parent1d82bd4f19de40f0cf966545c372595caa2c8afe (diff)
even more objectification of JS
Diffstat (limited to 'js')
-rw-r--r--js/feedlist.js4
-rw-r--r--js/tt-rss.js2
-rwxr-xr-xjs/viewfeed.js201
3 files changed, 103 insertions, 104 deletions
diff --git a/js/feedlist.js b/js/feedlist.js
index a95a82672..a0b552132 100644
--- a/js/feedlist.js
+++ b/js/feedlist.js
@@ -43,7 +43,7 @@ const Feeds = {
parseCounters: function (elems) {
for (let l = 0; l < elems.length; l++) {
- if (this._counters_prev[l] && this.counterEquals(elems[l], this._counters_prev[l])) {
+ if (Feeds._counters_prev[l] && this.counterEquals(elems[l], this._counters_prev[l])) {
continue;
}
@@ -169,7 +169,7 @@ const Feeds = {
const id = String(item.id);
const is_cat = id.match("^CAT:");
const feed = id.substr(id.indexOf(":") + 1);
- this.viewfeed({feed: feed, is_cat: is_cat});
+ Feeds.viewfeed({feed: feed, is_cat: is_cat});
return false;
},
openOnClick: false,
diff --git a/js/tt-rss.js b/js/tt-rss.js
index 66a94f714..e48e4ece9 100644
--- a/js/tt-rss.js
+++ b/js/tt-rss.js
@@ -326,7 +326,7 @@ function init_hotkey_actions() {
};
hotkey_actions["close_article"] = function () {
if (App.isCombinedMode()) {
- cdmCollapseActive();
+ Article.cdmCollapseActive();
} else {
Article.closeArticlePanel();
}
diff --git a/js/viewfeed.js b/js/viewfeed.js
index f57f7fc6c..45d2efebb 100755
--- a/js/viewfeed.js
+++ b/js/viewfeed.js
@@ -38,6 +38,60 @@ const ArticleCache = {
};
const Article = {
+ setSelectionScore: function() {
+ const ids = getSelectedArticleIds2();
+
+ if (ids.length > 0) {
+ console.log(ids);
+
+ const score = prompt(__("Please enter new score for selected articles:"));
+
+ if (score != undefined) {
+ const query = {
+ op: "article", method: "setScore", id: ids.toString(),
+ score: score
+ };
+
+ xhrJson("backend.php", query, (reply) => {
+ if (reply) {
+ reply.id.each((id) => {
+ const row = $("RROW-" + id);
+
+ if (row) {
+ const pic = row.getElementsByClassName("score-pic")[0];
+
+ if (pic) {
+ pic.src = pic.src.replace(/score_.*?\.png/,
+ reply["score_pic"]);
+ pic.setAttribute("score", reply["score"]);
+ }
+ }
+ });
+ }
+ });
+ }
+
+ } else {
+ alert(__("No articles are selected."));
+ }
+ },
+ changeScore: function(id, pic) {
+ const score = pic.getAttribute("score");
+
+ const new_score = prompt(__("Please enter new score for this article:"), score);
+
+ if (new_score != undefined) {
+ const query = {op: "article", method: "setScore", id: id, score: new_score};
+
+ xhrJson("backend.php", query, (reply) => {
+ if (reply) {
+ pic.src = pic.src.replace(/score_.*?\.png/, reply["score_pic"]);
+ pic.setAttribute("score", new_score);
+ pic.setAttribute("title", new_score);
+ }
+ });
+ }
+ },
closeArticlePanel: function () {
if (dijit.byId("content-insert"))
dijit.byId("headlines-wrap-inner").removeChild(
@@ -136,10 +190,55 @@ const Article = {
return false;
},
-}
+ cdmCollapseActive: function(event) {
+ const row = $("RROW-" + getActiveArticleId());
+
+ if (row) {
+ row.removeClassName("active");
+ const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]);
+
+ if (cb && !row.hasClassName("Selected"))
+ cb.attr("checked", false);
+
+ setActiveArticleId(0);
+
+ if (event)
+ event.stopPropagation();
+
+ return false;
+ }
+ }
+};
const Headlines = {
_headlines_scroll_timeout: 0,
+ click: function(event, id, in_body) {
+ in_body = in_body || false;
+
+ if (App.isCombinedMode()) {
+
+ if (!in_body && (event.ctrlKey || id == getActiveArticleId() || getInitParam("cdm_expanded"))) {
+ Article.openArticleInNewWindow(id);
+ }
+
+ setActiveArticleId(id);
+
+ if (!getInitParam("cdm_expanded"))
+ cdmScrollToArticleId(id);
+
+ return in_body;
+
+ } else {
+ if (event.ctrlKey) {
+ Article.openArticleInNewWindow(id);
+ setActiveArticleId(id);
+ } else {
+ Article.view(id);
+ }
+
+ return false;
+ }
+ },
initScrollHandler: function() {
$("headlines-frame").onscroll = (event) => {
clearTimeout(this._headlines_scroll_timeout);
@@ -1238,33 +1337,6 @@ function updateHeadlineLabels(transport) {
}
}
-function cdmClicked(event, id, in_body) {
- in_body = in_body || false;
-
- if (!in_body && (event.ctrlKey || id == getActiveArticleId() || getInitParam("cdm_expanded"))) {
- Article.openArticleInNewWindow(id);
- }
-
- setActiveArticleId(id);
-
- if (!getInitParam("cdm_expanded"))
- cdmScrollToArticleId(id);
-
- return in_body;
-}
-
-function hlClicked(event, id) {
- if (event.ctrlKey) {
- Article.openArticleInNewWindow(id);
- setActiveArticleId(id);
- } else {
- Article.view(id);
- }
-
- return false;
-}
-
-
function getRelativePostIds(id, limit) {
const tmp = [];
@@ -1313,25 +1385,6 @@ function headlineActionsChange(elem) {
elem.attr('value', 'false');
}
-function cdmCollapseActive(event) {
- const row = $("RROW-" + getActiveArticleId());
-
- if (row) {
- row.removeClassName("active");
- const cb = dijit.getEnclosingWidget(row.select(".rchk")[0]);
-
- if (cb && !row.hasClassName("Selected"))
- cb.attr("checked", false);
-
- setActiveArticleId(0);
-
- if (event)
- event.stopPropagation();
-
- return false;
- }
-}
-
function initFloatingMenu() {
if (!dijit.byId("floatingMenu")) {
@@ -1539,59 +1592,5 @@ function initHeadlinesMenu() {
}
}
-// noinspection JSUnusedGlobalSymbols
-function setSelectionScore() {
- const ids = getSelectedArticleIds2();
-
- if (ids.length > 0) {
- console.log(ids);
-
- const score = prompt(__("Please enter new score for selected articles:"));
-
- if (score != undefined) {
- const query = { op: "article", method: "setScore", id: ids.toString(),
- score: score };
-
- xhrJson("backend.php", query, (reply) => {
- if (reply) {
- reply.id.each((id) => {
- const row = $("RROW-" + id);
-
- if (row) {
- const pic = row.getElementsByClassName("score-pic")[0];
-
- if (pic) {
- pic.src = pic.src.replace(/score_.*?\.png/,
- reply["score_pic"]);
- pic.setAttribute("score", reply["score"]);
- }
- }
- });
- }
- });
- }
-
- } else {
- alert(__("No articles are selected."));
- }
-}
-
-// noinspection JSUnusedGlobalSymbols
-function changeScore(id, pic) {
- const score = pic.getAttribute("score");
-
- const new_score = prompt(__("Please enter new score for this article:"), score);
-
- if (new_score != undefined) {
- const query = { op: "article", method: "setScore", id: id, score: new_score };
- xhrJson("backend.php", query, (reply) => {
- if (reply) {
- pic.src = pic.src.replace(/score_.*?\.png/, reply["score_pic"]);
- pic.setAttribute("score", new_score);
- pic.setAttribute("title", new_score);
- }
- });
- }
-}