Francois Gouget : testbot/Submit: Replace the "Toggle All" action with a more standard "master" checkbox.
Alexandre Julliard
julliard at winehq.org
Tue Oct 1 07:59:43 CDT 2019
Module: tools
Branch: master
Commit: 359f779f553b2d73b94ce5b4c58f61b6bb986e2a
URL: https://source.winehq.org/git/tools.git/?a=commit;h=359f779f553b2d73b94ce5b4c58f61b6bb986e2a
Author: Francois Gouget <fgouget at codeweavers.com>
Date: Tue Oct 1 03:37:10 2019 +0200
testbot/Submit: Replace the "Toggle All" action with a more standard "master" checkbox.
Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
testbot/web/Submit.pl | 65 ++++++++++++++++++++++++++++++---------------------
1 file changed, 38 insertions(+), 27 deletions(-)
diff --git a/testbot/web/Submit.pl b/testbot/web/Submit.pl
index b9ead74..a51ace6 100644
--- a/testbot/web/Submit.pl
+++ b/testbot/web/Submit.pl
@@ -589,12 +589,10 @@ sub GenerateFields($)
{
$self->_GenerateStateField("ShowAll");
print "<div class='CollectionBlock'><table>\n";
- print "<thead><tr><th class='Record'></th>\n";
- print "<th class='Record'>VM Name</th>\n";
- print "<th class='Record'>Description</th>\n";
- print "</thead><tbody>\n";
+ print "<thead><tr><th class='Record'>";
- my $Even = 1;
+ # Check which VMs are selected and set the master default
+ my $MasterChecked = " checked";
foreach my $VMRow (@{$self->{VMRows}})
{
next if ($VMRow->{Incompatible});
@@ -602,15 +600,47 @@ sub GenerateFields($)
next if ($VMRow->{Extra} and !$VMRow->{Checked} and !$self->{ShowAll});
# By default select the base VMs that are ready to run tasks
- my $VM = $VMRow->{VM};
if (!$self->{UserVMSelection} and !$VMRow->{Extra} and
- $VM->Status !~ /^(?:offline|maintenance)$/)
+ $VMRow->{VM}->Status !~ /^(?:offline|maintenance)$/)
{
$VMRow->{Checked} = 1;
}
+ $MasterChecked = "" if (!$VMRow->{Checked});
+ }
+
+ # Add a "Toggle All" pseudo action
+ print <<EOF;
+<script type='text/javascript'>
+<!--
+function SetAllVMCBs(master)
+{
+ var vmcbs = document.getElementsByClassName("vmcb");
+ for (var i = 0; i < vmcbs.length; i++)
+ {
+ vmcbs[i].checked = master.checked;
+ }
+}
+
+// Only put the JavaScript checkbox if JavaScript is enabled
+document.write("<input type='checkbox' onchange='SetAllVMCBs(this);'$MasterChecked/>");
+//-->
+</script>
+EOF
+ print "</th>\n";
+ print "<th class='Record'>VM Name</th>\n";
+ print "<th class='Record'>Description</th>\n";
+ print "</thead><tbody>\n";
+
+ my $Even = 1;
+ foreach my $VMRow (@{$self->{VMRows}})
+ {
+ next if ($VMRow->{Incompatible});
+ # Extra VMs may be hidden
+ next if ($VMRow->{Extra} and !$VMRow->{Checked} and !$self->{ShowAll});
+ my $VM = $VMRow->{VM};
print "<tr class='", ($Even ? "even" : "odd"),
- "'><td><input name='$VMRow->{Field}' type='checkbox'";
+ "'><td><input class='vmcb' name='$VMRow->{Field}' type='checkbox'";
$Even = !$Even;
print " checked='checked'" if ($VMRow->{Checked});
print "/></td>\n";
@@ -631,25 +661,6 @@ sub GenerateFields($)
$self->_GenerateStateField("UserVMSelection");
print "</div><!--CollectionBlock-->\n";
- # Add a "Toggle All" pseudo action
- print <<EOF;
-<script type='text/javascript'>
-<!--
-function ToggleAll()
-{
- for (var i = 0; i < document.forms[0].elements.length; i++)
- {
- if (document.forms[0].elements[i].type == 'checkbox')
- document.forms[0].elements[i].checked = !(document.forms[0].elements[i].checked);
- }
-}
-
-// Only put javascript link in document if javascript is enabled
-document.write("<div class='ItemActions'><a href='javascript:void(0)' onClick='ToggleAll();'>Toggle All<\\\/a><\\\/div>");
-//-->
-</script>
-EOF
-
# Add a Show base/all VMs button separate from the other actions
print "<div class='ItemActions'>\n";
print "<input type='submit' name='Action' value='",
More information about the wine-cvs
mailing list