Browse files

using table for keys

clearing on new info
  • Loading branch information...
1 parent f40bc9a commit da9b4cc3a3adf493bc1d07712f1a34863fae25cd @thoolihan committed Jan 24, 2012
Showing with 29 additions and 10 deletions.
  1. +13 −0 dbsg.css
  2. +13 −9 oracle-resize.html
  3. +3 −1 script_gen.js
View
13 dbsg.css
@@ -18,4 +18,17 @@ fieldset {
border: 1px solid #999;
}
+table {
+ border-collapse: collapse;
+ margin: .75em;
+}
+
+table, tr, td, thead, th {
+ border: 1px solid #999;
+}
+
+tr:nth-child(even) {background: #eee;}
+
+td, th { padding: .4em; }
+
.hidden { display: none; }
View
22 oracle-resize.html
@@ -11,10 +11,16 @@
<legend>Table Info</legend>
<label for="table_name">Table</label>
- <input id="table_name" type="text" placeholder="MY_TABLE" />
+ <input id="table_name" type="text" placeholder="MY_TABLE" autofocus="autofocus" />
<input id="generate_script" type="button" value="Generate Script" /><br>
- <ul id="foreign_keys"></ul><br>
+ <table id="foreign_keys" class="hidden">
+ <thead>
+ <th>table</th>
+ <th>constraint</th>
+ <th>actions</th>
+ </thead>
+ </table>
<label for="fk_table_name">Associated Table with Foreign Key</label>
<input id="fk_table_name" type="text" placeholder="TABLE_WITH_FK" />
@@ -29,15 +35,14 @@
<script type="text/javascript" src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>
<script id="foreign_key_template" type="text/x-jquery-tmpl">
-<li id="fk${id}">
-table: <span class="table">${table}</span>
-constraint: <span class="foreign_key">${foreign_key}</span>
-<a href="#" onclick="$('#fk${id}').remove()">remove</a>
-</li>
+ <tr id="fk${id}" class="fk">
+ <td class="table">${table}</td>
+ <td class="foreign_key">${foreign_key}</td>
+ <td><a href="#" onclick="$('#fk${id}').remove()">remove</a></td>
+ </tr>
</script>
<script id="script_template" type="text/x-jquery-tmpl">
-<pre>
--**************************************************************<br>
--Generated by hoolihan.net/blog-tim/oracle-fix<br>
--No warranty, run at your own risk<br>
@@ -80,7 +85,6 @@
--only run these next two lines after ensuring that everything worked<br>
--drop table ${table}-temp-backup;<br>
--commit;
-</pre>
</script>
<script type="text/javascript" src="script_gen.js"></script>
</html>
View
4 script_gen.js
@@ -8,20 +8,22 @@ $(document).ready(function() {
foreign_key: $('#foreign_key_constraint').val()
};
$('#foreign_key_template').tmpl(key_data).appendTo('#foreign_keys');
+ $('#foreign_keys').removeClass('hidden');
});
$('input#generate_script').click(function(){
var script_data = {
table: $('#table_name').val(),
foreign_keys: []
};
- $('#foreign_keys li').each(function(index) {
+ $('#foreign_keys tr.fk').each(function(index) {
var fk_constraint = {
table: $(this).children('.table').first().html(),
constraint: $(this).children('.foreign_key').first().html()
};
script_data.foreign_keys.push(fk_constraint);
});
+ $('#results').html('');
$('#script_template').tmpl(script_data).appendTo('#results');
$('#results').removeClass('hidden');
});

0 comments on commit da9b4cc

Please sign in to comment.