mirror of
https://github.com/vrana/adminer.git
synced 2025-08-09 08:06:59 +02:00
Move inline event handlers to <script>
This commit is contained in:
@@ -297,8 +297,9 @@ if (!$columns && support("table")) {
|
|||||||
} else {
|
} else {
|
||||||
$backward_keys = $adminer->backwardKeys($TABLE, $table_name);
|
$backward_keys = $adminer->backwardKeys($TABLE, $table_name);
|
||||||
|
|
||||||
echo "<table id='table' cellspacing='0' class='nowrap checkable' onclick='tableClick(event);' ondblclick='tableClick(event, true);' onkeydown='return editingKeydown(event);'>\n";
|
echo "<table id='table' cellspacing='0' class='nowrap checkable'>";
|
||||||
echo "<thead><tr>" . (!$group && $select ? "" : "<td><input type='checkbox' id='all-page' onclick='formCheck.call(this, /check/);' class='jsonly'> <a href='" . h($_GET["modify"] ? remove_from_uri("modify") : $_SERVER["REQUEST_URI"] . "&modify=1") . "'>" . lang('Modify') . "</a>");
|
echo "<script>mixin(qs('#table'), {onclick: tableClick, ondblclick: partialArg(tableClick, true), onkeydown: editingKeydown});</script>\n";
|
||||||
|
echo "<thead><tr>" . (!$group && $select ? "" : "<td><input type='checkbox' id='all-page' class='jsonly'><script>qs('#all-page').onclick = partial(formCheck, /check/);</script> <a href='" . h($_GET["modify"] ? remove_from_uri("modify") : $_SERVER["REQUEST_URI"] . "&modify=1") . "'>" . lang('Modify') . "</a>");
|
||||||
$names = array();
|
$names = array();
|
||||||
$functions = array();
|
$functions = array();
|
||||||
reset($select);
|
reset($select);
|
||||||
@@ -314,13 +315,14 @@ if (!$columns && support("table")) {
|
|||||||
$column = idf_escape($key);
|
$column = idf_escape($key);
|
||||||
$href = remove_from_uri('(order|desc)[^=]*|page') . '&order%5B0%5D=' . urlencode($key);
|
$href = remove_from_uri('(order|desc)[^=]*|page') . '&order%5B0%5D=' . urlencode($key);
|
||||||
$desc = "&desc%5B0%5D=1";
|
$desc = "&desc%5B0%5D=1";
|
||||||
echo '<th onmouseover="columnMouse.call(this);" onmouseout="columnMouse.call(this, \' hidden\');">';
|
echo "<th><script>mixin(qsl('th'), {onmouseover: partial(columnMouse), onmouseout: partial(columnMouse, ' hidden')});</script>";
|
||||||
echo '<a href="' . h($href . ($order[0] == $column || $order[0] == $key || (!$order && $is_group && $group[0] == $column) ? $desc : '')) . '">'; // $order[0] == $key - COUNT(*)
|
echo '<a href="' . h($href . ($order[0] == $column || $order[0] == $key || (!$order && $is_group && $group[0] == $column) ? $desc : '')) . '">'; // $order[0] == $key - COUNT(*)
|
||||||
echo apply_sql_function($val["fun"], $name) . "</a>"; //! columns looking like functions
|
echo apply_sql_function($val["fun"], $name) . "</a>"; //! columns looking like functions
|
||||||
echo "<span class='column hidden'>";
|
echo "<span class='column hidden'>";
|
||||||
echo "<a href='" . h($href . $desc) . "' title='" . lang('descending') . "' class='text'> ↓</a>";
|
echo "<a href='" . h($href . $desc) . "' title='" . lang('descending') . "' class='text'> ↓</a>";
|
||||||
if (!$val["fun"]) {
|
if (!$val["fun"]) {
|
||||||
echo '<a href="#fieldset-search" onclick="selectSearch(\'' . h(js_escape($key)) . '\'); return false;" title="' . lang('Search') . '" class="text jsonly"> =</a>';
|
echo '<a href="#fieldset-search" title="' . lang('Search') . '" class="text jsonly"> =</a>';
|
||||||
|
echo "<script>qsl('a').onclick = partial(selectSearch, '" . h(js_escape($key)) . "');</script>";
|
||||||
}
|
}
|
||||||
echo "</span>";
|
echo "</span>";
|
||||||
}
|
}
|
||||||
@@ -419,7 +421,8 @@ if (!$columns && support("table")) {
|
|||||||
echo "<td>" . ($text ? "<textarea name='$id' cols='30' rows='" . (substr_count($row[$key], "\n") + 1) . "'>$h_value</textarea>" : "<input name='$id' value='$h_value' size='$lengths[$key]'>");
|
echo "<td>" . ($text ? "<textarea name='$id' cols='30' rows='" . (substr_count($row[$key], "\n") + 1) . "'>$h_value</textarea>" : "<input name='$id' value='$h_value' size='$lengths[$key]'>");
|
||||||
} else {
|
} else {
|
||||||
$long = strpos($val, "<i>...</i>");
|
$long = strpos($val, "<i>...</i>");
|
||||||
echo "<td id='$id' onclick=\"selectClick.call(this, event, " . ($long ? 2 : ($text ? 1 : 0)) . ($editable ? "" : ", '" . h(lang('Use edit link to modify this value.')) . "'") . ");\">$val";
|
echo "<td id='$id'>$val</td>";
|
||||||
|
echo "<script>qsl('td').onclick = partialArg(selectClick, " . ($long ? 2 : ($text ? 1 : 0)) . ($editable ? "" : ", '" . h(lang('Use edit link to modify this value.')) . "'") . ");</script>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -461,7 +464,8 @@ if (!$columns && support("table")) {
|
|||||||
: floor(($found_rows - 1) / $limit)
|
: floor(($found_rows - 1) / $limit)
|
||||||
);
|
);
|
||||||
if ($jush != "simpledb") {
|
if ($jush != "simpledb") {
|
||||||
echo '<a href="' . h(remove_from_uri("page")) . "\" onclick=\"pageClick(this.href, +prompt('" . lang('Page') . "', '" . ($page + 1) . "'), event); return false;\">" . lang('Page') . "</a>:";
|
echo '<a href="' . h(remove_from_uri("page")) . '">' . lang('Page') . "</a>:";
|
||||||
|
echo "<script>qsl('a').onclick = function () { pageClick(this.href, +prompt('" . lang('Page') . "', '" . ($page + 1) . "')); return false; }</script>\n";
|
||||||
echo pagination(0, $page) . ($page > 5 ? " ..." : "");
|
echo pagination(0, $page) . ($page > 5 ? " ..." : "");
|
||||||
for ($i = max(1, $page - 4); $i < min($max_page, $page + 5); $i++) {
|
for ($i = max(1, $page - 4); $i < min($max_page, $page + 5); $i++) {
|
||||||
echo pagination($i, $page);
|
echo pagination($i, $page);
|
||||||
@@ -474,7 +478,8 @@ if (!$columns && support("table")) {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
echo (($found_rows === false ? count($rows) + 1 : $found_rows - $page * $limit) > $limit
|
echo (($found_rows === false ? count($rows) + 1 : $found_rows - $page * $limit) > $limit
|
||||||
? ' <a href="' . h(remove_from_uri("page") . "&page=" . ($page + 1)) . '" onclick="return !selectLoadMore.call(this, ' . (+$limit) . ', \'' . lang('Loading') . '...\');" class="loadmore">' . lang('Load more data') . '</a>'
|
? ' <a href="' . h(remove_from_uri("page") . "&page=" . ($page + 1)) . '" class="loadmore">' . lang('Load more data') . '</a>'
|
||||||
|
. "<script>qsl('a').onclick = partial(selectLoadMore, " . (+$limit) . ", '" . lang('Loading') . "...');</script>"
|
||||||
: ''
|
: ''
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -11,7 +11,7 @@ h3 { font-weight: normal; font-size: 130%; margin: 1em 0 0; }
|
|||||||
form { margin: 0; }
|
form { margin: 0; }
|
||||||
td table { width: 100%; margin: 0; }
|
td table { width: 100%; margin: 0; }
|
||||||
table { margin: 1em 20px 0 0; border: 0; border-top: 1px solid #999; border-left: 1px solid #999; font-size: 90%; }
|
table { margin: 1em 20px 0 0; border: 0; border-top: 1px solid #999; border-left: 1px solid #999; font-size: 90%; }
|
||||||
td, th { border: 0; border-right: 1px solid #999; border-bottom: 1px solid #999; padding: .2em .3em; }
|
td, th {border: 0;border-right: 1px solid #999;border-bottom: 1px solid #999;padding: .2em .3em;}
|
||||||
th { background: #eee; text-align: left; }
|
th { background: #eee; text-align: left; }
|
||||||
thead th { text-align: center; padding: .2em .5em; }
|
thead th { text-align: center; padding: .2em .5em; }
|
||||||
thead td, thead th { background: #ddf; }
|
thead td, thead th { background: #ddf; }
|
||||||
|
@@ -7,6 +7,15 @@ function qs(selector) {
|
|||||||
return document.querySelector(selector);
|
return document.querySelector(selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get last element by selector
|
||||||
|
* @param string
|
||||||
|
* @return HTMLElement
|
||||||
|
*/
|
||||||
|
function qsl(selector) {
|
||||||
|
var els = qsa(selector, document);
|
||||||
|
return els[els.length - 1];
|
||||||
|
}
|
||||||
|
|
||||||
/** Get all elements by selector
|
/** Get all elements by selector
|
||||||
* @param string
|
* @param string
|
||||||
* @param HTMLElement
|
* @param HTMLElement
|
||||||
@@ -16,6 +25,41 @@ function qsa(selector, context) {
|
|||||||
return context.querySelectorAll(selector);
|
return context.querySelectorAll(selector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Return a function calling fn with the next arguments
|
||||||
|
* @param function
|
||||||
|
* @param ...
|
||||||
|
* @return function with preserved this
|
||||||
|
*/
|
||||||
|
function partial(fn) {
|
||||||
|
var args = Array.apply(null, arguments).slice(1);
|
||||||
|
return function () {
|
||||||
|
return fn.apply(this, args);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Return a function calling fn with the first parameter and then the next arguments
|
||||||
|
* @param function
|
||||||
|
* @param ...
|
||||||
|
* @return function with preserved this
|
||||||
|
*/
|
||||||
|
function partialArg(fn) {
|
||||||
|
var args = Array.apply(null, arguments);
|
||||||
|
return function (arg) {
|
||||||
|
args[0] = arg;
|
||||||
|
return fn.apply(this, args);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Assign values from source to target
|
||||||
|
* @param Object
|
||||||
|
* @param Object
|
||||||
|
*/
|
||||||
|
function mixin(target, source) {
|
||||||
|
for (var key in source) {
|
||||||
|
target[key] = source[key];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Add or remove CSS class
|
/** Add or remove CSS class
|
||||||
* @param HTMLElement
|
* @param HTMLElement
|
||||||
* @param string
|
* @param string
|
||||||
@@ -279,12 +323,10 @@ function nodePosition(el) {
|
|||||||
/** Go to the specified page
|
/** Go to the specified page
|
||||||
* @param string
|
* @param string
|
||||||
* @param string
|
* @param string
|
||||||
* @param [MouseEvent]
|
|
||||||
*/
|
*/
|
||||||
function pageClick(href, page, event) {
|
function pageClick(href, page) {
|
||||||
if (!isNaN(page) && page) {
|
if (!isNaN(page) && page) {
|
||||||
href += (page != 1 ? '&page=' + (page - 1) : '');
|
location.href = href + (page != 1 ? '&page=' + (page - 1) : '');
|
||||||
location.href = href;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -377,6 +419,7 @@ function columnMouse(className) {
|
|||||||
|
|
||||||
/** Fill column in search field
|
/** Fill column in search field
|
||||||
* @param string
|
* @param string
|
||||||
|
* @return boolean false
|
||||||
*/
|
*/
|
||||||
function selectSearch(name) {
|
function selectSearch(name) {
|
||||||
var el = qs('#fieldset-search');
|
var el = qs('#fieldset-search');
|
||||||
@@ -393,6 +436,7 @@ function selectSearch(name) {
|
|||||||
div.firstChild.onchange();
|
div.firstChild.onchange();
|
||||||
}
|
}
|
||||||
div.lastChild.focus();
|
div.lastChild.focus();
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -685,7 +729,7 @@ function selectClick(event, text, warning) {
|
|||||||
/** Load and display next page in select
|
/** Load and display next page in select
|
||||||
* @param number
|
* @param number
|
||||||
* @param string
|
* @param string
|
||||||
* @return boolean
|
* @return boolean false for success
|
||||||
* @this HTMLLinkElement
|
* @this HTMLLinkElement
|
||||||
*/
|
*/
|
||||||
function selectLoadMore(limit, loading) {
|
function selectLoadMore(limit, loading) {
|
||||||
@@ -695,7 +739,7 @@ function selectLoadMore(limit, loading) {
|
|||||||
a.innerHTML = loading;
|
a.innerHTML = loading;
|
||||||
if (href) {
|
if (href) {
|
||||||
a.removeAttribute('href');
|
a.removeAttribute('href');
|
||||||
return ajax(href, function (request) {
|
return !ajax(href, function (request) {
|
||||||
var tbody = document.createElement('tbody');
|
var tbody = document.createElement('tbody');
|
||||||
tbody.innerHTML = request.responseText;
|
tbody.innerHTML = request.responseText;
|
||||||
qs('#table').appendChild(tbody);
|
qs('#table').appendChild(tbody);
|
||||||
|
Reference in New Issue
Block a user