summaryrefslogtreecommitdiff
path: root/js/Article.js
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2018-12-06 14:23:45 +0300
committerAndrew Dolgov <[email protected]>2018-12-06 14:23:45 +0300
commitd2d2cb7e7dd25f8257f467806da6843aca95a9cb (patch)
treebe4d7dd19ea010b70d191d338fa23e6492a222e1 /js/Article.js
parentb09a58a5705bba7e987bae0601c298be2e3d5b84 (diff)
rework scoring display, JS processing and icons
Diffstat (limited to 'js/Article.js')
-rw-r--r--js/Article.js34
1 files changed, 26 insertions, 8 deletions
diff --git a/js/Article.js b/js/Article.js
index 507560ee4..46769223e 100644
--- a/js/Article.js
+++ b/js/Article.js
@@ -22,13 +22,22 @@ define(["dojo/_base/declare"], function (declare) {
reply.id.each((id) => {
const row = $("RROW-" + id);
+ row.removeClassName("score-low");
+ row.removeClassName("score-high");
+ row.removeClassName("score-half-low");
+ row.removeClassName("score-half-high");
+ row.removeClassName("score-neutral");
+
+ row.addClassName(reply["score_class"]);
+
+
if (row) {
- const pic = row.getElementsByClassName("score-pic")[0];
+ const pic = row.select(".icon-score")[0];
if (pic) {
- pic.src = pic.src.replace(/score_.*?\.png/,
- reply["score_pic"]);
- pic.setAttribute("score", reply["score"]);
+ pic.innerHTML = reply["score_pic"];
+ pic.setAttribute("data-score", reply["score"]);
+ pic.setAttribute("title", reply["score"]);
}
}
});
@@ -41,18 +50,27 @@ define(["dojo/_base/declare"], function (declare) {
}
},
setScore: function (id, pic) {
- const score = pic.getAttribute("score");
+ const row = pic.up("div[id*=RROW]");
+ const score = pic.getAttribute("data-score");
const new_score = prompt(__("Please enter new score for this article:"), score);
- if (new_score != undefined) {
+ if (row && 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.innerHTML = reply["score_pic"];
+ pic.setAttribute("data-score", new_score);
pic.setAttribute("title", new_score);
+
+ row.removeClassName("score-low");
+ row.removeClassName("score-high");
+ row.removeClassName("score-half-low");
+ row.removeClassName("score-half-high");
+ row.removeClassName("score-neutral");
+
+ row.addClassName(reply["score_class"]);
}
});
}