diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php index 4b0fd844..1b7dec5c 100644 --- a/adminer/include/functions.inc.php +++ b/adminer/include/functions.inc.php @@ -883,15 +883,6 @@ function input($field, $value, $function) { if ($field["type"] == "enum") { echo nbsp($functions[""]) . "" . $adminer->editInput($_GET["edit"], $field, $attrs, $value); } else { - $first = 0; - foreach ($functions as $key => $val) { - if ($key === "" || !$val) { - break; - } - $first++; - } - $onchange = ($first ? " oninput=\"var f = this.form['function[" . h(js_escape(bracket_escape($field["field"]))) . "]']; if ($first > f.selectedIndex) f.selectedIndex = $first;\"" : ""); - $attrs .= $onchange; $has_function = (in_array($function, $functions) || isset($functions[$function])); echo (count($functions) > 1 ? "" @@ -910,10 +901,10 @@ function input($field, $value, $function) { foreach ($matches[1] as $i => $val) { $val = stripcslashes(str_replace("''", "'", $val)); $checked = (is_int($value) ? ($value >> $i) & 1 : in_array($val, explode(",", $value), true)); - echo " '; + echo " '; } } elseif (preg_match('~blob|bytea|raw|file~', $field["type"]) && ini_bool("file_uploads")) { - echo ""; + echo ""; } elseif (($text = preg_match('~text|lob~', $field["type"])) || preg_match("~\n~", $value)) { if ($text && $jush != "sqlite") { $attrs .= " cols='50' rows='12'"; @@ -939,6 +930,17 @@ function input($field, $value, $function) { ; } echo $adminer->editHint($_GET["edit"], $field, $value); + // skip 'original' + $first = 0; + foreach ($functions as $key => $val) { + if ($key === "" || !$val) { + break; + } + $first++; + } + if ($first) { + echo script("mixin(qsl('td'), {onchange: partial(skipOriginal, $first), oninput: function () { this.onchange(); }});"); + } } } diff --git a/adminer/static/functions.js b/adminer/static/functions.js index 04c39e7c..945feca3 100644 --- a/adminer/static/functions.js +++ b/adminer/static/functions.js @@ -538,6 +538,17 @@ function functionChange() { helpClose(); } +/** Skip 'original' when typing +* @param number +* @this HTMLTableCellElement +*/ +function skipOriginal(first) { + var fnSelect = this.previousSibling.firstChild; + if (fnSelect.selectedIndex < first) { + fnSelect.selectedIndex = first; + } +} + /** Add new field in schema-less edit * @this HTMLInputElement */