]> git.joonet.de Git - adminer.git/commitdiff
Use <script> instead of inline event handler in on_help()
authorJakub Vrana <jakub@vrana.cz>
Fri, 12 Jan 2018 17:11:00 +0000 (18:11 +0100)
committerJakub Vrana <jakub@vrana.cz>
Fri, 12 Jan 2018 17:11:00 +0000 (18:11 +0100)
adminer/create.inc.php
adminer/db.inc.php
adminer/include/adminer.inc.php
adminer/include/editing.inc.php
adminer/include/functions.inc.php

index 187addcef7ecab78e28d8b99292e2f182dce4dbf..9fbf5d8fe116d8141112a3ef85b07b8ce9113595 100644 (file)
@@ -164,7 +164,7 @@ foreach ($engines as $engine) {
 <?php if (support("columns") || $TABLE == "") { ?>
 <?php echo lang('Table name'); ?>: <input name="name" maxlength="64" value="<?php echo h($row["name"]); ?>" autocapitalize="off">
 <?php if ($TABLE == "" && !$_POST) { echo script("focus(qs('#form')['name']);"); } ?>
-<?php echo ($engines ? "<select name='Engine'" . on_help("getTarget(event).value", 1) . ">" . optionlist(array("" => "(" . lang('engine') . ")") + $engines, $row["Engine"]) . "</select>" . script("qsl('select').onchange = helpClose;") : ""); ?>
+<?php echo ($engines ? "<select name='Engine'>" . optionlist(array("" => "(" . lang('engine') . ")") + $engines, $row["Engine"]) . "</select>" . on_help("getTarget(event).value", 1) . script("qsl('select').onchange = helpClose;") : ""); ?>
  <?php echo ($collations && !preg_match("~sqlite|mssql~", $jush) ? html_select("Collation", array("" => "(" . lang('collation') . ")") + $collations, $row["Collation"]) : ""); ?>
  <input type="submit" value="<?php echo lang('Save'); ?>">
 <?php } ?>
@@ -205,7 +205,7 @@ if (support("partitioning")) {
        print_fieldset("partition", lang('Partition by'), $row["partition_by"]);
        ?>
 <p>
-<?php echo "<select name='partition_by'" . on_help("getTarget(event).value.replace(/./, 'PARTITION BY \$&')", 1) . ">" . optionlist(array("" => "") + $partition_by, $row["partition_by"]) . "</select>" . script("qsl('select').onchange = partitionByChange;"); ?>
+<?php echo "<select name='partition_by'>" . optionlist(array("" => "") + $partition_by, $row["partition_by"]) . "</select>" . on_help("getTarget(event).value.replace(/./, 'PARTITION BY \$&')", 1) . script("qsl('select').onchange = partitionByChange;"); ?>
 (<input name="partition" value="<?php echo h($row["partition"]); ?>">)
 <?php echo lang('Partitions'); ?>: <input type="number" name="partitions" class="size<?php echo ($partition_table || !$row["partition_by"] ? " hidden" : ""); ?>" value="<?php echo h($row["partitions"]); ?>">
 <table cellspacing="0" id="partition-table"<?php echo ($partition_table ? "" : " class='hidden'"); ?>>
index 179665478c651cafe24600cedaa4a4fbf34d8c39..0db84e26c936f76c7bf7cffefffe53ff9b235fb8 100644 (file)
@@ -118,17 +118,17 @@ if ($adminer->homepage()) {
 
                        echo "</table>\n";
                        if (!information_schema(DB)) {
-                               $vacuum = "<input type='submit' value='" . lang('Vacuum') . "'" . on_help("'VACUUM'") . "> ";
-                               $optimize = "<input type='submit' name='optimize' value='" . lang('Optimize') . "'" . on_help($jush == "sql" ? "'OPTIMIZE TABLE'" : "'VACUUM OPTIMIZE'") . "> ";
+                               $vacuum = "<input type='submit' value='" . lang('Vacuum') . "'> " . on_help("'VACUUM'");
+                               $optimize = "<input type='submit' name='optimize' value='" . lang('Optimize') . "'> " . on_help($jush == "sql" ? "'OPTIMIZE TABLE'" : "'VACUUM OPTIMIZE'");
                                echo "<fieldset><legend>" . lang('Selected') . " <span id='selected'></span></legend><div>"
                                . ($jush == "sqlite" ? $vacuum
                                : ($jush == "pgsql" ? $vacuum . $optimize
-                               : ($jush == "sql" ? "<input type='submit' value='" . lang('Analyze') . "'" . on_help("'ANALYZE TABLE'") . "> " . $optimize
-                                       . "<input type='submit' name='check' value='" . lang('Check') . "'" . on_help("'CHECK TABLE'") . "> "
-                                       . "<input type='submit' name='repair' value='" . lang('Repair') . "'" . on_help("'REPAIR TABLE'") . "> "
+                               : ($jush == "sql" ? "<input type='submit' value='" . lang('Analyze') . "'> " . on_help("'ANALYZE TABLE'") . $optimize
+                                       . "<input type='submit' name='check' value='" . lang('Check') . "'> " . on_help("'CHECK TABLE'")
+                                       . "<input type='submit' name='repair' value='" . lang('Repair') . "'> " . on_help("'REPAIR TABLE'")
                                : "")))
-                               . "<input type='submit' name='truncate' value='" . lang('Truncate') . "'" . on_help($jush == "sqlite" ? "'DELETE'" : "'TRUNCATE" . ($jush == "pgsql" ? "'" : " TABLE'")) . "> " . confirm()
-                               . "<input type='submit' name='drop' value='" . lang('Drop') . "'" . on_help("'DROP TABLE'") . ">" . confirm() . "\n";
+                               . "<input type='submit' name='truncate' value='" . lang('Truncate') . "'> " . on_help($jush == "sqlite" ? "'DELETE'" : "'TRUNCATE" . ($jush == "pgsql" ? "'" : " TABLE'")) . confirm()
+                               . "<input type='submit' name='drop' value='" . lang('Drop') . "'>" . on_help("'DROP TABLE'") . confirm() . "\n";
                                $databases = (support("scheme") ? $adminer->schemas() : $adminer->databases());
                                if (count($databases) != 1 && $jush != "sqlite") {
                                        $db = (isset($_POST["target"]) ? $_POST["target"] : (support("scheme") ? $_GET["ns"] : DB));
index 8ec7a326be99b6e9f245dba786104e302cc5c60c..7f0143c08b9088d7c40e6a44de8a739a35cfd301 100644 (file)
@@ -319,8 +319,9 @@ class Adminer {
                                $val["col"],
                                ($key !== ""  ? "selectFieldChange" : "selectAddRow")
                        );
-                       echo "<div>" . ($functions || $grouping ? "<select name='columns[$i][fun]'"
-                               . on_help("getTarget(event).value && getTarget(event).value.replace(/ |\$/, '(') + ')'", 1) . ">" . optionlist(array(-1 => "") + array_filter(array(lang('Functions') => $functions, lang('Aggregation') => $grouping)), $val["fun"]) . "</select>"
+                       echo "<div>" . ($functions || $grouping ? "<select name='columns[$i][fun]'>"
+                               . optionlist(array(-1 => "") + array_filter(array(lang('Functions') => $functions, lang('Aggregation') => $grouping)), $val["fun"]) . "</select>"
+                               . on_help("getTarget(event).value && getTarget(event).value.replace(/ |\$/, '(') + ')'", 1)
                                . script("qsl('select').onchange = function () { helpClose();" . ($key !== "" ? "" : " this.nextSibling.nextSibling.nextSibling.onchange();") . " };", "")
                                . "($column)" : $column) . "</div>\n";
                        $i++;
index 4cae2c7050972469364b29e0ae9dc7ac9a377531..1e30c48a20d2b02d957d886e09fb477b3b39d1de 100644 (file)
@@ -141,7 +141,7 @@ function edit_type($key, $field, $collations, $foreign_keys = array()) {
        global $structured_types, $types, $unsigned, $on_actions;
        $type = $field["type"];
        ?>
-<td><select name="<?php echo h($key); ?>[type]" class="type" onfocus="lastType = selectValue(this);" onchange="editingTypeChange(this);"<?php echo on_help("getTarget(event).value", 1); ?> aria-labelledby="label-type"><?php
+<td><select name="<?php echo h($key); ?>[type]" class="type" onfocus="lastType = selectValue(this);" onchange="editingTypeChange(this);" aria-labelledby="label-type"><?php
 if ($type && !isset($types[$type]) && !isset($foreign_keys[$type])) {
        array_unshift($structured_types, $type);
 }
@@ -150,6 +150,7 @@ if ($foreign_keys) {
 }
 echo optionlist($structured_types, $type);
 ?></select>
+<?php echo on_help("getTarget(event).value", 1); ?>
 <td><input name="<?php echo h($key); ?>[length]" value="<?php echo h($field["length"]); ?>" size="3" onfocus="editingLengthFocus.call(this);"<?php echo (!$field["length"] && preg_match('~var(char|binary)$~', $type) ? " class='required'" : ""); ?> onchange="editingLengthChange.call(this);" onkeyup="this.onchange();" aria-labelledby="label-length"><td class="options"><?php //! type="number" with enabled JavaScript
        echo "<select name='" . h($key) . "[collation]'" . (preg_match('~(char|text|enum|set)$~', $type) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')' . optionlist($collations, $field["collation"]) . '</select>';
        echo ($unsigned ? "<select name='" . h($key) . "[unsigned]'" . (!$type || preg_match('~((^|[^o])int|float|double|decimal)$~', $type) ? "" : " class='hidden'") . '><option>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : '');
index 64eeb7b1871e94efee44266d738c547fdc5233f0..527c86108caeee48e6df6333a8fc9446d69a1bf8 100644 (file)
@@ -894,7 +894,8 @@ function input($field, $value, $function) {
                $attrs .= $onchange;
                $has_function = (in_array($function, $functions) || isset($functions[$function]));
                echo (count($functions) > 1
-                       ? "<select name='function[$name]'" . on_help("getTarget(event).value.replace(/^SQL\$/, '')", 1) . ">" . optionlist($functions, $function === null || $has_function ? $function : "") . "</select>"
+                       ? "<select name='function[$name]'>" . optionlist($functions, $function === null || $has_function ? $function : "") . "</select>"
+                               . on_help("getTarget(event).value.replace(/^SQL\$/, '')", 1)
                                . script("qsl('select').onchange = functionChange;", "")
                        : nbsp(reset($functions))
                ) . '<td>';
@@ -1313,7 +1314,7 @@ function lzw_decompress($binary) {
 * @return string
 */
 function on_help($command, $side = 0) {
-       return " onmouseover='helpMouseover.call(this, event, " . h($command) . ", $side);' onmouseout='helpMouseout.call(this, event);'";
+       return script("mixin(qsl('select, input'), {onmouseover: function (event) { helpMouseover.call(this, event, $command, $side) }, onmouseout: helpMouseout});", "");
 }
 
 /** Print edit data form