]> git.joonet.de Git - adminer.git/commitdiff
Use @this in JavaScript (prepares for removing inline event handlers)
authorJakub Vrana <jakub@vrana.cz>
Thu, 11 Jan 2018 16:00:39 +0000 (17:00 +0100)
committerJakub Vrana <jakub@vrana.cz>
Thu, 11 Jan 2018 16:01:29 +0000 (17:01 +0100)
18 files changed:
adminer/create.inc.php
adminer/db.inc.php
adminer/dump.inc.php
adminer/foreign.inc.php
adminer/include/adminer.inc.php
adminer/include/connect.inc.php
adminer/include/design.inc.php
adminer/include/editing.inc.php
adminer/include/functions.inc.php
adminer/indexes.inc.php
adminer/schema.inc.php
adminer/select.inc.php
adminer/static/editing.js
adminer/static/functions.js
editor/db.inc.php
editor/include/adminer.inc.php
editor/static/editing.js
plugins/tables-filter.php

index 2b9ebb284afb68270973d9d7c3ce08c55f1c1b6c..93604df9504cd96b0c2c88a8ac174bd219c0113b 100644 (file)
@@ -204,7 +204,7 @@ if (support("partitioning")) {
        print_fieldset("partition", lang('Partition by'), $row["partition_by"]);
        ?>
 <p>
-<?php echo "<select name='partition_by' onchange='partitionByChange(this);'" . on_help("getTarget(event).value.replace(/./, 'PARTITION BY \$&')", 1) . ">" . optionlist(array("" => "") + $partition_by, $row["partition_by"]) . "</select>"; ?>
+<?php echo "<select name='partition_by' onchange='partitionByChange.call(this);'" . on_help("getTarget(event).value.replace(/./, 'PARTITION BY \$&')", 1) . ">" . optionlist(array("" => "") + $partition_by, $row["partition_by"]) . "</select>"; ?>
 (<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'"); ?>>
@@ -212,7 +212,7 @@ if (support("partitioning")) {
 <?php
 foreach ($row["partition_names"] as $key => $val) {
        echo '<tr>';
-       echo '<td><input name="partition_names[]" value="' . h($val) . '"' . ($key == count($row["partition_names"]) - 1 ? ' onchange="partitionNameChange(this);"' : '') . ' autocapitalize="off">';
+       echo '<td><input name="partition_names[]" value="' . h($val) . '"' . ($key == count($row["partition_names"]) - 1 ? ' onchange="partitionNameChange.call(this);"' : '') . ' autocapitalize="off">';
        echo '<td><input name="partition_values[]" value="' . h($row["partition_values"][$key]) . '">';
 }
 ?>
index 8a99310a914cda7affb47b17ded9440849bfbafb..b93ca700d86e9445652d6e1e63fb4688cbbe9916 100644 (file)
@@ -64,7 +64,7 @@ if ($adminer->homepage()) {
                        }
                        $doc_link = doc_link(array('sql' => 'show-table-status.html'));
                        echo "<table cellspacing='0' class='nowrap checkable' onclick='tableClick(event);' ondblclick='tableClick(event, true);'>\n";
-                       echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^(tables|views)\[/);" class="jsonly">';
+                       echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck.call(this, /^(tables|views)\[/);" class="jsonly">';
                        echo '<th>' . lang('Table');
                        echo '<td>' . lang('Engine') . doc_link(array('sql' => 'storage-engines.html'));
                        echo '<td>' . lang('Collation') . doc_link(array('sql' => 'charset-mysql.html'));
@@ -135,7 +135,7 @@ if ($adminer->homepage()) {
                                        echo (support("copy") ? " <input type='submit' name='copy' value='" . lang('Copy') . "'>" : "");
                                        echo "\n";
                                }
-                               echo "<input type='hidden' name='all' value='' onclick=\"selectCount('selected', formChecked(this, /^(tables|views)\[/));" . (support("table") ? " selectCount('selected2', formChecked(this, /^tables\[/) || $tables);" : "") . "\">\n"; // used by trCheck()
+                               echo "<input type='hidden' name='all' value='' onclick=\"selectCount('selected', formChecked.call(this, /^(tables|views)\[/));" . (support("table") ? " selectCount('selected2', formChecked.call(this, /^tables\[/) || $tables);" : "") . "\">\n"; // used by trCheck()
                                echo "<input type='hidden' name='token' value='$token'>\n";
                                echo "</div></fieldset>\n";
                        }
index 0dd819a02641b28197a0d46f7e280471fb009e75..14b59889e9e66ef742155568738580c4391fdf08 100644 (file)
@@ -169,8 +169,8 @@ $prefixes = array();
 if (DB != "") {
        $checked = ($TABLE != "" ? "" : " checked");
        echo "<thead><tr>";
-       echo "<th style='text-align: left;'><label class='block'><input type='checkbox' id='check-tables'$checked onclick='formCheck(this, /^tables\\[/);'>" . lang('Tables') . "</label>";
-       echo "<th style='text-align: right;'><label class='block'>" . lang('Data') . "<input type='checkbox' id='check-data'$checked onclick='formCheck(this, /^data\\[/);'></label>";
+       echo "<th style='text-align: left;'><label class='block'><input type='checkbox' id='check-tables'$checked onclick='formCheck.call(this, /^tables\\[/);'>" . lang('Tables') . "</label>";
+       echo "<th style='text-align: right;'><label class='block'>" . lang('Data') . "<input type='checkbox' id='check-data'$checked onclick='formCheck.call(this, /^data\\[/);'></label>";
        echo "</thead>\n";
 
        $views = "";
@@ -178,11 +178,11 @@ if (DB != "") {
        foreach ($tables_list as $name => $type) {
                $prefix = preg_replace('~_.*~', '', $name);
                $checked = ($TABLE == "" || $TABLE == (substr($TABLE, -1) == "%" ? "$prefix%" : $name)); //! % may be part of table name
-               $print = "<tr><td>" . checkbox("tables[]", $name, $checked, $name, "checkboxClick(event, this); formUncheck('check-tables');", "block");
+               $print = "<tr><td>" . checkbox("tables[]", $name, $checked, $name, "checkboxClick.call(this, event); formUncheck('check-tables');", "block");
                if ($type !== null && !preg_match('~table~i', $type)) {
                        $views .= "$print\n";
                } else {
-                       echo "$print<td align='right'><label class='block'><span id='Rows-" . h($name) . "'></span>" . checkbox("data[]", $name, $checked, "", "checkboxClick(event, this); formUncheck('check-data');") . "</label>\n";
+                       echo "$print<td align='right'><label class='block'><span id='Rows-" . h($name) . "'></span>" . checkbox("data[]", $name, $checked, "", "checkboxClick.call(this, event); formUncheck('check-data');") . "</label>\n";
                }
                $prefixes[$prefix]++;
        }
@@ -193,7 +193,7 @@ if (DB != "") {
        }
 
 } else {
-       echo "<thead><tr><th style='text-align: left;'><label class='block'><input type='checkbox' id='check-databases'" . ($TABLE == "" ? " checked" : "") . " onclick='formCheck(this, /^databases\\[/);'>" . lang('Database') . "</label></thead>\n";
+       echo "<thead><tr><th style='text-align: left;'><label class='block'><input type='checkbox' id='check-databases'" . ($TABLE == "" ? " checked" : "") . " onclick='formCheck.call(this, /^databases\\[/);'>" . lang('Database') . "</label></thead>\n";
        $databases = $adminer->databases();
        if ($databases) {
                foreach ($databases as $db) {
index 07602db404c02cada94e3bf5f63306586054637d..85779357469d87358971d4b819d90c7c8ae4bafa 100644 (file)
@@ -67,7 +67,7 @@ $referencable = array_keys(array_filter(table_status('', true), 'fk_support'));
 $j = 0;
 foreach ($row["source"] as $key => $val) {
        echo "<tr>";
-       echo "<td>" . html_select("source[" . (+$key) . "]", array(-1 => "") + $source, $val, ($j == count($row["source"]) - 1 ? "foreignAddRow(this);" : 1), "label-source");
+       echo "<td>" . html_select("source[" . (+$key) . "]", array(-1 => "") + $source, $val, ($j == count($row["source"]) - 1 ? "foreignAddRow.call(this);" : 1), "label-source");
        echo "<td>" . html_select("target[" . (+$key) . "]", $target, $row["target"][$key], 1, "label-target");
        $j++;
 }
index d997384f62b060b3c70cbf18efd02d9af0bcff68..dde21082c5a0da2b1e6dd1ff21415b1523e1c3f0 100644 (file)
@@ -309,7 +309,7 @@ focus(qs('#username'));
                $select[""] = array();
                foreach ($select as $key => $val) {
                        $val = $_GET["columns"][$key];
-                       $column = select_input(" name='columns[$i][col]' onchange='" . ($key !== ""  ? "selectFieldChange(this.form)" : "selectAddRow(this)") . ";'", $columns, $val["col"]);
+                       $column = select_input(" name='columns[$i][col]' onchange='" . ($key !== ""  ? "selectFieldChange(this.form)" : "selectAddRow.call(this)") . ";'", $columns, $val["col"]);
                        echo "<div>" . ($functions || $grouping ? "<select name='columns[$i][fun]' onchange='helpClose();" . ($key !== "" ? "" : " this.nextSibling.nextSibling.onchange();") . "'"
                                . 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>"
                                . "($column)" : $column) . "</div>\n";
@@ -342,7 +342,7 @@ focus(qs('#username'));
                        if (!$val || ("$val[col]$val[val]" != "" && in_array($val["op"], $this->operators))) {
                                echo "<div>" . select_input(" name='where[$i][col]' onchange='$change_next'", $columns, $val["col"], "(" . lang('anywhere') . ")");
                                echo html_select("where[$i][op]", $this->operators, $val["op"], $change_next);
-                               echo "<input type='search' name='where[$i][val]' value='" . h($val["val"]) . "' onchange='" . ($val ? "selectFieldChange(this.form)" : "selectAddRow(this)") . ";' onkeydown='selectSearchKeydown(this, event);' onsearch='selectSearchSearch(this);'></div>\n";
+                               echo "<input type='search' name='where[$i][val]' value='" . h($val["val"]) . "' onchange='" . ($val ? "selectFieldChange(this.form)" : "selectAddRow.call(this)") . ";' onkeydown='selectSearchKeydown.call(this, event);' onsearch='selectSearchSearch.call(this);'></div>\n";
                        }
                }
                echo "</div></fieldset>\n";
@@ -364,7 +364,7 @@ focus(qs('#username'));
                                $i++;
                        }
                }
-               echo "<div>" . select_input(" name='order[$i]' onchange='selectAddRow(this);'", $columns);
+               echo "<div>" . select_input(" name='order[$i]' onchange='selectAddRow.call(this);'", $columns);
                echo checkbox("desc[$i]", 1, false, lang('descending')) . "</div>\n";
                echo "</div></fieldset>\n";
        }
@@ -852,7 +852,7 @@ focus(qs('#username'));
                                        foreach ($usernames as $username => $password) {
                                                if ($password !== null) {
                                                        if ($first) {
-                                                               echo "<p id='logins' onmouseover='menuOver(this, event);' onmouseout='menuOut(this);'>\n";
+                                                               echo "<p id='logins' onmouseover='menuOver.call(this, event);' onmouseout='menuOut.call(this);'>\n";
                                                                $first = false;
                                                        }
                                                        $dbs = $_SESSION["db"][$vendor][$server][$username];
@@ -924,7 +924,7 @@ bodyLoad('<?php echo (is_object($connection) ? substr($connection->server_info,
 <p id="dbs">
 <?php
                hidden_fields_get();
-               $db_events = " onmousedown='dbMouseDown(event, this);' onchange='dbChange(this);'";
+               $db_events = " onmousedown='dbMouseDown.call(this, event);' onchange='dbChange.call(this);'";
                echo "<span title='" . lang('database') . "'>DB</span>: " . ($databases
                        ? "<select name='db'$db_events>" . optionlist(array("" => "") + $databases, DB) . "</select>"
                        : '<input name="db" value="' . h(DB) . '" autocapitalize="off">'
@@ -951,7 +951,7 @@ bodyLoad('<?php echo (is_object($connection) ? substr($connection->server_info,
        * @return null
        */
        function tablesPrint($tables) {
-               echo "<ul id='tables' onmouseover='menuOver(this, event);' onmouseout='menuOut(this);'>\n";
+               echo "<ul id='tables' onmouseover='menuOver.call(this, event);' onmouseout='menuOut.call(this);'>\n";
                foreach ($tables as $table => $status) {
                        echo '<li><a href="' . h(ME) . 'select=' . urlencode($table) . '"' . bold($_GET["select"] == $table || $_GET["edit"] == $table, "select") . ">" . lang('select') . "</a> ";
                        $name = $this->tableName($status);
index 061475a1ef2434665156ede42f50c08825e7ba0e..400741320b77a647ad9e0ed6db9c09b0d3db717c 100644 (file)
@@ -56,7 +56,7 @@ function connect_error() {
                        echo "</table>\n";
                        echo (support("database")
                                ? "<fieldset><legend>" . lang('Selected') . " <span id='selected'></span></legend><div>\n"
-                                       . "<input type='hidden' name='all' value='' onclick=\"selectCount('selected', formChecked(this, /^db/));\">\n" // used by trCheck()
+                                       . "<input type='hidden' name='all' value='' onclick=\"selectCount('selected', formChecked.call(this, /^db/));\">\n" // used by trCheck()
                                        . "<input type='submit' name='drop' value='" . lang('Drop') . "'" . confirm() . ">\n"
                                        . "</div></fieldset>\n"
                                : ""
index 291273c881d1f5b1f12057fda33f0137e6e0b088..2f40866e6460f68265265cd79612de1c18246b41 100644 (file)
@@ -39,7 +39,7 @@ document.body.className = document.body.className.replace(/ nojs/, ' js');
 var offlineMessage = '<?php echo js_escape(lang('You are offline.')); ?>';
 </script>
 
-<div id="help" class="jush-<?php echo $jush; ?> jsonly hidden" onmouseover="helpOpen = 1;" onmouseout="helpMouseout(this, event);"></div>
+<div id="help" class="jush-<?php echo $jush; ?> jsonly hidden" onmouseover="helpOpen = 1;" onmouseout="helpMouseout.call(this, event);"></div>
 
 <div id="content">
 <?php
index 2d5545f57bc5690b5b4834532088de462d601021..cc50379e88ccb165be0dc3653ab71f4db47236bf 100644 (file)
@@ -150,7 +150,7 @@ if ($foreign_keys) {
 }
 echo optionlist($structured_types, $type);
 ?></select>
-<td><input name="<?php echo h($key); ?>[length]" value="<?php echo h($field["length"]); ?>" size="3" onfocus="editingLengthFocus(this);"<?php echo (!$field["length"] && preg_match('~var(char|binary)$~', $type) ? " class='required'" : ""); ?> onchange="editingLengthChange(this);" onkeyup="this.onchange();" aria-labelledby="label-length"><td class="options"><?php //! type="number" with enabled JavaScript
+<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>' : '');
        echo (isset($field['on_update']) ? "<select name='" . h($key) . "[on_update]'" . (preg_match('~timestamp|datetime~', $type) ? "" : " class='hidden'") . '>' . optionlist(array("" => "(" . lang('ON UPDATE') . ")", "CURRENT_TIMESTAMP"), $field["on_update"]) . '</select>' : '');
@@ -239,7 +239,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
 <thead><tr class="wrap">
 <?php if ($type == "PROCEDURE") { ?><td>&nbsp;<?php } ?>
 <th id="label-name"><?php echo ($type == "TABLE" ? lang('Column name') : lang('Parameter name')); ?>
-<td id="label-type"><?php echo lang('Type'); ?><textarea id="enum-edit" rows="4" cols="12" wrap="off" style="display: none;" onblur="editingLengthBlur(this);"></textarea>
+<td id="label-type"><?php echo lang('Type'); ?><textarea id="enum-edit" rows="4" cols="12" wrap="off" style="display: none;" onblur="editingLengthBlur.call(this);"></textarea>
 <td id="label-length"><?php echo lang('Length'); ?>
 <td><?php echo lang('Options'); /* no label required, options have their own label */ ?>
 <?php if ($type == "TABLE") { ?>
@@ -264,7 +264,7 @@ function edit_fields($fields, $collations, $type = "TABLE", $foreign_keys = arra
                ?>
 <tr<?php echo ($display ? "" : " style='display: none;'"); ?>>
 <?php echo ($type == "PROCEDURE" ? "<td>" . html_select("fields[$i][inout]", explode("|", $inout), $field["inout"]) : ""); ?>
-<th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo h($field["field"]); ?>" onchange="editingNameChange(this);<?php echo ($field["field"] != "" || count($fields) > 1 ? '' : ' editingAddRow(this);" onkeyup="if (this.value) editingAddRow(this);'); ?>" maxlength="64" autocapitalize="off" aria-labelledby="label-name"><?php } ?>
+<th><?php if ($display) { ?><input name="fields[<?php echo $i; ?>][field]" value="<?php echo h($field["field"]); ?>" onchange="editingNameChange.call(this);<?php echo ($field["field"] != "" || count($fields) > 1 ? '' : ' editingAddRow.call(this);" onkeyup="if (this.value) editingAddRow.call(this);'); ?>" maxlength="64" autocapitalize="off" aria-labelledby="label-name"><?php } ?>
 <input type="hidden" name="fields[<?php echo $i; ?>][orig]" value="<?php echo h($orig); ?>">
 <?php edit_type("fields[$i]", $field, $collations, $foreign_keys); ?>
 <?php if ($type == "TABLE") { ?>
@@ -276,11 +276,11 @@ echo checkbox("fields[$i][has_default]", 1, $field["has_default"], "", "", "", "
 <?php
                echo "<td>";
                echo (support("move_col") ?
-                       "<input type='image' class='icon' name='add[$i]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "' onclick='return !editingAddRow(this, 1);'>&nbsp;"
-                       . "<input type='image' class='icon' name='up[$i]' src='../adminer/static/up.gif' alt='^' title='" . lang('Move up') . "' onclick='return !editingMoveRow(this, 1);'>&nbsp;"
-                       . "<input type='image' class='icon' name='down[$i]' src='../adminer/static/down.gif' alt='v' title='" . lang('Move down') . "' onclick='return !editingMoveRow(this, 0);'>&nbsp;"
+                       "<input type='image' class='icon' name='add[$i]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "' onclick='return !editingAddRow.call(this, 1);'>&nbsp;"
+                       . "<input type='image' class='icon' name='up[$i]' src='../adminer/static/up.gif' alt='^' title='" . lang('Move up') . "' onclick='return !editingMoveRow.call(this, 1);'>&nbsp;"
+                       . "<input type='image' class='icon' name='down[$i]' src='../adminer/static/down.gif' alt='v' title='" . lang('Move down') . "' onclick='return !editingMoveRow.call(this, 0);'>&nbsp;"
                : "");
-               echo ($orig == "" || support("drop_col") ? "<input type='image' class='icon' name='drop_col[$i]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "' onclick=\"return !editingRemoveRow(this, 'fields\$1[field]');\">" : "");
+               echo ($orig == "" || support("drop_col") ? "<input type='image' class='icon' name='drop_col[$i]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "' onclick=\"return !editingRemoveRow.call(this, 'fields\$1[field]');\">" : "");
                echo "\n";
        }
 }
index fdca468a96bef3b50f35c68ccb5f88a0b2b6d438..8afff85bf6acb623ef52ef13c6e5f57a05213119 100644 (file)
@@ -878,7 +878,7 @@ function input($field, $value, $function) {
                $attrs .= $onchange;
                $has_function = (in_array($function, $functions) || isset($functions[$function]));
                echo (count($functions) > 1
-                       ? "<select name='function[$name]' onchange='functionChange(this);'" . on_help("getTarget(event).value.replace(/^SQL\$/, '')", 1) . ">" . optionlist($functions, $function === null || $has_function ? $function : "") . "</select>"
+                       ? "<select name='function[$name]' onchange='functionChange.call(this);'" . on_help("getTarget(event).value.replace(/^SQL\$/, '')", 1) . ">" . optionlist($functions, $function === null || $has_function ? $function : "") . "</select>"
                        : nbsp(reset($functions))
                ) . '<td>';
                $input = $adminer->editInput($_GET["edit"], $field, $attrs, $value); // usage in call is without a table
@@ -1296,7 +1296,7 @@ function lzw_decompress($binary) {
 * @return string
 */
 function on_help($command, $side = 0) {
-       return " onmouseover='helpMouseover(this, event, " . h($command) . ", $side);' onmouseout='helpMouseout(this, event);'";
+       return " onmouseover='helpMouseover.call(this, event, " . h($command) . ", $side);' onmouseout='helpMouseout.call(this, event);'";
 }
 
 /** Print edit data form
@@ -1364,7 +1364,7 @@ function edit_form($TABLE, $fields, $row, $update) {
                }
                if (!support("table")) {
                        echo "<tr>"
-                               . "<th><input name='field_keys[]' onkeyup='keyupChange.call(this);' onchange='fieldChange(this);' value=''>" // needs empty value for keyupChange()
+                               . "<th><input name='field_keys[]' onkeyup='keyupChange.call(this);' onchange='fieldChange.call(this);' value=''>" // needs empty value for keyupChange()
                                . "<td class='function'>" . html_select("field_funs[]", $adminer->editFunctions(array("null" => isset($_GET["select"]))))
                                . "<td><input name='field_vals[]'>"
                                . "\n"
index 806e1b6e73e930401fc3726239dc6b5d85a93fe9..1e0f4fbaf7cc31cd9dd11a5f2b2e5bb2243cb235 100644 (file)
@@ -113,14 +113,14 @@ if ($primary) {
 $j = 1;
 foreach ($row["indexes"] as $index) {
        if (!$_POST["drop_col"] || $j != key($_POST["drop_col"])) {
-               echo "<tr><td>" . html_select("indexes[$j][type]", array(-1 => "") + $index_types, $index["type"], ($j == count($row["indexes"]) ? "indexesAddRow(this);" : 1), "label-type");
+               echo "<tr><td>" . html_select("indexes[$j][type]", array(-1 => "") + $index_types, $index["type"], ($j == count($row["indexes"]) ? "indexesAddRow.call(this);" : 1), "label-type");
 
                echo "<td>";
                ksort($index["columns"]);
                $i = 1;
                foreach ($index["columns"] as $key => $column) {
                        echo "<span>" . select_input(
-                               " name='indexes[$j][columns][$i]' onchange=\"" . ($i == count($index["columns"]) ? "indexesAddColumn" : "indexesChangeColumn") . "(this, '" . h(js_escape($jush == "sql" ? "" : $_GET["indexes"] . "_")) . "');\" title='" . lang('Column') . "'",
+                               " name='indexes[$j][columns][$i]' onchange=\"" . ($i == count($index["columns"]) ? "indexesAddColumn" : "indexesChangeColumn") . ".call(this, '" . h(js_escape($jush == "sql" ? "" : $_GET["indexes"] . "_")) . "');\" title='" . lang('Column') . "'",
                                ($fields ? array_combine($fields, $fields) : $fields),
                                $column
                        );
@@ -131,7 +131,7 @@ foreach ($row["indexes"] as $index) {
                }
 
                echo "<td><input name='indexes[$j][name]' value='" . h($index["name"]) . "' autocapitalize='off' aria-labelledby='label-name'>\n";
-               echo "<td><input type='image' class='icon' name='drop_col[$j]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "' onclick=\"return !editingRemoveRow(this, 'indexes\$1[type]');\">\n";
+               echo "<td><input type='image' class='icon' name='drop_col[$j]' src='../adminer/static/cross.gif' alt='x' title='" . lang('Remove') . "' onclick=\"return !editingRemoveRow.call(this, 'indexes\$1[type]');\">\n";
        }
        $j++;
 }
index 6f58a2b46a0e59310bc0a050c3673b82c6b3f3f0..ff80018ebaf28f5ea92a8818c8ba3939660a6972 100644 (file)
@@ -59,7 +59,7 @@ document.onmouseup = function (ev) {
 </script>
 <?php
 foreach ($schema as $name => $table) {
-       echo "<div class='table' style='top: " . $table["pos"][0] . "em; left: " . $table["pos"][1] . "em;' onmousedown='schemaMousedown(this, event);'>";
+       echo "<div class='table' style='top: " . $table["pos"][0] . "em; left: " . $table["pos"][1] . "em;' onmousedown='schemaMousedown.call(this, event);'>";
        echo '<a href="' . h(ME) . 'table=' . urlencode($name) . '"><b>' . h($name) . "</b></a>";
        
        foreach ($table["fields"] as $field) {
index 2d5c79c8200ebb2f95e6421b40edf3c309a357d1..191b28a7c05f6a92ae2a64e76b6ded2fa1a42eae 100644 (file)
@@ -298,7 +298,7 @@ if (!$columns && support("table")) {
                        $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 "<thead><tr>" . (!$group && $select ? "" : "<td><input type='checkbox' id='all-page' onclick='formCheck(this, /check/);' class='jsonly'> <a href='" . h($_GET["modify"] ? remove_from_uri("modify") : $_SERVER["REQUEST_URI"] . "&modify=1") . "'>" . lang('Modify') . "</a>");
+                       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>");
                        $names = array();
                        $functions = array();
                        reset($select);
@@ -314,7 +314,7 @@ if (!$columns && support("table")) {
                                                $column = idf_escape($key);
                                                $href = remove_from_uri('(order|desc)[^=]*|page') . '&order%5B0%5D=' . urlencode($key);
                                                $desc = "&desc%5B0%5D=1";
-                                               echo '<th onmouseover="columnMouse(this);" onmouseout="columnMouse(this, \' hidden\');">';
+                                               echo '<th onmouseover="columnMouse.call(this);" onmouseout="columnMouse.call(this, \' hidden\');">';
                                                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 "<span class='column hidden'>";
@@ -419,7 +419,7 @@ 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]'>");
                                                } else {
                                                        $long = strpos($val, "<i>...</i>");
-                                                       echo "<td id='$id' onclick=\"selectClick(this, event, " . ($long ? 2 : ($text ? 1 : 0)) . ($editable ? "" : ", '" . h(lang('Use edit link to modify this value.')) . "'") . ");\">$val";
+                                                       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";
                                                }
                                        }
                                }
@@ -474,7 +474,7 @@ if (!$columns && support("table")) {
                                                );
                                        }
                                        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(this, ' . (+$limit) . ', \'' . lang('Loading') . '...\');" class="loadmore">' . lang('Load more data') . '</a>'
+                                               ? ' <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>'
                                                : ''
                                        );
                                } else {
@@ -488,7 +488,7 @@ if (!$columns && support("table")) {
                        echo "<p class='count'>\n";
                        echo ($found_rows !== false ? "(" . ($exact_count ? "" : "~ ") . lang('%d row(s)', $found_rows) . ") " : "");
                        $display_rows = ($exact_count ? "" : "~ ") . $found_rows;
-                       echo checkbox("all", 1, 0, lang('whole result'), "var checked = formChecked(this, /check/); selectCount('selected', this.checked ? '$display_rows' : checked); selectCount('selected2', this.checked || !checked ? '$display_rows' : checked);") . "\n";
+                       echo checkbox("all", 1, 0, lang('whole result'), "var checked = formChecked.call(this, /check/); selectCount('selected', this.checked ? '$display_rows' : checked); selectCount('selected2', this.checked || !checked ? '$display_rows' : checked);") . "\n";
 
                        if ($adminer->selectCommandPrint()) {
                                ?>
index e82dd5f40bef8655e9f0b4f59d2d1277f4710c8e..f601124a1fb0cb9176fb386ddf52988cf22cb58e 100644 (file)
@@ -67,27 +67,27 @@ var dbPrevious = {};
 
 /** Check if database should be opened to a new window
 * @param MouseEvent
-* @param HTMLSelectElement
+* @this HTMLSelectElement
 */
-function dbMouseDown(event, el) {
+function dbMouseDown(event) {
        dbCtrl = isCtrl(event);
-       if (dbPrevious[el.name] == undefined) {
-               dbPrevious[el.name] = el.value;
+       if (dbPrevious[this.name] == undefined) {
+               dbPrevious[this.name] = this.value;
        }
 }
 
 /** Load database after selecting it
-* @param HTMLSelectElement
+* @this HTMLSelectElement
 */
-function dbChange(el) {
+function dbChange() {
        if (dbCtrl) {
-               el.form.target = '_blank';
+               this.form.target = '_blank';
        }
-       el.form.submit();
-       el.form.target = '';
-       if (dbCtrl && dbPrevious[el.name] != undefined) {
-               el.value = dbPrevious[el.name];
-               dbPrevious[el.name] = undefined;
+       this.form.submit();
+       this.form.target = '';
+       if (dbCtrl && dbPrevious[this.name] != undefined) {
+               this.value = dbPrevious[this.name];
+               dbPrevious[this.name] = undefined;
        }
 }
 
@@ -172,14 +172,14 @@ function idfEscape(s) {
 }
 
 /** Detect foreign key
-* @param HTMLInputElement
+* @this HTMLInputElement
 */
-function editingNameChange(field) {
-       var name = field.name.substr(0, field.name.length - 7);
-       var type = formField(field.form, name + '[type]');
+function editingNameChange() {
+       var name = this.name.substr(0, this.name.length - 7);
+       var type = formField(this.form, name + '[type]');
        var opts = type.options;
        var candidate; // don't select anything with ambiguous match (like column `id`)
-       var val = field.value;
+       var val = this.value;
        for (var i = opts.length; i--; ) {
                var match = /(.+)`(.+)/.exec(opts[i].value);
                if (!match) { // common type
@@ -209,14 +209,14 @@ function editingNameChange(field) {
 }
 
 /** Add table row for next field
-* @param HTMLInputElement
 * @param boolean
 * @return boolean
+* @this HTMLInputElement
 */
-function editingAddRow(button, focus) {
-       var match = /(\d+)(\.\d+)?/.exec(button.name);
+function editingAddRow(focus) {
+       var match = /(\d+)(\.\d+)?/.exec(this.name);
        var x = match[0] + (match[2] ? added.substr(match[2].length) : added) + '1';
-       var row = parentTag(button, 'tr');
+       var row = parentTag(this, 'tr');
        var row2 = cloneNode(row);
        var tags = qsa('select', row);
        var tags2 = qsa('select', row2);
@@ -240,16 +240,12 @@ function editingAddRow(button, focus) {
                        tags2[i].checked = false;
                }
        }
-       tags[0].onchange = function () {
-               editingNameChange(tags[0]);
-       };
+       tags[0].onchange = editingNameChange;
        tags[0].onkeyup = function () {
        };
        row.parentNode.insertBefore(row2, row.nextSibling);
        if (focus) {
-               input.onchange = function () {
-                       editingNameChange(input);
-               };
+               input.onchange = editingNameChange;
                input.onkeyup = function () {
                };
                input.focus();
@@ -260,24 +256,24 @@ function editingAddRow(button, focus) {
 }
 
 /** Remove table row for field
-* @param HTMLInputElement
 * @param string
 * @return boolean
+* @this HTMLInputElement
 */
-function editingRemoveRow(button, name) {
-       var field = formField(button.form, button.name.replace(/[^\[]+(.+)/, name));
+function editingRemoveRow(name) {
+       var field = formField(this.form, this.name.replace(/[^\[]+(.+)/, name));
        field.parentNode.removeChild(field);
-       parentTag(button, 'tr').style.display = 'none';
+       parentTag(this, 'tr').style.display = 'none';
        return true;
 }
 
 /** Move table row for field
-* @param HTMLInputElement
 * @param boolean direction to move row, true for up or false for down
 * @return boolean
+* @this HTMLInputElement
 */
-function editingMoveRow(button, dir){
-       var row = parentTag(button, 'tr');
+function editingMoveRow(dir){
+       var row = parentTag(this, 'tr');
        if (!('nextElementSibling' in row)) {
                return false;
        }
@@ -326,37 +322,37 @@ function editingTypeChange(type) {
 }
 
 /** Mark length as required
-* @param HTMLInputElement
+* @this HTMLInputElement
 */
-function editingLengthChange(el) {
-       alterClass(el, 'required', !el.value.length && /var(char|binary)$/.test(selectValue(el.parentNode.previousSibling.firstChild)));
+function editingLengthChange() {
+       alterClass(this, 'required', !this.value.length && /var(char|binary)$/.test(selectValue(this.parentNode.previousSibling.firstChild)));
 }
 
 /** Edit enum or set
-* @param HTMLInputElement
+* @this HTMLInputElement
 */
-function editingLengthFocus(field) {
-       var td = field.parentNode;
+function editingLengthFocus() {
+       var td = this.parentNode;
        if (/(enum|set)$/.test(selectValue(td.previousSibling.firstChild))) {
                var edit = qs('#enum-edit');
-               var val = field.value;
+               var val = this.value;
                edit.value = (/^'.+'$/.test(val) ? val.substr(1, val.length - 2).replace(/','/g, "\n").replace(/''/g, "'") : val); //! doesn't handle 'a'',''b' correctly
                td.appendChild(edit);
-               field.style.display = 'none';
+               this.style.display = 'none';
                edit.style.display = 'inline';
                edit.focus();
        }
 }
 
 /** Finish editing of enum or set
-* @param HTMLTextAreaElement
+* @this HTMLTextAreaElement
 */
-function editingLengthBlur(edit) {
-       var field = edit.parentNode.firstChild;
-       var val = edit.value;
+function editingLengthBlur() {
+       var field = this.parentNode.firstChild;
+       var val = this.value;
        field.value = (/^'[^\n]+'$/.test(val) ? val : "'" + val.replace(/\n+$/, '').replace(/'/g, "''").replace(/\n/g, "','") + "'");
        field.style.display = 'inline';
-       edit.style.display = 'none';
+       this.style.display = 'none';
 }
 
 /** Show or hide selected table column
@@ -380,49 +376,49 @@ function editingHideDefaults() {
 }
 
 /** Display partition options
-* @param HTMLSelectElement
+* @this HTMLSelectElement
 */
-function partitionByChange(el) {
-       var partitionTable = /RANGE|LIST/.test(selectValue(el));
-       alterClass(el.form['partitions'], 'hidden', partitionTable || !el.selectedIndex);
+function partitionByChange() {
+       var partitionTable = /RANGE|LIST/.test(selectValue(this));
+       alterClass(this.form['partitions'], 'hidden', partitionTable || !this.selectedIndex);
        alterClass(qs('#partition-table'), 'hidden', !partitionTable);
        helpClose();
 }
 
 /** Add next partition row
-* @param HTMLInputElement
+* @this HTMLInputElement
 */
-function partitionNameChange(el) {
-       var row = cloneNode(parentTag(el, 'tr'));
+function partitionNameChange() {
+       var row = cloneNode(parentTag(this, 'tr'));
        row.firstChild.firstChild.value = '';
-       parentTag(el, 'table').appendChild(row);
-       el.onchange = function () {};
+       parentTag(this, 'table').appendChild(row);
+       this.onchange = function () {};
 }
 
 
 
 /** Add row for foreign key
-* @param HTMLSelectElement
+* @this HTMLSelectElement
 */
-function foreignAddRow(field) {
-       field.onchange = function () { };
-       var row = cloneNode(parentTag(field, 'tr'));
+function foreignAddRow() {
+       this.onchange = function () { };
+       var row = cloneNode(parentTag(this, 'tr'));
        var selects = qsa('select', row);
        for (var i=0; i < selects.length; i++) {
                selects[i].name = selects[i].name.replace(/\]/, '1$&');
                selects[i].selectedIndex = 0;
        }
-       parentTag(field, 'table').appendChild(row);
+       parentTag(this, 'table').appendChild(row);
 }
 
 
 
 /** Add row for indexes
-* @param HTMLSelectElement
+* @this HTMLSelectElement
 */
-function indexesAddRow(field) {
-       field.onchange = function () { };
-       var row = cloneNode(parentTag(field, 'tr'));
+function indexesAddRow() {
+       this.onchange = function () { };
+       var row = cloneNode(parentTag(this, 'tr'));
        var selects = qsa('select', row);
        for (var i=0; i < selects.length; i++) {
                selects[i].name = selects[i].name.replace(/indexes\[\d+/, '$&1');
@@ -433,17 +429,17 @@ function indexesAddRow(field) {
                inputs[i].name = inputs[i].name.replace(/indexes\[\d+/, '$&1');
                inputs[i].value = '';
        }
-       parentTag(field, 'table').appendChild(row);
+       parentTag(this, 'table').appendChild(row);
 }
 
 /** Change column in index
-* @param HTMLSelectElement
 * @param string name prefix
+* @this HTMLSelectElement
 */
-function indexesChangeColumn(field, prefix) {
+function indexesChangeColumn(prefix) {
        var names = [];
        for (var tag in { 'select': 1, 'input': 1 }) {
-               var columns = qsa(tag, parentTag(field, 'td'));
+               var columns = qsa(tag, parentTag(this, 'td'));
                for (var i=0; i < columns.length; i++) {
                        if (/\[columns\]/.test(columns[i].name)) {
                                var value = selectValue(columns[i]);
@@ -453,14 +449,15 @@ function indexesChangeColumn(field, prefix) {
                        }
                }
        }
-       field.form[field.name.replace(/\].*/, '][name]')].value = prefix + names.join('_');
+       this.form[this.name.replace(/\].*/, '][name]')].value = prefix + names.join('_');
 }
 
 /** Add column for index
-* @param HTMLSelectElement
 * @param string name prefix
+* @this HTMLSelectElement
 */
-function indexesAddColumn(field, prefix) {
+function indexesAddColumn(prefix) {
+       var field = this;
        field.onchange = function () {
                indexesChangeColumn(field, prefix);
        };
@@ -510,14 +507,14 @@ function triggerChange(tableRe, table, form) {
 var that, x, y; // em and tablePos defined in schema.inc.php
 
 /** Get mouse position
-* @param HTMLElement
 * @param MouseEvent
+* @this HTMLElement
 */
-function schemaMousedown(el, event) {
+function schemaMousedown(event) {
        if ((event.which ? event.which : event.button) == 1) {
-               that = el;
-               x = event.clientX - el.offsetLeft;
-               y = event.clientY - el.offsetTop;
+               that = this;
+               x = event.clientX - this.offsetLeft;
+               y = event.clientY - this.offsetTop;
        }
 }
 
@@ -589,16 +586,16 @@ function schemaMouseup(ev, db) {
 var helpOpen, helpIgnore; // when mouse outs <option> then it mouse overs border of <select> - ignore it
 
 /** Display help
-* @param HTMLElement
 * @param MouseEvent
 * @param string
 * @param bool display on left side (otherwise on top)
+* @this HTMLElement
 */
-function helpMouseover(el, event, text, side) {
+function helpMouseover(event, text, side) {
        var target = getTarget(event);
        if (!text) {
                helpClose();
-       } else if (window.jush && (!helpIgnore || el != target)) {
+       } else if (window.jush && (!helpIgnore || this != target)) {
                helpOpen = 1;
                var help = qs('#help');
                help.innerHTML = text;
@@ -612,12 +609,12 @@ function helpMouseover(el, event, text, side) {
 }
 
 /** Close help after timeout
-* @param HTMLElement
 * @param MouseEvent
+* @this HTMLElement
 */
-function helpMouseout(el, event) {
+function helpMouseout(event) {
        helpOpen = 0;
-       helpIgnore = (el != getTarget(event));
+       helpIgnore = (this != getTarget(event));
        setTimeout(function () {
                if (!helpOpen) {
                        helpClose();
index 8cdb7808dd61e14c3cb1a654885ca94b1fd3a3c1..15341dd12705cfcc33139399e8b43384ea155299 100644 (file)
@@ -135,14 +135,14 @@ function selectCount(id, count) {
 }
 
 /** Check all elements matching given name
-* @param HTMLInputElement
 * @param RegExp
+* @this HTMLInputElement
 */
-function formCheck(el, name) {
-       var elems = el.form.elements;
+function formCheck(name) {
+       var elems = this.form.elements;
        for (var i=0; i < elems.length; i++) {
                if (name.test(elems[i].name)) {
-                       elems[i].checked = el.checked;
+                       elems[i].checked = this.checked;
                        trCheck(elems[i]);
                }
        }
@@ -172,13 +172,13 @@ function formUncheck(id) {
 }
 
 /** Get number of checked elements matching given name
-* @param HTMLInputElement
 * @param RegExp
 * @return number
+* @this HTMLInputElement
 */
-function formChecked(el, name) {
+function formChecked(name) {
        var checked = 0;
-       var elems = el.form.elements;
+       var elems = this.form.elements;
        for (var i=0; i < elems.length; i++) {
                if (name.test(elems[i].name) && elems[i].checked) {
                        checked++;
@@ -199,7 +199,7 @@ function tableClick(event, click) {
                        if (el.type != 'checkbox') {
                                return;
                        }
-                       checkboxClick(event, el);
+                       checkboxClick.call(el, event);
                        click = false;
                }
                el = el.parentNode;
@@ -219,24 +219,24 @@ var lastChecked;
 
 /** Shift-click on checkbox for multiple selection.
 * @param MouseEvent
-* @param HTMLInputElement
+* @this HTMLInputElement
 */
-function checkboxClick(event, el) {
-       if (!el.name) {
+function checkboxClick(event) {
+       if (!this.name) {
                return;
        }
-       if (event.shiftKey && (!lastChecked || lastChecked.name == el.name)) {
+       if (event.shiftKey && (!lastChecked || lastChecked.name == this.name)) {
                var checked = (lastChecked ? lastChecked.checked : true);
-               var inputs = qsa('input', parentTag(el, 'table'));
+               var inputs = qsa('input', parentTag(this, 'table'));
                var checking = !lastChecked;
                for (var i=0; i < inputs.length; i++) {
                        var input = inputs[i];
-                       if (input.name === el.name) {
+                       if (input.name === this.name) {
                                if (checking) {
                                        input.checked = checked;
                                        trCheck(input);
                                }
-                               if (input === el || input === lastChecked) {
+                               if (input === this || input === lastChecked) {
                                        if (checking) {
                                                break;
                                        }
@@ -245,7 +245,7 @@ function checkboxClick(event, el) {
                        }
                }
        } else {
-               lastChecked = el;
+               lastChecked = this;
        }
 }
 
@@ -291,29 +291,30 @@ function pageClick(href, page, event) {
 
 
 /** Display items in menu
-* @param HTMLElement
 * @param MouseEvent
+* @this HTMLElement
 */
-function menuOver(el, event) {
+function menuOver(event) {
        var a = getTarget(event);
        if (isTag(a, 'a|span') && a.offsetLeft + a.offsetWidth > a.parentNode.offsetWidth - 15) { // 15 - ellipsis
-               el.style.overflow = 'visible';
+               this.style.overflow = 'visible';
        }
 }
 
 /** Hide items in menu
-* @param HTMLElement
+* @this HTMLElement
 */
-function menuOut(el) {
-       el.style.overflow = 'auto';
+function menuOut() {
+       this.style.overflow = 'auto';
 }
 
 
 
 /** Add row in select fieldset
-* @param HTMLSelectElement
+* @this HTMLSelectElement
 */
-function selectAddRow(field) {
+function selectAddRow() {
+       var field = this;
        field.onchange = function () {
                selectFieldChange(field.form);
        };
@@ -338,33 +339,33 @@ function selectAddRow(field) {
 }
 
 /** Prevent onsearch handler on Enter
-* @param HTMLInputElement
 * @param KeyboardEvent
+* @this HTMLInputElement
 */
-function selectSearchKeydown(el, event) {
+function selectSearchKeydown(event) {
        if (event.keyCode == 13 || event.keyCode == 10) {
-               el.onsearch = function () {
+               this.onsearch = function () {
                };
        }
 }
 
 /** Clear column name after resetting search
-* @param HTMLInputElement
+* @this HTMLInputElement
 */
-function selectSearchSearch(el) {
-       if (!el.value) {
-               el.parentNode.firstChild.selectedIndex = 0;
+function selectSearchSearch() {
+       if (!this.value) {
+               this.parentNode.firstChild.selectedIndex = 0;
        }
 }
 
 
 
 /** Toggles column context menu
-* @param HTMLElement
 * @param [string] extra class name
+* @this HTMLElement
 */
-function columnMouse(el, className) {
-       var spans = qsa('span', el);
+function columnMouse(className) {
+       var spans = qsa('span', this);
        for (var i=0; i < spans.length; i++) {
                if (/column/.test(spans[i].className)) {
                        spans[i].className = 'column' + (className || '');
@@ -474,11 +475,11 @@ function editingKeydown(event) {
 }
 
 /** Disable maxlength for functions
-* @param HTMLSelectElement
+* @this HTMLSelectElement
 */
-function functionChange(select) {
-       var input = select.form[select.name.replace(/^function/, 'fields')];
-       if (selectValue(select)) {
+function functionChange() {
+       var input = this.form[this.name.replace(/^function/, 'fields')];
+       if (selectValue(this)) {
                if (input.origType === undefined) {
                        input.origType = input.type;
                        input.origMaxLength = input.getAttribute('data-maxlength');
@@ -506,17 +507,17 @@ function keyupChange() {
 }
 
 /** Add new field in schema-less edit
-* @param HTMLInputElement
+* @this HTMLInputElement
 */
-function fieldChange(field) {
-       var row = cloneNode(parentTag(field, 'tr'));
+function fieldChange() {
+       var row = cloneNode(parentTag(this, 'tr'));
        var inputs = qsa('input', row);
        for (var i = 0; i < inputs.length; i++) {
                inputs[i].value = '';
        }
        // keep value in <select> (function)
-       parentTag(field, 'table').appendChild(row);
-       field.onchange = function () { };
+       parentTag(this, 'table').appendChild(row);
+       this.onchange = function () { };
 }
 
 
@@ -609,12 +610,13 @@ function ajaxForm(form, message, button) {
 
 
 /** Display edit field
-* @param HTMLElement
 * @param MouseEvent
 * @param number display textarea instead of input, 2 - load long text
 * @param string warning to display
+* @this HTMLElement
 */
-function selectClick(td, event, text, warning) {
+function selectClick(event, text, warning) {
+       var td = this;
        var target = getTarget(event);
        if (!isCtrl(event) || isTag(td.firstChild, 'input|textarea') || isTag(target, 'a')) {
                return;
@@ -681,12 +683,13 @@ function selectClick(td, event, text, warning) {
 
 
 /** Load and display next page in select
-* @param HTMLLinkElement
 * @param number
 * @param string
 * @return boolean
+* @this HTMLLinkElement
 */
-function selectLoadMore(a, limit, loading) {
+function selectLoadMore(limit, loading) {
+       var a = this;
        var title = a.innerHTML;
        var href = a.href;
        a.innerHTML = loading;
index 352880e96ff5b55a32061ef840e3c4d0bc24e976..a593c3c47348b7409f1d543ddb9089c1f85da40d 100644 (file)
@@ -8,7 +8,7 @@ if ($adminer->homepage()) {
                search_tables();
        }
        echo "<table cellspacing='0' class='nowrap checkable' onclick='tableClick(event);'>\n";
-       echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck(this, /^tables\[/);" class="jsonly"><th>' . lang('Table') . '<td>' . lang('Rows') . "</thead>\n";
+       echo '<thead><tr class="wrap"><td><input id="check-all" type="checkbox" onclick="formCheck.call(this, /^tables\[/);" class="jsonly"><th>' . lang('Table') . '<td>' . lang('Rows') . "</thead>\n";
        
        foreach (table_status() as $table => $row) {
                $name = $adminer->tableName($row);
index 0416dfa468090579f374335e084692d894455790..bb7de001e9553f3c82984ace2aadd470e9029c26 100644 (file)
@@ -242,13 +242,13 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
                        if (($val["col"] == "" || $columns[$val["col"]]) && "$val[col]$val[val]" != "") {
                                echo "<div><select name='where[$i][col]'><option value=''>(" . lang('anywhere') . ")" . optionlist($columns, $val["col"], true) . "</select>";
                                echo html_select("where[$i][op]", array(-1 => "") + $this->operators, $val["op"]);
-                               echo "<input type='search' name='where[$i][val]' value='" . h($val["val"]) . "' onkeydown='selectSearchKeydown(this, event);' onsearch='selectSearchSearch(this);'></div>\n";
+                               echo "<input type='search' name='where[$i][val]' value='" . h($val["val"]) . "' onkeydown='selectSearchKeydown.call(this, event);' onsearch='selectSearchSearch.call(this);'></div>\n";
                                $i++;
                        }
                }
                echo "<div><select name='where[$i][col]' onchange='this.nextSibling.nextSibling.onchange();'><option value=''>(" . lang('anywhere') . ")" . optionlist($columns, null, true) . "</select>";
                echo html_select("where[$i][op]", array(-1 => "") + $this->operators);
-               echo "<input type='search' name='where[$i][val]' onchange='selectAddRow(this);' onsearch='selectSearch(this);'></div>\n";
+               echo "<input type='search' name='where[$i][val]' onchange='selectAddRow.call(this);' onsearch='selectSearchSearch.call(this);'></div>\n";
                echo "</div></fieldset>\n";
        }
 
@@ -457,7 +457,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
                if ($options !== null) {
                        return (is_array($options)
                                ? "<select$attrs>" . optionlist($options, $value, true) . "</select>"
-                               :  "<input value='" . h($value) . "'$attrs class='hidden'><input value='" . h($options) . "' class='jsonly' onkeyup=\"whisper('" . h(ME . "script=complete&source=" . urlencode($table) . "&field=" . urlencode($field["field"])) . "&value=', this);\"><div onclick='return whisperClick(event, this.previousSibling);'></div>"
+                               :  "<input value='" . h($value) . "'$attrs class='hidden'><input value='" . h($options) . "' class='jsonly' onkeyup=\"whisper.call(this, '" . h(ME . "script=complete&source=" . urlencode($table) . "&field=" . urlencode($field["field"])) . "&value=');\"><div onclick='return whisperClick(event, this.previousSibling);'></div>"
                        );
                }
                if (like_bool($field)) {
@@ -559,7 +559,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
                                foreach ($servers[""] as $username => $password) {
                                        if ($password !== null) {
                                                if ($first) {
-                                                       echo "<p id='logins' onmouseover='menuOver(this, event);' onmouseout='menuOut(this);'>\n";
+                                                       echo "<p id='logins' onmouseover='menuOver.call(this, event);' onmouseout='menuOut.call(this);'>\n";
                                                        $first = false;
                                                }
                                                echo "<a href='" . h(auth_url($vendor, "", $username)) . "'>" . ($username != "" ? h($username) : "<i>" . lang('empty') . "</i>") . "</a><br>\n";
@@ -583,7 +583,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
        }
 
        function tablesPrint($tables) {
-               echo "<p id='tables' onmouseover='menuOver(this, event);' onmouseout='menuOut(this);'>\n";
+               echo "<p id='tables' onmouseover='menuOver.call(this, event);' onmouseout='menuOut.call(this);'>\n";
                foreach ($tables as $row) {
                        $name = $this->tableName($row);
                        if (isset($row["Engine"]) && $name != "") { // ignore views and tables without name
index 8b5c23598a0ade172befa7b987c71dadb226af72..7d69c01d51a6644dd3b12ee95eb2e5233c52e879 100644 (file)
@@ -21,7 +21,8 @@ function whisperClick(event, field) {
        }
 }
 
-function whisper(url, field) {
+function whisper(url) {
+       var field = this;
        if (field.orig != field.value) { // ignore arrows, Shift, ...
                field.orig = field.value;
                field.previousSibling.value = field.value; // accept number, reject string
index b68c23da533e9fe3de3d8d030b7bfa6b638f76b9..a8753eeb0cdb5c0b798009a98fdfb1b7cf504b00 100644 (file)
@@ -9,7 +9,7 @@
 class AdminerTablesFilter {
        function tablesPrint($tables) { ?>
 <p class="jsonly"><input id="filter-field" onkeyup="tablesFilterInput();" autocomplete="off">
-<ul id='tables' onmouseover='menuOver(this, event);' onmouseout='menuOut(this);'>
+<ul id='tables' onmouseover='menuOver.call(this, event);' onmouseout='menuOut.call(this);'>
 <?php
 foreach ($tables as $table => $status) {
        echo '<li data-table-name="' . h($table) . '"><a href="' . h(ME) . 'select=' . urlencode($table) . '"' . bold($_GET["select"] == $table || $_GET["edit"] == $table, "select") . ">" . lang('select') . "</a> ";