bayes: properly reset score when going good -> ugly
article: add helper to refresh article score pic, properly set scorepic title
This commit is contained in:
parent
308c55c0f1
commit
a72cd54ce1
|
@ -215,6 +215,18 @@ class Article extends Handler_Protected {
|
||||||
score = '$score' WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]);
|
score = '$score' WHERE ref_id IN ($ids) AND owner_uid = " . $_SESSION["uid"]);
|
||||||
|
|
||||||
print json_encode(array("id" => $ids,
|
print json_encode(array("id" => $ids,
|
||||||
|
"score" => (int)$score,
|
||||||
|
"score_pic" => get_score_pic($score)));
|
||||||
|
}
|
||||||
|
|
||||||
|
function getScore() {
|
||||||
|
$id = $this->dbh->escape_string($_REQUEST['id']);
|
||||||
|
|
||||||
|
$result = $this->dbh->query("SELECT score FROM ttrss_user_entries WHERE ref_id = $id AND owner_uid = " . $_SESSION["uid"]);
|
||||||
|
$score = $this->dbh->fetch_result($result, 0, "score");
|
||||||
|
|
||||||
|
print json_encode(array("id" => $id,
|
||||||
|
"score" => (int)$score,
|
||||||
"score_pic" => get_score_pic($score)));
|
"score_pic" => get_score_pic($score)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2293,6 +2293,34 @@ function setSelectionScore() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateScore(id) {
|
||||||
|
try {
|
||||||
|
var pic = $$("#RROW-" + id + " .hlScorePic")[0];
|
||||||
|
|
||||||
|
if (pic) {
|
||||||
|
|
||||||
|
var query = "op=article&method=getScore&id=" + param_escape(id);
|
||||||
|
|
||||||
|
new Ajax.Request("backend.php", {
|
||||||
|
parameters: query,
|
||||||
|
onComplete: function(transport) {
|
||||||
|
console.log(transport.responseText);
|
||||||
|
|
||||||
|
var reply = JSON.parse(transport.responseText);
|
||||||
|
|
||||||
|
if (reply) {
|
||||||
|
pic.src = pic.src.replace(/score_.*?\.png/, reply["score_pic"]);
|
||||||
|
pic.setAttribute("score", reply["score"]);
|
||||||
|
pic.setAttribute("title", reply["score"]);
|
||||||
|
}
|
||||||
|
} });
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (e) {
|
||||||
|
exception_error("updateScore", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function changeScore(id, pic) {
|
function changeScore(id, pic) {
|
||||||
try {
|
try {
|
||||||
var score = pic.getAttribute("score");
|
var score = pic.getAttribute("score");
|
||||||
|
@ -2312,6 +2340,7 @@ function changeScore(id, pic) {
|
||||||
if (reply) {
|
if (reply) {
|
||||||
pic.src = pic.src.replace(/score_.*?\.png/, reply["score_pic"]);
|
pic.src = pic.src.replace(/score_.*?\.png/, reply["score_pic"]);
|
||||||
pic.setAttribute("score", new_score);
|
pic.setAttribute("score", new_score);
|
||||||
|
pic.setAttribute("title", new_score);
|
||||||
}
|
}
|
||||||
} });
|
} });
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,13 @@ function bayesTrain(id, train_up) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
var query = "backend.php?op=pluginhandler&plugin=af_sort_bayes&method=trainArticle&article_id=" + param_escape(id) +
|
var query = "backend.php?op=pluginhandler&plugin=af_sort_bayes&method=trainArticle&article_id=" + param_escape(id) +
|
||||||
"&train_up=" + train_up;
|
"&train_up=" + param_escape(train_up);
|
||||||
|
|
||||||
new Ajax.Request("backend.php", {
|
new Ajax.Request("backend.php", {
|
||||||
parameters: query,
|
parameters: query,
|
||||||
onComplete: function(transport) {
|
onComplete: function(transport) {
|
||||||
notify(transport.responseText);
|
notify(transport.responseText);
|
||||||
|
updateScore(id);
|
||||||
} });
|
} });
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -79,14 +79,14 @@ class Af_Sort_Bayes extends Plugin {
|
||||||
switch ($current_category) {
|
switch ($current_category) {
|
||||||
case "UGLY":
|
case "UGLY":
|
||||||
$dst_category = "BAD";
|
$dst_category = "BAD";
|
||||||
$score = -$this->score_modifier;
|
$score = $this->score_modifier;
|
||||||
break;
|
break;
|
||||||
case "BAD":
|
case "BAD":
|
||||||
$dst_category = "BAD";
|
$dst_category = "BAD";
|
||||||
break;
|
break;
|
||||||
case "GOOD":
|
case "GOOD":
|
||||||
$dst_category = "UGLY";
|
$dst_category = "UGLY";
|
||||||
$score = -$this->score_modifier;
|
$score = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue