Highlight checked rows

This commit is contained in:
Jakub Vrana 2011-08-11 13:48:27 +02:00
parent bf8b620560
commit 023b62a39c
8 changed files with 49 additions and 10 deletions

View file

@ -48,7 +48,7 @@ if ($adminer->homepage()) {
if ($_POST["search"] && $_POST["query"] != "") { if ($_POST["search"] && $_POST["query"] != "") {
search_tables(); search_tables();
} }
echo "<table cellspacing='0' class='nowrap' onclick='tableClick(event);'>\n"; echo "<table cellspacing='0' class='nowrap checkable' onclick='tableClick(event);'>\n";
echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^(tables|views)\[/);">'; echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^(tables|views)\[/);">';
echo '<th>' . lang('Table'); echo '<th>' . lang('Table');
echo '<td>' . lang('Engine'); echo '<td>' . lang('Engine');
@ -89,6 +89,7 @@ if ($adminer->homepage()) {
echo "<td align='right' id='sum-$key'>&nbsp;"; echo "<td align='right' id='sum-$key'>&nbsp;";
} }
echo "</table>\n"; echo "</table>\n";
echo "<script type='text/javascript'>tableCheck();</script>\n";
if (!information_schema(DB)) { if (!information_schema(DB)) {
echo "<p>" . ($jush == "sql" ? "<input type='submit' value='" . lang('Analyze') . "'> <input type='submit' name='optimize' value='" . lang('Optimize') . "'> <input type='submit' name='check' value='" . lang('Check') . "'> <input type='submit' name='repair' value='" . lang('Repair') . "'> " : "") . "<input type='submit' name='truncate' value='" . lang('Truncate') . "'" . confirm("formChecked(this, /tables/)") . "> <input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm("formChecked(this, /tables|views/)", 1) . ">\n"; // 1 - eventStop echo "<p>" . ($jush == "sql" ? "<input type='submit' value='" . lang('Analyze') . "'> <input type='submit' name='optimize' value='" . lang('Optimize') . "'> <input type='submit' name='check' value='" . lang('Check') . "'> <input type='submit' name='repair' value='" . lang('Repair') . "'> " : "") . "<input type='submit' name='truncate' value='" . lang('Truncate') . "'" . confirm("formChecked(this, /tables/)") . "> <input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm("formChecked(this, /tables|views/)", 1) . ">\n"; // 1 - eventStop
$databases = (support("scheme") ? schemas() : get_databases()); $databases = (support("scheme") ? schemas() : get_databases());

View file

@ -31,7 +31,7 @@ function connect_error() {
$scheme = support("scheme"); $scheme = support("scheme");
$collations = collations(); $collations = collations();
echo "<form action='' method='post'>\n"; echo "<form action='' method='post'>\n";
echo "<table cellspacing='0' onclick='tableClick(event);'>\n"; echo "<table cellspacing='0' class='checkable' onclick='tableClick(event);'>\n";
echo "<thead><tr><td>&nbsp;<th>" . lang('Database') . "<td>" . lang('Collation') . "<td>" . lang('Tables') . "</thead>\n"; echo "<thead><tr><td>&nbsp;<th>" . lang('Database') . "<td>" . lang('Collation') . "<td>" . lang('Tables') . "</thead>\n";
foreach ($databases as $db) { foreach ($databases as $db) {
$root = h(ME) . "db=" . urlencode($db); $root = h(ME) . "db=" . urlencode($db);
@ -42,6 +42,7 @@ function connect_error() {
echo "\n"; echo "\n";
} }
echo "</table>\n"; echo "</table>\n";
echo "<script type='text/javascript'>tableCheck();</script>\n";
echo "<p><input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm("formChecked(this, /db/)", 1) . ">\n"; // 1 - eventStop echo "<p><input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm("formChecked(this, /db/)", 1) . ">\n"; // 1 - eventStop
echo "<input type='hidden' name='token' value='$token'>\n"; echo "<input type='hidden' name='token' value='$token'>\n";
echo "<a href='" . h(ME) . "refresh=1' onclick='eventStop(event);'>" . lang('Refresh') . "</a>\n"; echo "<a href='" . h(ME) . "refresh=1' onclick='eventStop(event);'>" . lang('Refresh') . "</a>\n";

View file

@ -13,7 +13,7 @@ page_header(lang('Process list'), $error);
?> ?>
<form action="" method="post"> <form action="" method="post">
<table cellspacing="0" onclick="tableClick(event);" class="nowrap"> <table cellspacing="0" onclick="tableClick(event);" class="nowrap checkable">
<?php <?php
// HTML valid because there is always at least one process // HTML valid because there is always at least one process
$i = -1; $i = -1;
@ -29,6 +29,7 @@ foreach (process_list() as $i => $row) {
} }
?> ?>
</table> </table>
<script type='text/javascript'>tableCheck();</script>
<p> <p>
<?php <?php
if (support("kill")) { if (support("kill")) {

View file

@ -250,7 +250,7 @@ if (!$columns) {
} else { } else {
$backward_keys = $adminer->backwardKeys($TABLE, $table_name); $backward_keys = $adminer->backwardKeys($TABLE, $table_name);
echo "<table cellspacing='0' class='nowrap' onclick='tableClick(event);' onkeydown='return editingKeydown(event);'>\n"; echo "<table cellspacing='0' class='nowrap checkable' onclick='tableClick(event);' onkeydown='return editingKeydown(event);'>\n";
echo "<thead><tr>" . (!$group && $select ? "" : "<td><input type='checkbox' id='all-page' onclick='formCheck(this, /check/);'> <a href='" . h($_GET["modify"] ? remove_from_uri("modify") : $_SERVER["REQUEST_URI"] . "&modify=1") . "'>" . lang('edit') . "</a>"); echo "<thead><tr>" . (!$group && $select ? "" : "<td><input type='checkbox' id='all-page' onclick='formCheck(this, /check/);'> <a href='" . h($_GET["modify"] ? remove_from_uri("modify") : $_SERVER["REQUEST_URI"] . "&modify=1") . "'>" . lang('edit') . "</a>");
$names = array(); $names = array();
$functions = array(); $functions = array();
@ -368,6 +368,7 @@ if (!$columns) {
echo "</tr>\n"; // close to allow white-space: pre echo "</tr>\n"; // close to allow white-space: pre
} }
echo "</table>\n"; echo "</table>\n";
echo (!$group && $select ? "" : "<script type='text/javascript'>tableCheck();</script>\n");
} }
if ($rows || $page) { if ($rows || $page) {

View file

@ -17,7 +17,7 @@ p { margin: .8em 20px 0 0; }
img { vertical-align: middle; border: 0; } img { vertical-align: middle; border: 0; }
td img { max-width: 200px; max-height: 200px; } td img { max-width: 200px; max-height: 200px; }
code { background: #eee; } code { background: #eee; }
tr:hover td, tr:hover th { background: #ddf; } tbody tr:hover td, tbody tr:hover th { background: #eee; }
pre { margin: 1em 0 0; } pre { margin: 1em 0 0; }
input[type=image] { vertical-align: middle; } input[type=image] { vertical-align: middle; }
.version { color: #777; font-size: 67%; } .version { color: #777; font-size: 67%; }
@ -33,6 +33,7 @@ input[type=image] { vertical-align: middle; }
.enum { color: #007F7F; } .enum { color: #007F7F; }
.binary { color: red; } .binary { color: red; }
.odd td { background: #F5F5F5; } .odd td { background: #F5F5F5; }
.js .checked td, .js .checked th { background: #ddf; }
.time { color: silver; font-size: 70%; } .time { color: silver; font-size: 70%; }
.function { text-align: right; } .function { text-align: right; }
.number { text-align: right; } .number { text-align: right; }

View file

@ -38,6 +38,14 @@ function selectValue(select) {
return ((selected.attributes.value || {}).specified ? selected.value : selected.text); return ((selected.attributes.value || {}).specified ? selected.value : selected.text);
} }
/** Set checked class
* @param HTMLInputElement
*/
function trCheck(el) {
var tr = el.parentNode.parentNode;
tr.className = tr.className.replace(/(^|\s)checked(\s|$)/, '$2') + (el.checked ? ' checked' : '');
}
/** Check all elements matching given name /** Check all elements matching given name
* @param HTMLInputElement * @param HTMLInputElement
* @param RegExp * @param RegExp
@ -47,6 +55,21 @@ function formCheck(el, name) {
for (var i=0; i < elems.length; i++) { for (var i=0; i < elems.length; i++) {
if (name.test(elems[i].name)) { if (name.test(elems[i].name)) {
elems[i].checked = el.checked; elems[i].checked = el.checked;
trCheck(elems[i]);
}
}
}
/** Check all rows in <table class="checkable">
*/
function tableCheck() {
var tables = document.getElementsByTagName('table');
for (var i=0; i < tables.length; i++) {
if (/(^|\s)checkable(\s|$)/.test(tables[i].className)) {
var trs = tables[i].getElementsByTagName('tr');
for (var j=0; j < trs.length; j++) {
trCheck(trs[j].firstChild.firstChild);
}
} }
} }
} }
@ -55,7 +78,9 @@ function formCheck(el, name) {
* @param string * @param string
*/ */
function formUncheck(id) { function formUncheck(id) {
document.getElementById(id).checked = false; var el = document.getElementById(id);
el.checked = false;
trCheck(el);
} }
/** Get number of checked elements matching given name /** Get number of checked elements matching given name
@ -78,16 +103,23 @@ function formChecked(el, name) {
* @param MouseEvent * @param MouseEvent
*/ */
function tableClick(event) { function tableClick(event) {
var click = true;
var el = event.target || event.srcElement; var el = event.target || event.srcElement;
while (!/^tr$/i.test(el.tagName)) { while (!/^tr$/i.test(el.tagName)) {
if (/^(table|a|input|textarea)$/i.test(el.tagName)) { if (/^table$/i.test(el.tagName)) {
return; return;
} }
if (/^(a|input|textarea)$/i.test(el.tagName)) {
click = false;
}
el = el.parentNode; el = el.parentNode;
} }
el = el.firstChild.firstChild; el = el.firstChild.firstChild;
el.click && el.click(); if (click) {
el.onclick && el.onclick(); el.click && el.click();
el.onclick && el.onclick();
}
trCheck(el);
} }
/** Set HTML code of an element /** Set HTML code of an element

View file

@ -1,4 +1,5 @@
Adminer 3.3.3-dev: Adminer 3.3.3-dev:
Highlight checked rows
Titles of links in database overview and navigation Titles of links in database overview and navigation
Fix trigger export (SQLite) Fix trigger export (SQLite)
Default trigger statement (SQLite, PostgreSQL) Default trigger statement (SQLite, PostgreSQL)

View file

@ -7,7 +7,7 @@ if ($adminer->homepage()) {
if ($_POST["query"] != "") { if ($_POST["query"] != "") {
search_tables(); search_tables();
} }
echo "<table cellspacing='0' class='nowrap' onclick='tableClick(event);'>\n"; echo "<table cellspacing='0' class='nowrap checkable' onclick='tableClick(event);'>\n";
echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^tables\[/);"><th>' . lang('Table') . '<td>' . lang('Rows') . "</thead>\n"; echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^tables\[/);"><th>' . lang('Table') . '<td>' . lang('Rows') . "</thead>\n";
foreach (table_status() as $table => $row) { foreach (table_status() as $table => $row) {
$name = $adminer->tableName($row); $name = $adminer->tableName($row);
@ -19,5 +19,6 @@ if ($adminer->homepage()) {
} }
} }
echo "</table>\n"; echo "</table>\n";
echo "<script type='text/javascript'>tableCheck();</script>\n";
echo "</form>\n"; echo "</form>\n";
} }