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'"); ?>>
<?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]) . '">';
}
?>
}
$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'));
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";
}
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 = "";
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]++;
}
}
} 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) {
$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++;
}
$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";
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";
$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";
}
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];
<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">'
* @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);
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"
: ""
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
}
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>' : '');
<thead><tr class="wrap">
<?php if ($type == "PROCEDURE") { ?><td> <?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") { ?>
?>
<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") { ?>
<?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);'> "
- . "<input type='image' class='icon' name='up[$i]' src='../adminer/static/up.gif' alt='^' title='" . lang('Move up') . "' onclick='return !editingMoveRow(this, 1);'> "
- . "<input type='image' class='icon' name='down[$i]' src='../adminer/static/down.gif' alt='v' title='" . lang('Move down') . "' onclick='return !editingMoveRow(this, 0);'> "
+ "<input type='image' class='icon' name='add[$i]' src='../adminer/static/plus.gif' alt='+' title='" . lang('Add next') . "' onclick='return !editingAddRow.call(this, 1);'> "
+ . "<input type='image' class='icon' name='up[$i]' src='../adminer/static/up.gif' alt='^' title='" . lang('Move up') . "' onclick='return !editingMoveRow.call(this, 1);'> "
+ . "<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);'> "
: "");
- 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";
}
}
$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
* @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
}
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"
$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
);
}
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++;
}
</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) {
$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);
$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'>";
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";
}
}
}
);
}
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 {
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()) {
?>
/** 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;
}
}
}
/** 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
}
/** 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);
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();
}
/** 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;
}
}
/** 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
}
/** 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');
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]);
}
}
}
- 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);
};
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;
}
}
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;
}
/** 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();
}
/** 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]);
}
}
}
/** 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++;
if (el.type != 'checkbox') {
return;
}
- checkboxClick(event, el);
+ checkboxClick.call(el, event);
click = false;
}
el = el.parentNode;
/** 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;
}
}
}
} else {
- lastChecked = el;
+ lastChecked = this;
}
}
/** 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);
};
}
/** 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 || '');
}
/** 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');
}
/** 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 () { };
}
/** 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;
/** 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;
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);
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";
}
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)) {
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";
}
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
}
}
-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
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> ";