1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-05 22:27:24 +02:00

JS: Unsupport event.srcElement

This commit is contained in:
Jakub Vrana
2025-03-21 23:41:46 +01:00
parent 26db8596aa
commit aaca1eee8e
6 changed files with 19 additions and 27 deletions

View File

@@ -183,7 +183,7 @@ foreach ($engines as $engine) {
<?php
if (support("columns") || $TABLE == "") {
echo lang('Table name') . ": <input name='name'" . ($TABLE == "" && !$_POST ? " autofocus" : "") . " data-maxlength='64' value='" . h($row["name"]) . "' autocapitalize='off'>\n";
echo ($engines ? html_select("Engine", array("" => "(" . lang('engine') . ")") + $engines, $row["Engine"]) . on_help("getTarget(event).value", 1) . script("qsl('select').onchange = helpClose;") . "\n" : "");
echo ($engines ? html_select("Engine", array("" => "(" . lang('engine') . ")") + $engines, $row["Engine"]) . on_help("event.target.value", 1) . script("qsl('select').onchange = helpClose;") . "\n" : "");
if ($collations) {
echo "<datalist id='collations'>" . optionlist($collations) . "</datalist>";
echo (preg_match("~sqlite|mssql~", JUSH) ? "" : "<input list='collations' name='Collation' value='" . h($row["Collation"]) . "' placeholder='(" . lang('collation') . ")'>");
@@ -221,7 +221,7 @@ if (support("columns")) {
if (support("partitioning")) {
$partition_table = preg_match('~RANGE|LIST~', $row["partition_by"]);
print_fieldset("partition", lang('Partition by'), $row["partition_by"]);
echo "<p>" . html_select("partition_by", array("" => "") + $partition_by, $row["partition_by"]) . on_help("getTarget(event).value.replace(/./, 'PARTITION BY \$&')", 1) . script("qsl('select').onchange = partitionByChange;");
echo "<p>" . html_select("partition_by", array("" => "") + $partition_by, $row["partition_by"]) . on_help("event.target.value.replace(/./, 'PARTITION BY \$&')", 1) . script("qsl('select').onchange = partitionByChange;");
echo "(<input name='partition' value='" . h($row["partition"]) . "'>)\n";
echo lang('Partitions') . ": <input type='number' name='partitions' class='size" . ($partition_table || !$row["partition_by"] ? " hidden" : "") . "' value='" . h($row["partitions"]) . "'>\n";
echo "<table id='partition-table'" . ($partition_table ? "" : " class='hidden'") . ">\n";

View File

@@ -387,7 +387,7 @@ class Adminer {
($key !== "" ? "selectFieldChange" : "selectAddRow")
);
echo "<div>" . ($driver->functions || $driver->grouping ? html_select("columns[$i][fun]", array(-1 => "") + array_filter(array(lang('Functions') => $driver->functions, lang('Aggregation') => $driver->grouping)), $val["fun"])
. on_help("getTarget(event).value && getTarget(event).value.replace(/ |\$/, '(') + ')'", 1)
. on_help("event.target.value && event.target.value.replace(/ |\$/, '(') + ')'", 1)
. script("qsl('select').onchange = function () { helpClose();" . ($key !== "" ? "" : " qsl('select, input', this.parentNode).onchange();") . " };", "")
. "($column)" : $column) . "</div>\n";
$i++;

View File

@@ -280,7 +280,7 @@ function input($field, $value, $function, $autofocus = false) {
$has_function = (in_array($function, $functions) || isset($functions[$function]));
echo (count($functions) > 1
? "<select name='function[$name]'$disabled>" . optionlist($functions, $function === null || $has_function ? $function : "") . "</select>"
. on_help("getTarget(event).value.replace(/^SQL\$/, '')", 1)
. on_help("event.target.value.replace(/^SQL\$/, '')", 1)
. script("qsl('select').onchange = functionChange;", "")
: h(reset($functions))
) . '<td>';

View File

@@ -237,7 +237,7 @@ function editFields() {
},
onchange: editingTypeChange,
onmouseover: function (event) {
helpMouseover.call(this, event, getTarget(event).value, 1);
helpMouseover.call(this, event, event.target.value, 1);
},
onmouseout: helpMouseout
});
@@ -249,7 +249,7 @@ function editFields() {
* @return boolean false to cancel action
*/
function editingClick(event) {
let el = getTarget(event);
let el = event.target;
if (!isTag(el, 'input')) {
el = parentTag(el, 'label');
el = el && qs('input', el);
@@ -282,7 +282,7 @@ function editingClick(event) {
* @param InputEvent
*/
function editingInput(event) {
const el = getTarget(event);
const el = event.target;
if (/\[default]$/.test(el.name)) {
el.previousElementSibling.checked = true;
el.previousElementSibling.selectedIndex = Math.max(el.previousElementSibling.selectedIndex, 1);
@@ -546,7 +546,7 @@ function editingCommentsClick(el, focus) {
* @this HTMLTableElement
*/
function dumpClick(event) {
let el = parentTag(getTarget(event), 'label');
let el = parentTag(event.target, 'label');
if (el) {
el = qs('input', el);
const match = /(.+)\[]$/.exec(el.name);
@@ -758,7 +758,7 @@ let helpOpen, helpIgnore; // when mouse outs <option> then it mouse overs border
* @this HTMLElement
*/
function helpMouseover(event, text, side) {
const target = getTarget(event);
const target = event.target;
if (!text) {
helpClose();
} else if (window.jush && (!helpIgnore || this != target)) {
@@ -780,7 +780,7 @@ function helpMouseover(event, text, side) {
*/
function helpMouseout(event) {
helpOpen = 0;
helpIgnore = (this != getTarget(event));
helpIgnore = (this != event.target);
setTimeout(() => {
if (!helpOpen) {
helpClose();

View File

@@ -232,7 +232,7 @@ function formChecked(input, name) {
* @param [boolean] force click
*/
function tableClick(event, click) {
const td = parentTag(getTarget(event), 'td');
const td = parentTag(event.target, 'td');
let text;
if (td && (text = td.getAttribute('data-text'))) {
if (selectClick.call(td, event, +text, td.getAttribute('data-warning'))) {
@@ -240,7 +240,7 @@ function tableClick(event, click) {
}
}
click = (click || !window.getSelection || getSelection().isCollapsed);
let el = getTarget(event);
let el = event.target;
while (!isTag(el, 'tr')) {
if (isTag(el, 'table|a|input|textarea')) {
if (el.type != 'checkbox') {
@@ -345,7 +345,7 @@ function pageClick(href, page) {
* @this HTMLElement
*/
function menuOver(event) {
const a = getTarget(event);
const a = event.target;
if (isTag(a, 'a|span') && a.offsetLeft + a.offsetWidth > a.parentNode.offsetWidth - 15) { // 15 - ellipsis
this.style.overflow = 'visible';
}
@@ -452,14 +452,6 @@ function isCtrl(event) {
return (event.ctrlKey || event.metaKey) && !event.altKey; // shiftKey allowed
}
/** Return event target
* @param Event
* @return HTMLElement
*/
function getTarget(event) {
return event.target || event.srcElement;
}
/** Send form by Ctrl+Enter on <select> and <textarea>
@@ -469,7 +461,7 @@ function getTarget(event) {
*/
function bodyKeydown(event, button) {
eventStop(event);
let target = getTarget(event);
let target = event.target;
if (target.jushTextarea) {
target = target.jushTextarea;
}
@@ -493,7 +485,7 @@ function bodyKeydown(event, button) {
* @param MouseEvent
*/
function bodyClick(event) {
const target = getTarget(event);
const target = event.target;
if ((isCtrl(event) || event.shiftKey) && target.type == 'submit' && isTag(target, 'input')) {
target.form.target = '_blank';
setTimeout(() => {
@@ -511,7 +503,7 @@ function bodyClick(event) {
*/
function editingKeydown(event) {
if ((event.keyCode == 40 || event.keyCode == 38) && isCtrl(event)) { // 40 - Down, 38 - Up
const target = getTarget(event);
const target = event.target;
const sibling = (event.keyCode == 40 ? 'nextSibling' : 'previousSibling');
let el = target.parentNode.parentNode[sibling];
if (el && (isTag(el, 'tr') || (el = el[sibling])) && isTag(el, 'tr') && (el = el.childNodes[nodePosition(target.parentNode)]) && (el = el.childNodes[nodePosition(target)])) {
@@ -618,7 +610,7 @@ function ajax(url, callback, data, message) {
}
request.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
request.onreadystatechange = () => {
if (request.readyState == 4) { // 4 - DONE
if (request.readyState == 4) {
if (/^2/.test(request.status)) {
callback(request);
} else {
@@ -690,7 +682,7 @@ function ajaxForm(form, message, button) {
*/
function selectClick(event, text, warning) {
const td = this;
const target = getTarget(event);
const target = event.target;
if (!isCtrl(event) || isTag(td.firstChild, 'input|textarea') || isTag(target, 'a')) {
return;
}

View File

@@ -45,7 +45,7 @@ function whisper(url) {
*/
function whisperClick(event) {
const field = this.previousSibling;
const el = getTarget(event);
const el = event.target;
if (isTag(el, 'a') && !(event.button || event.shiftKey || event.altKey || isCtrl(event))) {
field.value = el.firstChild.data;
field.previousSibling.value = decodeURIComponent(el.href.replace(/.*=/, ''));