Permalink
Browse files

Separate JavaScript

git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@618 7c3ca157-0c34-0410-bff1-cbf682f78f5c
  • Loading branch information...
jakubvrana
jakubvrana committed May 29, 2009
1 parent 7f3b4f2 commit 540e2174e289102fd067831feb1648bfc981defd
Showing with 277 additions and 269 deletions.
  1. +4 −1 _compile.php
  2. +1 −0 changes.txt
  3. +1 −4 connect.inc.php
  4. +4 −12 create.inc.php
  5. +1 −8 design.inc.php
  6. +1 −13 dump.inc.php
  7. +18 −73 editing.inc.php
  8. +1 −14 foreign.inc.php
  9. +236 −0 functions.js
  10. +1 −1 index.php
  11. +2 −32 indexes.inc.php
  12. +0 −6 procedure.inc.php
  13. +3 −64 schema.inc.php
  14. +4 −40 select.inc.php
  15. +0 −1 todo.txt
View
@@ -170,7 +170,7 @@ function php_shrink($input) {
$file = preg_replace_callback("~lang\\('((?:[^\\\\']+|\\\\.)*)'([,)])~s", 'lang_ids', $file);
}
$replace = 'preg_replace("~\\\\\\\\?.*~", "", $_SERVER["REQUEST_URI"]) . "?file=\\0&version=' . $VERSION;
-$file = preg_replace('~default\\.css|favicon\\.ico|(up|down|plus|minus)\\.gif~', '<?php echo ' . $replace . '"; ?>', $file);
+$file = preg_replace('~default\\.css|functions\\.js|favicon\\.ico|(up|down|plus|minus)\\.gif~', '<?php echo ' . $replace . '"; ?>', $file);
$file = preg_replace('~arrow\\.gif~', '" . ' . $replace, $file);
$file = str_replace('error_reporting(E_ALL & ~E_NOTICE);', 'error_reporting(E_ALL & ~E_NOTICE);
if (isset($_GET["file"])) {
@@ -181,6 +181,9 @@ function php_shrink($input) {
} elseif ($_GET["file"] == "default.css") {
header("Content-Type: text/css");
?>' . preg_replace('~\\s*([:;{},])\\s*~', '\\1', file_get_contents("default.css")) . '<?php
+ } elseif ($_GET["file"] == "functions.js") {
+ header("Content-Type: text/javascript");
+ ?>' . file_get_contents("functions.js") . '<?php
} else {
header("Content-Type: image/gif");
switch ($_GET["file"]) {
View
@@ -2,6 +2,7 @@ phpMinAdmin 1.11.0:
Connection through socket by server :/path/to/socket
Display execution time in SQL query
Version checker
+Separate JavaScript functions
phpMinAdmin 1.10.1:
Highlight odd and hover rows
View
@@ -17,10 +17,7 @@
?>
<script type="text/javascript">
onload = function () {
- document.cookie = 'phpMinAdmin_version=0';
- var script = document.createElement('script');
- script.src = 'http://phpminadmin.sourceforge.net/version.php?version=<?php echo $VERSION; ?>';
- document.body.appendChild(script);
+ check_version('<?php echo $VERSION; ?>');
};
</script>
<?php
View
@@ -122,22 +122,14 @@
<select name="Collation"><option value="">(<?php echo lang('collation'); ?>)</option><?php echo optionlist($collations, $row["Collation"]); ?></select>
<input type="submit" value="<?php echo lang('Save'); ?>" />
</p>
-<table cellspacing="0">
-<?php $column_comments = edit_fields($row["fields"], $collations); ?>
+<table cellspacing="0" id="edit-fields">
+<?php $column_comments = edit_fields($row["fields"], $collations, "TABLE", $suhosin); ?>
</table>
-<?php echo type_change(count($row["fields"]), $suhosin); ?>
<p>
<?php echo lang('Auto Increment'); ?>: <input name="Auto_increment" size="4" value="<?php echo intval($row["Auto_increment"]); ?>" />
<?php echo lang('Comment'); ?>: <input name="Comment" value="<?php echo htmlspecialchars($row["Comment"]); ?>" maxlength="60" />
<script type="text/javascript">// <![CDATA[
document.write('<label><input type="checkbox"<?php if ($column_comments) { ?> checked="checked"<?php } ?> onclick="column_comments_click(this.checked);" /><?php echo lang('Show column comments'); ?></label>');
-function column_comments_click(checked) {
- var trs = document.getElementsByTagName('tr');
- for (var i=0; i < trs.length; i++) {
- trs[i].getElementsByTagName('td')[5].style.display = (checked ? '' : 'none');
- }
-}
-<?php if (!$column_comments) { ?>column_comments_click(false);<?php } ?>
// ]]></script>
</p>
<p>
@@ -151,15 +143,15 @@ function column_comments_click(checked) {
?>
<fieldset><legend><?php echo lang('Partition by'); ?></legend>
<p>
-<select name="partition_by" onchange="var partition_table = /RANGE|LIST/.test(this.options[this.selectedIndex].text); this.form['partitions'].className = (partition_table || !this.selectedIndex ? 'hidden' : ''); document.getElementById('partition-table').className = (partition_table ? '' : 'hidden');"><option></option><?php echo optionlist($partition_by, $row["partition_by"]); ?></select>
+<select name="partition_by" onchange="partition_by_change(this);"><option></option><?php echo optionlist($partition_by, $row["partition_by"]); ?></select>
(<input name="partition" value="<?php echo htmlspecialchars($row["partition"]); ?>" />)
<?php echo lang('Partitions'); ?>: <input name="partitions" size="2" value="<?php echo htmlspecialchars($row["partitions"]); ?>"<?php echo ($partition_table || !$row["partition_by"] ? " class='hidden'" : ""); ?> />
</p>
<table cellspacing="0" id="partition-table"<?php echo ($partition_table ? "" : " class='hidden'"); ?>>
<thead><tr><th><?php echo lang('Partition name'); ?></th><th><?php echo lang('Values'); ?></th></tr></thead>
<?php
foreach ($row["partition_names"] as $key => $val) {
- echo '<tr><td><input name="partition_names[]" value="' . htmlspecialchars($val) . '"' . ($key == count($row["partition_names"]) - 1 ? ' onchange="var row = this.parentNode.parentNode.cloneNode(true); row.firstChild.firstChild.value = \'\'; this.parentNode.parentNode.parentNode.appendChild(row); this.onchange = function () {};"' : '') . ' /></td><td><input name="partition_values[]" value="' . htmlspecialchars($row["partition_values"][$key]) . "\" /></td></tr>\n";
+ echo '<tr><td><input name="partition_names[]" value="' . htmlspecialchars($val) . '"' . ($key == count($row["partition_names"]) - 1 ? ' onchange="partition_name_change(this);"' : '') . ' /></td><td><input name="partition_values[]" value="' . htmlspecialchars($row["partition_values"][$key]) . "\" /></td></tr>\n";
}
?>
</table>
View
@@ -18,14 +18,7 @@ function page_header($title, $error = "", $breadcrumb = array(), $title2 = "") {
</head>
<body>
-<script type="text/javascript">
-document.body.className = 'js';
-function toggle(id) {
- var el = document.getElementById(id);
- el.className = (el.className == 'hidden' ? '' : 'hidden');
- return true;
-}
-</script>
+<script type="text/javascript" src="functions.js"></script>
<div id="content">
<?php
View
@@ -17,7 +17,7 @@ function dump_link($type, $name, $val, $attrs = "") {
. (isset($check["db_check"]) ? "&amp;db_check=" . urlencode($check["db_check"]) : "")
. (isset($check["table_check"]) ? "&amp;table_check=" . urlencode($check["table_check"]) : "")
. (isset($check["data_check"]) ? "&amp;data_check=" . urlencode($check["data_check"]) : "")
- . "\" onclick=\"return !check(this, /^$name/, '$val');\"$attrs>" . ($val ? $val : lang('skip')) . "</a>"
+ . "\" onclick=\"return !dump_check(this, /^$name/, '$val');\"$attrs>" . ($val ? $val : lang('skip')) . "</a>"
;
}
@@ -142,18 +142,6 @@ function dump_link($type, $name, $val, $attrs = "") {
page_header(lang('Export'), "", (strlen($_GET["export"]) ? array("table" => $_GET["export"]) : array()), $_GET["db"]);
?>
-<script type="text/javascript">
-function check(a, name, value) {
- var inputs = a.parentNode.parentNode.parentNode.parentNode.getElementsByTagName('input');
- for (var i=0; inputs.length > i; i++) {
- if (name.test(inputs[i].name)) {
- inputs[i].checked = (inputs[i].value == value);
- }
- }
- return true;
-}
-</script>
-
<form action="" method="post">
<p><?php echo lang('Output') . ": $dump_output " . lang('Format') . ": $dump_format"; ?> <input type="submit" value="<?php echo lang('Export'); ?>" /></p>
View
@@ -89,7 +89,7 @@ function process_input($name, $field) {
function edit_type($key, $field, $collations) {
global $types, $unsigned, $inout;
?>
-<td><select name="<?php echo $key; ?>[type]" onchange="type_change(this);"><?php echo optionlist(array_keys($types), $field["type"]); ?></select></td>
+<td><select name="<?php echo $key; ?>[type]" onchange="editing_type_change(this);"><?php echo optionlist(array_keys($types), $field["type"]); ?></select></td>
<td><input name="<?php echo $key; ?>[length]" value="<?php echo htmlspecialchars($field["length"]); ?>" size="3" /></td>
<td><?php echo "<select name=\"$key" . '[collation]"' . (preg_match('~char|text|enum|set~', $field["type"]) ? "" : " class='hidden'") . '><option value="">(' . lang('collation') . ')</option>' . optionlist($collations, $field["collation"]) . '</select>' . ($unsigned ? " <select name=\"$key" . '[unsigned]"' . (!$field["type"] || preg_match('~int|float|double|decimal~', $field["type"]) ? "" : " class='hidden'") . '>' . optionlist($unsigned, $field["unsigned"]) . '</select>' : ''); ?></td>
<?php
@@ -104,8 +104,14 @@ function process_type($field, $collate = "COLLATE") {
;
}
-function edit_fields($fields, $collations, $type = "TABLE") {
+function edit_fields($fields, $collations, $type = "TABLE", $allowed = 0) {
global $inout;
+ $column_comments = false;
+ foreach ($fields as $field) {
+ if (strlen($field["comment"])) {
+ $column_comments = true;
+ }
+ }
?>
<thead><tr>
<?php if ($type == "PROCEDURE") { ?><td><?php echo lang('IN-OUT'); ?></td><?php } ?>
@@ -116,12 +122,16 @@ function edit_fields($fields, $collations, $type = "TABLE") {
<?php if ($type == "TABLE") { ?>
<td><?php echo lang('NULL'); ?></td>
<td><input type="radio" name="auto_increment_col" value="" /><?php echo lang('Auto Increment'); ?></td>
-<td><?php echo lang('Comment'); ?></td>
+<td<?php echo ($column_comments ? "" : " class='hidden'"); ?>><?php echo lang('Comment'); ?></td>
<?php } ?>
-<td><input type="image" name="add[0]" src="plus.gif" title="<?php echo lang('Add next'); ?>" /></td>
+<td><input type="image" name="add[0]" src="plus.gif" title="<?php echo lang('Add next'); ?>" />
+<script type="text/javascript">
+var added = '.';
+var row_count = <?php echo count($fields); ?>;
+</script>
+</td>
</tr></thead>
<?php
- $column_comments = false;
foreach ($fields as $i => $field) {
$i++;
$display = (isset($_POST["add"][$i-1]) || (isset($field["field"]) && !$_POST["drop_col"][$i]));
@@ -133,19 +143,16 @@ function edit_fields($fields, $collations, $type = "TABLE") {
<?php if ($type == "TABLE") { ?>
<td><input type="checkbox" name="fields[<?php echo $i; ?>][null]" value="1"<?php if ($field["null"]) { ?> checked="checked"<?php } ?> /></td>
<td><input type="radio" name="auto_increment_col" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked="checked"<?php } ?> /></td>
-<td><input name="fields[<?php echo $i; ?>][comment]" value="<?php echo htmlspecialchars($field["comment"]); ?>" maxlength="255" /></td>
+<td<?php echo ($column_comments ? "" : " class='hidden'"); ?>><input name="fields[<?php echo $i; ?>][comment]" value="<?php echo htmlspecialchars($field["comment"]); ?>" maxlength="255" /></td>
<?php } ?>
<td class="nowrap">
-<input type="image" name="add[<?php echo $i; ?>]" src="plus.gif" title="<?php echo lang('Add next'); ?>" onclick="return !add_row(this);" />
-<input type="image" name="drop_col[<?php echo $i; ?>]" src="minus.gif" title="<?php echo lang('Remove'); ?>" onclick="return !remove_row(this);" />
+<input type="image" name="add[<?php echo $i; ?>]" src="plus.gif" title="<?php echo lang('Add next'); ?>" onclick="return !editing_add_row(this, <?php echo $allowed; ?>);" />
+<input type="image" name="drop_col[<?php echo $i; ?>]" src="minus.gif" title="<?php echo lang('Remove'); ?>" onclick="return !editing_remove_row(this);" />
<input type="image" name="up[<?php echo $i; ?>]" src="up.gif" title="<?php echo lang('Move up'); ?>" />
<input type="image" name="down[<?php echo $i; ?>]" src="down.gif" title="<?php echo lang('Move down'); ?>" />
</td>
</tr>
<?php
- if (strlen($field["comment"])) {
- $column_comments = true;
- }
}
return $column_comments;
}
@@ -187,68 +194,6 @@ function process_fields(&$fields) {
}
}
-function type_change($count, $allowed = 0) {
- ?>
-<script type="text/javascript">// <![CDATA[
-var added = '.';
-var row_count = <?php echo $count; ?>;
-
-function add_row(button) {
- if (<?php echo $allowed; ?> && row_count >= <?php echo $allowed; ?>) {
- return false;
- }
- var match = /([0-9]+)(\.[0-9]+)?/.exec(button.name)
- var x = match[0] + (match[2] ? added.substr(match[2].length) : added) + '1';
- var row = button.parentNode.parentNode;
- var row2 = row.cloneNode(true);
- var tags = row.getElementsByTagName('select');
- var tags2 = row2.getElementsByTagName('select');
- for (var i=0; tags.length > i; i++) {
- tags[i].name = tags[i].name.replace(/([0-9.]+)/, x);
- tags2[i].selectedIndex = tags[i].selectedIndex;
- }
- tags = row.getElementsByTagName('input');
- for (var i=0; tags.length > i; i++) {
- if (tags[i].name == 'auto_increment_col') {
- tags[i].value = x;
- tags[i].checked = false;
- }
- tags[i].name = tags[i].name.replace(/([0-9.]+)/, x);
- if (/\[(orig|field|comment)/.test(tags[i].name)) {
- tags[i].value = '';
- }
- }
- row.parentNode.insertBefore(row2, row);
- tags[0].focus();
- added += '0';
- row_count++;
- return true;
-}
-
-function remove_row(button) {
- var field = button.form[button.name.replace(/drop_col(.+)/, 'fields$1[field]')];
- field.parentNode.removeChild(field);
- button.parentNode.parentNode.style.display = 'none';
- //! should change class="odd" of next rows
- return true;
-}
-
-function type_change(type) {
- var name = type.name.substr(0, type.name.length - 6);
- for (var i=0; i < type.form.elements.length; i++) {
- var el = type.form.elements[i];
- if (el.name == name + '[collation]') {
- el.className = (/char|text|enum|set/.test(type.options[type.selectedIndex].text) ? '' : 'hidden');
- }
- if (el.name == name + '[unsigned]') {
- el.className = (/int|float|double|decimal/.test(type.options[type.selectedIndex].text) ? '' : 'hidden');
- }
- }
-}
-// ]]></script>
-<?php
-}
-
function normalize_enum($match) {
return "'" . str_replace("'", "''", addcslashes(stripcslashes(str_replace($match[0]{0} . $match[0]{0}, $match[0]{0}, substr($match[0], 1, -1))), '\\')) . "'";
}
View
@@ -48,19 +48,6 @@
$target = ($_GET["foreign"] === $row["table"] ? $source : get_vals("SHOW COLUMNS FROM " . idf_escape($row["table"])));
?>
-<script type="text/javascript">// <![CDATA[
-function add_row(field) {
- var row = field.parentNode.parentNode.cloneNode(true);
- var selects = row.getElementsByTagName('select');
- for (var i=0; i < selects.length; i++) {
- selects[i].name = selects[i].name.replace(/\]/, '1$&');
- selects[i].selectedIndex = 0;
- }
- field.parentNode.parentNode.parentNode.appendChild(row);
- field.onchange = function () { };
-}
-// ]]></script>
-
<form action="" method="post">
<p>
<?php echo lang('Target table'); ?>:
@@ -74,7 +61,7 @@ function add_row(field) {
$j = 0;
foreach ($row["source"] as $key => $val) {
echo "<tr>";
- echo "<td><select name='source[" . intval($key) . "]'" . ($j == count($row["source"]) - 1 ? " onchange='add_row(this);'" : "") . "><option></option>" . optionlist($source, $val) . "</select></td>";
+ echo "<td><select name='source[" . intval($key) . "]'" . ($j == count($row["source"]) - 1 ? " onchange='foreign_add_row(this);'" : "") . "><option></option>" . optionlist($source, $val) . "</select></td>";
echo "<td><select name='target[" . intval($key) . "]'>" . optionlist($target, $row["target"][$key]) . "</select></td>";
echo "</tr>\n";
$j++;
Oops, something went wrong.

0 comments on commit 540e217

Please sign in to comment.