1
0
mirror of https://github.com/vrana/adminer.git synced 2025-08-06 06:37:33 +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 <?php
if (support("columns") || $TABLE == "") { 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 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) { if ($collations) {
echo "<datalist id='collations'>" . optionlist($collations) . "</datalist>"; 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') . ")'>"); 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")) { if (support("partitioning")) {
$partition_table = preg_match('~RANGE|LIST~', $row["partition_by"]); $partition_table = preg_match('~RANGE|LIST~', $row["partition_by"]);
print_fieldset("partition", lang('Partition by'), $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 "(<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 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"; echo "<table id='partition-table'" . ($partition_table ? "" : " class='hidden'") . ">\n";

View File

@@ -387,7 +387,7 @@ class Adminer {
($key !== "" ? "selectFieldChange" : "selectAddRow") ($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"]) 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();") . " };", "") . script("qsl('select').onchange = function () { helpClose();" . ($key !== "" ? "" : " qsl('select, input', this.parentNode).onchange();") . " };", "")
. "($column)" : $column) . "</div>\n"; . "($column)" : $column) . "</div>\n";
$i++; $i++;

View File

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

View File

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

View File

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

View File

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