Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Highlight checked rows

  • Loading branch information...
commit 023b62a39cef91bac4219ad03c6b80739db93b2f 1 parent bf8b620
@vrana authored
View
3  adminer/db.inc.php
@@ -48,7 +48,7 @@
if ($_POST["search"] && $_POST["query"] != "") {
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 '<th>' . lang('Table');
echo '<td>' . lang('Engine');
@@ -89,6 +89,7 @@
echo "<td align='right' id='sum-$key'>&nbsp;";
}
echo "</table>\n";
+ echo "<script type='text/javascript'>tableCheck();</script>\n";
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
$databases = (support("scheme") ? schemas() : get_databases());
View
3  adminer/include/connect.inc.php
@@ -31,7 +31,7 @@ function connect_error() {
$scheme = support("scheme");
$collations = collations();
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";
foreach ($databases as $db) {
$root = h(ME) . "db=" . urlencode($db);
@@ -42,6 +42,7 @@ function connect_error() {
echo "\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 "<input type='hidden' name='token' value='$token'>\n";
echo "<a href='" . h(ME) . "refresh=1' onclick='eventStop(event);'>" . lang('Refresh') . "</a>\n";
View
3  adminer/processlist.inc.php
@@ -13,7 +13,7 @@
?>
<form action="" method="post">
-<table cellspacing="0" onclick="tableClick(event);" class="nowrap">
+<table cellspacing="0" onclick="tableClick(event);" class="nowrap checkable">
<?php
// HTML valid because there is always at least one process
$i = -1;
@@ -29,6 +29,7 @@
}
?>
</table>
+<script type='text/javascript'>tableCheck();</script>
<p>
<?php
if (support("kill")) {
View
3  adminer/select.inc.php
@@ -250,7 +250,7 @@
} else {
$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>");
$names = array();
$functions = array();
@@ -368,6 +368,7 @@
echo "</tr>\n"; // close to allow white-space: pre
}
echo "</table>\n";
+ echo (!$group && $select ? "" : "<script type='text/javascript'>tableCheck();</script>\n");
}
if ($rows || $page) {
View
3  adminer/static/default.css
@@ -17,7 +17,7 @@ p { margin: .8em 20px 0 0; }
img { vertical-align: middle; border: 0; }
td img { max-width: 200px; max-height: 200px; }
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; }
input[type=image] { vertical-align: middle; }
.version { color: #777; font-size: 67%; }
@@ -33,6 +33,7 @@ input[type=image] { vertical-align: middle; }
.enum { color: #007F7F; }
.binary { color: red; }
.odd td { background: #F5F5F5; }
+.js .checked td, .js .checked th { background: #ddf; }
.time { color: silver; font-size: 70%; }
.function { text-align: right; }
.number { text-align: right; }
View
40 adminer/static/functions.js
@@ -38,6 +38,14 @@ function selectValue(select) {
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
* @param HTMLInputElement
* @param RegExp
@@ -47,6 +55,21 @@ function formCheck(el, name) {
for (var i=0; i < elems.length; i++) {
if (name.test(elems[i].name)) {
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
*/
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
@@ -78,16 +103,23 @@ function formChecked(el, name) {
* @param MouseEvent
*/
function tableClick(event) {
+ var click = true;
var el = event.target || event.srcElement;
while (!/^tr$/i.test(el.tagName)) {
- if (/^(table|a|input|textarea)$/i.test(el.tagName)) {
+ if (/^table$/i.test(el.tagName)) {
return;
}
+ if (/^(a|input|textarea)$/i.test(el.tagName)) {
+ click = false;
+ }
el = el.parentNode;
}
el = el.firstChild.firstChild;
- el.click && el.click();
- el.onclick && el.onclick();
+ if (click) {
+ el.click && el.click();
+ el.onclick && el.onclick();
+ }
+ trCheck(el);
}
/** Set HTML code of an element
View
1  changes.txt
@@ -1,4 +1,5 @@
Adminer 3.3.3-dev:
+Highlight checked rows
Titles of links in database overview and navigation
Fix trigger export (SQLite)
Default trigger statement (SQLite, PostgreSQL)
View
3  editor/db.inc.php
@@ -7,7 +7,7 @@
if ($_POST["query"] != "") {
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";
foreach (table_status() as $table => $row) {
$name = $adminer->tableName($row);
@@ -19,5 +19,6 @@
}
}
echo "</table>\n";
+ echo "<script type='text/javascript'>tableCheck();</script>\n";
echo "</form>\n";
}
Please sign in to comment.
Something went wrong with that request. Please try again.