]> git.joonet.de Git - adminer.git/commitdiff
JavaScript for next rows
authorjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Tue, 17 Jul 2007 16:31:42 +0000 (16:31 +0000)
committerjakubvrana <jakubvrana@7c3ca157-0c34-0410-bff1-cbf682f78f5c>
Tue, 17 Jul 2007 16:31:42 +0000 (16:31 +0000)
git-svn-id: https://adminer.svn.sourceforge.net/svnroot/adminer/trunk@217 7c3ca157-0c34-0410-bff1-cbf682f78f5c

create.inc.php
editing.inc.php

index 02743f5bf5dd70faf63c5a92cba25cd819881316..7016c587fd3ec3a24fef4a774deb7fbc90957380 100644 (file)
@@ -8,7 +8,7 @@ if ($_POST && !$error && !$_POST["add"]) {
                if (strlen($_GET["create"]) && strlen($_POST["fields"][$_POST["auto_increment"]]["orig"])) {
                        foreach (indexes($_GET["create"]) as $index) {
                                foreach ($index["columns"] as $column) {
-                                       if ($column == $_POST["fields"][$_POST["auto_increment"]]["orig"]) {
+                                       if ($column === $_POST["fields"][$_POST["auto_increment"]]["orig"]) {
                                                $auto_increment_index = "";
                                                break 2;
                                        }
@@ -104,8 +104,9 @@ $collations = collations();
 <script type="text/javascript">
 document.write('<label for="column_comments"><input type="checkbox" id="column_comments"<?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) {
-       for (var i=0; <?php echo count($row["fields"]); ?> >= i; i++) {
-               document.getElementById('comment-' + i).style.display = (checked ? '' : 'none');
+       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 } ?>
index a39bd5855efa3fdd74e874eeda102a1df3f1ecf3..77bb0259d84d7e128c5b83b2995f94b36bcb1fcf 100644 (file)
@@ -89,7 +89,7 @@ function edit_fields($fields, $collations, $type = "TABLE") {
 <?php if ($type == "TABLE") { ?>
 <td><?php echo lang('NULL'); ?></td>
 <td><input type="radio" name="auto_increment" value="" /><?php echo lang('Auto Increment'); ?></td>
-<td id="comment-0"><?php echo lang('Comment'); ?></td>
+<td><?php echo lang('Comment'); ?></td>
 <?php } ?>
 <td><input type="submit" name="add[0]" value="<?php echo lang('Add next'); ?>" /></td>
 </tr></thead>
@@ -105,22 +105,40 @@ 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" value="<?php echo $i; ?>"<?php if ($field["auto_increment"]) { ?> checked="checked"<?php } ?> /></td>
-<td id="comment-<?php echo $i; ?>"><input name="fields[<?php echo $i; ?>][comment]" value="<?php echo htmlspecialchars($field["comment"]); ?>" maxlength="255" /></td>
+<td><input name="fields[<?php echo $i; ?>][comment]" value="<?php echo htmlspecialchars($field["comment"]); ?>" maxlength="255" /></td>
 <?php } ?>
-<td><input type="submit" name="add[<?php echo $i; ?>]" value="<?php echo lang('Add next'); ?>" /></td>
+<td><input type="submit" name="add[<?php echo $i; ?>]" value="<?php echo lang('Add next'); ?>" onclick="return !add_row(this.parentNode.parentNode);" /></td>
 </tr>
 <?php
                if (strlen($field["comment"])) {
                        $column_comments = true;
                }
        }
-       //! JavaScript for next rows
        return $column_comments;
 }
 
 function type_change($count) {
 ?>
 <script type="text/javascript">
+var added = '.';
+function add_row(row) {
+       row.parentNode.insertBefore(row.cloneNode(true), row);
+       var tags = row.getElementsByTagName('*');
+       var match, x;
+       for (var i=0; i < tags.length; i++) {
+               if (tags[i].name == 'auto_increment') {
+                       tags[i].value = x;
+               } else if (tags[i].name && (x || (match = /([0-9]+)(\.[0-9]+)?/.exec(tags[i].name)))) {
+                       x = x || match[0] + (match[2] ? added.substr(match[2].length) : added) + '1';
+                       tags[i].name = tags[i].name.replace(/([0-9.]+)/, x);
+                       if (/\[(orig|field|comment)/.test(tags[i].name)) {
+                               tags[i].value = '';
+                       }
+               }
+       }
+       added += '0';
+       return true;
+}
 function type_change(type) {
        var name = type.name.substr(0, type.name.length - 6);
        type.form[name + '[collation]'].style.display = (/char|text|enum|set/.test(type.form[name + '[type]'].value) ? '' : 'none');