DEV: patchbot: use checked buttons as reference instead of internal table
The statuses[] table was pre-filled from the shell code during initialization based on the evaluation and the buttons pre-checked accordingly, but upon reload, the checked buttons are preserved and the statuses reinitialized, leading to a different status and color on lines that were changed. In practice we don't need this table and we can directly check each button's state. This makes sure that displayed state is consistent with checked buttons and allows to preserve the statuses upon reloads to benefit from updates. Only the start of the review is reset upon reload now (this allows to consider latest backport state). Of course, a full reload (shift-ctrl-R) continues to reset the form.
This commit is contained in:
parent
0a203c1d3f
commit
896d452015
|
@ -135,8 +135,7 @@ input.y[type="radio"]:checked {
|
||||||
|
|
||||||
<script type="text/javascript"><!--
|
<script type="text/javascript"><!--
|
||||||
|
|
||||||
// statuses are "y", "w", "u", "n"
|
var nb_patches = 0;
|
||||||
var statuses = [];
|
|
||||||
var cid = [];
|
var cid = [];
|
||||||
|
|
||||||
// first line to review
|
// first line to review
|
||||||
|
@ -151,8 +150,8 @@ function updt_table(line) {
|
||||||
var tn = 0, tu = 0, tw = 0, ty = 0;
|
var tn = 0, tu = 0, tw = 0, ty = 0;
|
||||||
var i, el;
|
var i, el;
|
||||||
|
|
||||||
for (i = 1; i < statuses.length; i++) {
|
for (i = 1; i < nb_patches; i++) {
|
||||||
if (statuses[i] == "n") {
|
if (document.getElementById("bt_" + i + "_n").checked) {
|
||||||
tn++;
|
tn++;
|
||||||
if (line && i != line)
|
if (line && i != line)
|
||||||
continue;
|
continue;
|
||||||
|
@ -160,7 +159,7 @@ function updt_table(line) {
|
||||||
el.style.backgroundColor = "$BG_N";
|
el.style.backgroundColor = "$BG_N";
|
||||||
el.style.display = n && i >= review ? "" : "none";
|
el.style.display = n && i >= review ? "" : "none";
|
||||||
}
|
}
|
||||||
else if (statuses[i] == "u") {
|
else if (document.getElementById("bt_" + i + "_u").checked) {
|
||||||
tu++;
|
tu++;
|
||||||
if (line && i != line)
|
if (line && i != line)
|
||||||
continue;
|
continue;
|
||||||
|
@ -168,7 +167,7 @@ function updt_table(line) {
|
||||||
el.style.backgroundColor = "$BG_U";
|
el.style.backgroundColor = "$BG_U";
|
||||||
el.style.display = u && i >= review ? "" : "none";
|
el.style.display = u && i >= review ? "" : "none";
|
||||||
}
|
}
|
||||||
else if (statuses[i] == "w") {
|
else if (document.getElementById("bt_" + i + "_w").checked) {
|
||||||
tw++;
|
tw++;
|
||||||
if (line && i != line)
|
if (line && i != line)
|
||||||
continue;
|
continue;
|
||||||
|
@ -176,7 +175,7 @@ function updt_table(line) {
|
||||||
el.style.backgroundColor = "$BG_W";
|
el.style.backgroundColor = "$BG_W";
|
||||||
el.style.display = w && i >= review ? "" : "none";
|
el.style.display = w && i >= review ? "" : "none";
|
||||||
}
|
}
|
||||||
else if (statuses[i] == "y") {
|
else if (document.getElementById("bt_" + i + "_y").checked) {
|
||||||
ty++;
|
ty++;
|
||||||
if (line && i != line)
|
if (line && i != line)
|
||||||
continue;
|
continue;
|
||||||
|
@ -202,16 +201,16 @@ function updt_table(line) {
|
||||||
function updt_output() {
|
function updt_output() {
|
||||||
var i, y = "", w = "", u = "", n = "";
|
var i, y = "", w = "", u = "", n = "";
|
||||||
|
|
||||||
for (i = 1; i < statuses.length; i++) {
|
for (i = 1; i < nb_patches; i++) {
|
||||||
if (i < review)
|
if (i < review)
|
||||||
continue;
|
continue;
|
||||||
if (statuses[i] == "y")
|
if (document.getElementById("bt_" + i + "_y").checked)
|
||||||
y = y + " " + cid[i];
|
y = y + " " + cid[i];
|
||||||
else if (statuses[i] == "w")
|
else if (document.getElementById("bt_" + i + "_w").checked)
|
||||||
w = w + " " + cid[i];
|
w = w + " " + cid[i];
|
||||||
else if (statuses[i] == "u")
|
else if (document.getElementById("bt_" + i + "_u").checked)
|
||||||
u = u + " " + cid[i];
|
u = u + " " + cid[i];
|
||||||
else if (statuses[i] == "n")
|
else if (document.getElementById("bt_" + i + "_n").checked)
|
||||||
n = n + " " + cid[i];
|
n = n + " " + cid[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -224,9 +223,7 @@ function updt_output() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function updt(line,value) {
|
function updt(line,value) {
|
||||||
if (value != "r") {
|
if (value == "r") {
|
||||||
statuses[line] = value;
|
|
||||||
} else {
|
|
||||||
review = line;
|
review = line;
|
||||||
line = 0; // redraw everything
|
line = 0; // redraw everything
|
||||||
}
|
}
|
||||||
|
@ -309,7 +306,7 @@ for patch in "${PATCHES[@]}"; do
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "<script type='text/javascript'>cid[$seq_num]='$cid';statuses[$seq_num]='$verdict'[0];</script>"
|
echo "<script type='text/javascript'>cid[$seq_num]='$cid'</script>"
|
||||||
|
|
||||||
echo -n "<TR id='tr_$seq_num' name='$cid'"
|
echo -n "<TR id='tr_$seq_num' name='$cid'"
|
||||||
|
|
||||||
|
@ -368,5 +365,5 @@ echo "<P/>"
|
||||||
echo "<H3>Output:</H3>"
|
echo "<H3>Output:</H3>"
|
||||||
echo "<textarea cols=120 rows=10 id='output'></textarea>"
|
echo "<textarea cols=120 rows=10 id='output'></textarea>"
|
||||||
echo "<P/>"
|
echo "<P/>"
|
||||||
echo "<script type='text/javascript'>review=$review; updt_table(0); updt_output();</script>"
|
echo "<script type='text/javascript'>nb_patches=$seq_num; review=$review; updt_table(0); updt_output();</script>"
|
||||||
echo "</BODY></HTML>"
|
echo "</BODY></HTML>"
|
||||||
|
|
Loading…
Reference in New Issue