1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-06 06:37:33 +02:00

Use CSS to highlight odd rows

This commit is contained in:
Jakub Vrana
2025-02-21 21:27:41 +01:00
parent db75be9ba7
commit b29767dcfb
28 changed files with 53 additions and 72 deletions

View File

@@ -66,7 +66,7 @@ if ($adminer->homepage()) {
}
}
echo "<div class='scrollable'>\n";
echo "<table cellspacing='0' class='nowrap checkable'>\n";
echo "<table cellspacing='0' class='nowrap checkable odds'>\n";
echo script("mixin(qsl('table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true)});");
echo '<thead><tr class="wrap">';
echo '<td><input id="check-all" type="checkbox" class="jsonly">' . script("qs('#check-all').onclick = partial(formCheck, /^(tables|views)\[/);", "");
@@ -85,7 +85,7 @@ if ($adminer->homepage()) {
foreach ($tables_list as $name => $type) {
$view = ($type !== null && !preg_match('~table|sequence~i', $type));
$id = h("Table-" . $name);
echo '<tr' . odd() . '><td>' . checkbox(($view ? "views[]" : "tables[]"), $name, in_array($name, $tables_views, true), "", "", "", $id);
echo '<tr><td>' . checkbox(($view ? "views[]" : "tables[]"), $name, in_array($name, $tables_views, true), "", "", "", $id);
echo '<th>' . (support("table") || support("indexes") ? "<a href='" . h(ME) . "table=" . urlencode($name) . "' title='" . lang('Show structure') . "' id='$id'>" . h($name) . '</a>' : h($name));
if ($view) {
echo '<td colspan="6"><a href="' . h(ME) . "view=" . urlencode($name) . '" title="' . lang('Alter view') . '">' . (preg_match('~materialized~i', $type) ? lang('Materialized view') : lang('View')) . '</a>';
@@ -159,12 +159,11 @@ if ($adminer->homepage()) {
echo "<h3 id='routines'>" . lang('Routines') . "</h3>\n";
$routines = routines();
if ($routines) {
echo "<table cellspacing='0'>\n";
echo "<table cellspacing='0' class='odds'>\n";
echo '<thead><tr><th>' . lang('Name') . '<td>' . lang('Type') . '<td>' . lang('Return type') . "<td></thead>\n";
odd('');
foreach ($routines as $row) {
$name = ($row["SPECIFIC_NAME"] == $row["ROUTINE_NAME"] ? "" : "&name=" . urlencode($row["ROUTINE_NAME"])); // not computed on the pages to be able to print the header first
echo '<tr' . odd() . '>';
echo '<tr>';
echo '<th><a href="' . h(ME . ($row["ROUTINE_TYPE"] != "PROCEDURE" ? 'callf=' : 'call=') . urlencode($row["SPECIFIC_NAME"]) . $name) . '">' . h($row["ROUTINE_NAME"]) . '</a>';
echo '<td>' . h($row["ROUTINE_TYPE"]);
echo '<td>' . h($row["DTD_IDENTIFIER"]);
@@ -182,11 +181,10 @@ if ($adminer->homepage()) {
echo "<h3 id='sequences'>" . lang('Sequences') . "</h3>\n";
$sequences = get_vals("SELECT sequence_name FROM information_schema.sequences WHERE sequence_schema = current_schema() ORDER BY sequence_name");
if ($sequences) {
echo "<table cellspacing='0'>\n";
echo "<table cellspacing='0' class='odds'>\n";
echo "<thead><tr><th>" . lang('Name') . "</thead>\n";
odd('');
foreach ($sequences as $val) {
echo "<tr" . odd() . "><th><a href='" . h(ME) . "sequence=" . urlencode($val) . "'>" . h($val) . "</a>\n";
echo "<tr><th><a href='" . h(ME) . "sequence=" . urlencode($val) . "'>" . h($val) . "</a>\n";
}
echo "</table>\n";
}
@@ -197,11 +195,10 @@ if ($adminer->homepage()) {
echo "<h3 id='user-types'>" . lang('User types') . "</h3>\n";
$user_types = types();
if ($user_types) {
echo "<table cellspacing='0'>\n";
echo "<table cellspacing='0' class='odds'>\n";
echo "<thead><tr><th>" . lang('Name') . "</thead>\n";
odd('');
foreach ($user_types as $val) {
echo "<tr" . odd() . "><th><a href='" . h(ME) . "type=" . urlencode($val) . "'>" . h($val) . "</a>\n";
echo "<tr><th><a href='" . h(ME) . "type=" . urlencode($val) . "'>" . h($val) . "</a>\n";
}
echo "</table>\n";
}

View File

@@ -310,10 +310,10 @@ class Adminer {
*/
function tableStructurePrint($fields) {
echo "<div class='scrollable'>\n";
echo "<table cellspacing='0' class='nowrap'>\n";
echo "<table cellspacing='0' class='nowrap odds'>\n";
echo "<thead><tr><th>" . lang('Column') . "<td>" . lang('Type') . (support("comment") ? "<td>" . lang('Comment') : "") . "</thead>\n";
foreach ($fields as $field) {
echo "<tr" . odd() . "><th>" . h($field["field"]);
echo "<tr><th>" . h($field["field"]);
echo "<td><span title='" . h($field["collation"]) . "'>" . h($field["full_type"]) . "</span>";
echo ($field["null"] ? " <i>NULL</i>" : "");
echo ($field["auto_increment"] ? " <i>" . lang('Auto Increment') . "</i>" : "");

View File

@@ -29,7 +29,7 @@ function connect_error() {
$scheme = support("scheme");
$collations = collations();
echo "<form action='' method='post'>\n";
echo "<table cellspacing='0' class='checkable'>\n";
echo "<table cellspacing='0' class='checkable odds'>\n";
echo script("mixin(qsl('table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true)});");
echo "<thead><tr>"
. (support("database") ? "<td>" : "")
@@ -45,7 +45,7 @@ function connect_error() {
foreach ($databases as $db => $tables) {
$root = h(ME) . "db=" . urlencode($db);
$id = h("Db-" . $db);
echo "<tr" . odd() . ">" . (support("database") ? "<td>" . checkbox("db[]", $db, in_array($db, (array) $_POST["db"]), "", "", "", $id) : "");
echo "<tr>" . (support("database") ? "<td>" . checkbox("db[]", $db, in_array($db, (array) $_POST["db"]), "", "", "", $id) : "");
echo "<th><a href='$root' id='$id'>" . h($db) . "</a>";
$collation = h(db_collation($db, $collations));
echo "<td>" . (support("database") ? "<a href='$root" . ($scheme ? "&amp;ns=" : "") . "&amp;database=' title='" . lang('Alter database') . "'>$collation</a>" : $collation);

View File

@@ -16,11 +16,10 @@ function select($result, $connection2 = null, $orgtables = array(), $limit = 0)
$blobs = array(); // colno => bool - display bytes for blobs
$types = array(); // colno => type - display char in <code>
$return = array(); // table => orgtable - mapping to use in EXPLAIN
odd(''); // reset odd for each result
for ($i=0; (!$limit || $i < $limit) && ($row = $result->fetch_row()); $i++) {
if (!$i) {
echo "<div class='scrollable'>\n";
echo "<table cellspacing='0' class='nowrap'>\n";
echo "<table cellspacing='0' class='nowrap odds'>\n";
echo "<thead><tr>";
for ($j=0; $j < count($row); $j++) {
$field = $result->fetch_field();
@@ -61,7 +60,7 @@ function select($result, $connection2 = null, $orgtables = array(), $limit = 0)
}
echo "</thead>\n";
}
echo "<tr" . odd() . ">";
echo "<tr>";
foreach ($row as $key => $val) {
$link = "";
if (isset($links[$key]) && !$columns[$links[$key]]) {

View File

@@ -266,18 +266,6 @@ function bold($bold, $class = "") {
return ($bold ? " class='active $class'" : ($class ? " class='$class'" : ""));
}
/** Generate class for odd rows
* @param string return this for odd rows, empty to reset counter
* @return string
*/
function odd($return = ' class="odd"') {
static $i = 0;
if (!$return) { // reset counter
$i = -1;
}
return ($i++ % 2 ? $return : '');
}
/** Escape string for JavaScript apostrophes
* @param string
* @return string

View File

@@ -14,15 +14,15 @@ echo "<form action=''><p>\n";
hidden_fields_get();
echo "<input type='hidden' name='db' value='" . h(DB) . "'>\n";
echo ($grant ? "" : "<input type='hidden' name='grant' value=''>\n");
echo "<table cellspacing='0'>\n";
echo "<table cellspacing='0' class='odds'>\n";
echo "<thead><tr><th>" . lang('Username') . "<th>" . lang('Server') . "<th></thead>\n";
while ($row = $result->fetch_assoc()) {
echo '<tr' . odd() . '><td>' . h($row["User"]) . "<td>" . h($row["Host"]) . '<td><a href="' . h(ME . 'user=' . urlencode($row["User"]) . '&host=' . urlencode($row["Host"])) . '">' . lang('Edit') . "</a>\n";
echo '<tr><td>' . h($row["User"]) . "<td>" . h($row["Host"]) . '<td><a href="' . h(ME . 'user=' . urlencode($row["User"]) . '&host=' . urlencode($row["Host"])) . '">' . lang('Edit') . "</a>\n";
}
if (!$grant || DB != "") {
echo "<tr" . odd() . "><td><input name='user' autocapitalize='off'><td><input name='host' value='localhost' autocapitalize='off'><td><input type='submit' value='" . lang('Edit') . "'>\n";
echo "<tr><td><input name='user' autocapitalize='off'><td><input name='host' value='localhost' autocapitalize='off'><td><input type='submit' value='" . lang('Edit') . "'>\n";
}
echo "</table>\n";

View File

@@ -16,7 +16,7 @@ page_header(lang('Process list'), $error);
<form action="" method="post">
<div class="scrollable">
<table cellspacing="0" class="nowrap checkable">
<table cellspacing="0" class="nowrap checkable odds">
<?php
echo script("mixin(qsl('table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true)});");
// HTML valid because there is always at least one process
@@ -34,7 +34,7 @@ foreach (process_list() as $i => $row) {
}
echo "</thead>\n";
}
echo "<tr" . odd() . ">" . (support("kill") ? "<td>" . checkbox("kill[]", $row[$jush == "sql" ? "Id" : "pid"], 0) : "");
echo "<tr>" . (support("kill") ? "<td>" . checkbox("kill[]", $row[$jush == "sql" ? "Id" : "pid"], 0) : "");
foreach ($row as $key => $val) {
echo "<td>" . (
($jush == "sql" && $key == "Info" && preg_match("~Query|Killed~", $row["Command"]) && $val != "") ||

View File

@@ -312,7 +312,7 @@ if (!$columns && support("table")) {
$backward_keys = $adminer->backwardKeys($TABLE, $table_name);
echo "<div class='scrollable'>";
echo "<table id='table' cellspacing='0' class='nowrap checkable'>";
echo "<table id='table' cellspacing='0' class='nowrap checkable odds'>";
echo script("mixin(qs('#table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true), onkeydown: editingKeydown});");
echo "<thead><tr>" . (!$group && $select
? ""
@@ -361,9 +361,6 @@ if (!$columns && support("table")) {
echo ($backward_keys ? "<th>" . lang('Relations') : "") . "</thead>\n";
if (is_ajax()) {
if ($limit % 2 == 1 && $page % 2 == 1) {
odd();
}
ob_end_clean();
}
@@ -386,7 +383,7 @@ if (!$columns && support("table")) {
}
$unique_idf .= "&" . ($val !== null ? urlencode("where[" . bracket_escape($key) . "]") . "=" . urlencode($val === false ? "f" : $val) : "null%5B%5D=" . urlencode($key));
}
echo "<tr" . odd() . ">" . (!$group && $select ? "" : "<td>"
echo "<tr>" . (!$group && $select ? "" : "<td>"
. checkbox("check[]", substr($unique_idf, 1), in_array(substr($unique_idf, 1), (array) $_POST["check"]))
. ($is_group || information_schema(DB) ? "" : " <a href='" . h(ME . "edit=" . urlencode($TABLE) . $unique_idf) . "' class='edit'>" . lang('edit') . "</a>")
);

View File

@@ -45,7 +45,7 @@ input.wayoff { left: -1000px; position: absolute; }
.date { color: #7F007F; }
.enum { color: #007F7F; }
.binary { color: red; }
.odd td { background: #F5F5F5; }
.odds tbody tr:nth-child(2n) td { background: #F5F5F5; }
.js .checkable .checked td, .js .checkable .checked th { background: #ddf; }
.time { color: silver; font-size: 70%; }
.function { text-align: right; }

View File

@@ -141,7 +141,7 @@ if ($_POST) {
<?php
//! MAX_* limits, REQUIRE
echo "<table cellspacing='0'>\n";
echo "<table cellspacing='0' class='odds'>\n";
echo "<thead><tr><th colspan='2'>" . lang('Privileges') . doc_link(array('sql' => "grant.html#priv_level"));
$i = 0;
foreach ($grants as $object => $grant) {
@@ -159,7 +159,7 @@ foreach (array(
"Procedures" => lang('Routine'),
) as $context => $desc) {
foreach ((array) $privileges[$context] as $privilege => $comment) {
echo "<tr" . odd() . "><td" . ($desc ? ">$desc<td" : " colspan='2'") . ' lang="en" title="' . h($comment) . '">' . h($privilege);
echo "<tr><td" . ($desc ? ">$desc<td" : " colspan='2'") . ' lang="en" title="' . h($comment) . '">' . h($privilege);
$i = 0;
foreach ($grants as $object => $grant) {
$name = "'grants[$i][" . h(strtoupper($privilege)) . "]'";

File diff suppressed because one or more lines are too long

View File

@@ -175,8 +175,8 @@
background: var(--color-darkPurple);
}
.odd th,
.odd td {
.odds tbody tr:nth-child(2n) th,
.odds tbody tr:nth-child(2n) td {
background: var(--color-darkDraculaVSCode);
}

View File

@@ -133,11 +133,11 @@ th {
background:white;
}
tr.odd td {
.odds tbody tr:nth-child(2n) td {
background:#fcfaf5;
}
#content tbody tr.checked td, tr.checked.odd td {
#content tbody tr.checked td, .odds tbody tr.checked:nth-child(2n) td {
background:#fbe2e2;
color:red;
}

View File

@@ -347,11 +347,11 @@ td{
border-bottom: 1px solid rgba(255, 255, 255, .1);
}
.odd th{
.odds tbody tr:nth-child(2n) th{
background: #222;
}
.odd td{
.odds tbody tr:nth-child(2n) td{
background: #000;
}

View File

@@ -72,7 +72,7 @@ tr:first-child th {padding-right: 30px;}
td:first-child, th:first-child {border-left-width: 0;}
thead td, thead th {background-color: #DFDFDF; border: none; border-bottom: 1px #BBB solid;}
thead tr:hover td, thead tr:hover th {background-color: #DDD !important;}
tr:nth-child(2n) td, tr:nth-child(2n) th, .odd td, .odd th, tr.odd {background-color: #F1F1F1;}
tr:nth-child(2n) td, tr:nth-child(2n) th, .odds tbody tr:nth-child(2n) td, .odds tbody tr:nth-child(2n) th, .odds tbody tr:nth-child(2n) {background-color: #F1F1F1;}
tr:hover td, tr:hover th {background-color: #BCD;}
fieldset {display: inline; vertical-align: top; padding: 2px 12px; margin: 25px 12px 12px 0; border: none; background-color: #F1F1F1; border: 1px solid #E3E3E3; position: relative;}
fieldset, x:-moz-any-link {padding-top: 4px;}

View File

@@ -377,11 +377,11 @@ td{
border-bottom: 1px solid #777;
}
.odd th{
.odds tbody tr:nth-child(2n) th{
background: #33394d;
}
.odd td{
.odds tbody tr:nth-child(2n) td{
background: #33394d;
}

View File

@@ -378,7 +378,7 @@ thead td abbr, thead td sup, thead th acronym, thead th sup {
color: #cdf
}
tr.odd td {
.odds tbody tr:nth-child(2n) td {
background: #fcfaf5
}
@@ -735,7 +735,7 @@ table tbody input ~ a[href*="&edit="][href*="&where"] {
color: #000
}
#content tbody tr.checked td, tr.checked.odd td {
#content tbody tr.checked td, .odds tbody tr.checked:nth-child(2n) td {
background: #fbe2e2;
color: red
}

View File

@@ -153,7 +153,7 @@ th, td {
vertical-align: top;
}
.odd th, .odd td {
.odds tbody tr:nth-child(2n) th, .odds tbody tr:nth-child(2n) td {
background: #FCFAF5;
}

View File

@@ -132,11 +132,11 @@ th {
background:white;
}
tr.odd td {
.odds tbody tr:nth-child(2n) td {
background:#fcfaf5;
}
#content tbody tr.checked td, tr.checked.odd td {
#content tbody tr.checked td, .odds tbody tr:nth-child(2n).checked td {
background:#fbe2e2;
color:red;
}

View File

@@ -187,7 +187,7 @@ td.nowrap {
.binary {
color: red;
}
.odd td {
.odds tbody tr:nth-child(2n) td {
background: transparent;
}
.js .checkable .checked td,

View File

@@ -169,7 +169,7 @@ th {
background:white;
}
tr.odd td {
.odds tbody tr:nth-child(2n) td {
background:#fcfaf5;
}
@@ -181,7 +181,7 @@ tr.odd td {
background: #f2f2f2;
}
#content tbody tr.checked td, tr.checked.odd td {
#content tbody tr.checked td, .odds tbody tr:nth-child(2n).checked td {
background:#fbe2e2;
color:red;
}
@@ -748,7 +748,7 @@ input[type=submit] {
label { margin: 0 8px;}
thead td, thead th{color:#fff;}
#content tbody tr.checked td, tr.checked.odd td {
#content tbody .odds tbody tr:nth-child(2n).checked td, .odds tbody tr:nth-child(2n).checked td {
background: #c8edff;
color: #03A9F4;
}

View File

@@ -65,7 +65,7 @@ thead td, thead th {
border-bottom: 1px #DDD solid; }
.nowrap tr:nth-child(2n) td, .nowrap tr:nth-child(2n) th {
background-color: #DEF; }
.odd td, .odd th {
.odds tbody tr:nth-child(2n) td, .odds tbody tr:nth-child(2n) th {
background-color: #DEF; } /* IEx */
tr.selected td, tr.selected th {
background-color: #ABC !important; }

View File

@@ -136,8 +136,8 @@ table.checkable tbody tr:hover th {
background: #bfb008;
}
.odd th,
.odd td {
.odds tbody tr:nth-child(2n) th,
.odds tbody tr:nth-child(2n) td {
background: #f5f5f5;
}

View File

@@ -58,7 +58,7 @@ table{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-ri
td,th{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;border-color:-moz-use-text-color #999 #999 -moz-use-text-color;border-image:none;border-style:none solid solid none;border-width:0 1px 1px 0;padding:.2em .3em}
thead td,thead th{background:#eee;background:-moz-linear-gradient(top,#eee 0,#ccc 100%);background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#eee),color-stop(100%,#ccc));background:-webkit-linear-gradient(top,#eee 0,#ccc 100%);background:-o-linear-gradient(top,#eee 0,#ccc 100%);background:-ms-linear-gradient(top,#eee 0,#ccc 100%);background:linear-gradient(to bottom,#eee 0,#ccc 100%);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee',endColorstr='#cccccc',GradientType=0)}
td{background-color:#f4f8ff}
.odd td{background-color:#fff}
.odds tbody tr:nth-child(2n) td{background-color:#fff}
tbody tr:hover td,tbody tr:hover th{background-color:#FFE}
p.tabs{margin:0 20px 0 0}
.jush-sql{background:0}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -8,7 +8,7 @@ if ($adminer->homepage()) {
search_tables();
}
echo "<div class='scrollable'>\n";
echo "<table cellspacing='0' class='nowrap checkable'>\n";
echo "<table cellspacing='0' class='nowrap checkable odds'>\n";
echo script("mixin(qsl('table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true)});");
echo '<thead><tr class="wrap">';
echo '<td><input id="check-all" type="checkbox" class="jsonly">' . script("qs('#check-all').onclick = partial(formCheck, /^tables\[/);", "");
@@ -19,7 +19,7 @@ if ($adminer->homepage()) {
foreach (table_status() as $table => $row) {
$name = $adminer->tableName($row);
if (isset($row["Engine"]) && $name != "") {
echo '<tr' . odd() . '><td>' . checkbox("tables[]", $table, in_array($table, (array) $_POST["tables"], true));
echo '<tr><td>' . checkbox("tables[]", $table, in_array($table, (array) $_POST["tables"], true));
echo "<th><a href='" . h(ME) . 'select=' . urlencode($table) . "'>$name</a>";
$val = format_number($row["Rows"]);
echo "<td align='right'><a href='" . h(ME . "edit=") . urlencode($table) . "'>" . ($row["Engine"] == "InnoDB" && $val ? "~ $val" : $val) . "</a>";

View File

@@ -14,10 +14,10 @@ class AdminerTableStructure {
*/
function tableStructurePrint($fields) {
echo "<div class='scrollable'>\n";
echo "<table cellspacing='0' class='nowrap'>\n";
echo "<table cellspacing='0' class='nowrap odds'>\n";
echo "<thead><tr><th>" . lang('Column') . "<th>" . lang('Type') . "<th>" . lang('Nullable') . "<th>" . lang('Default') . (support("comment") ? "<th>" . lang('Comment') : "") . "</thead>\n";
foreach ($fields as $field) {
echo "<tr" . odd() . "><th>" . h($field["field"]) . ($field["primary"] ? " (PRIMARY)" : "");
echo "<tr><th>" . h($field["field"]) . ($field["primary"] ? " (PRIMARY)" : "");
echo "<td><span>" . h($field["full_type"]) . "</span>";
echo ($field["auto_increment"] ? " <i>" . lang('Auto Increment') . "</i>" : "");
echo ($field["collation"] ? " <i>" . h($field["collation"]) . "</i>" : "");