<style>
#bodyBG {
background: #8c92ac;
background: -moz-linear-gradient(bottom, #8c92ac, #fff) no-repeat;
background: -o-linear-gradient(bottom, rgb(140,146,172), rgb(255,255,255)) no-repeat;
background: -webkit-gradient(linear, center bottom, center top, from(#8c92ac), to(#fff)) no-repeat;
}
</style>
<script type="text/javascript">
$(function(){
var strCr = "";
var strRef = "";
var strRefCol = "";
$("#helperOK").live("click",function(){
var result="";
var primarySQL="";
var sqlInfo=$("#dialog-createTable tr");
//$("#dialog-createTable tr").each()
result +="CREATE TABLE "+sqlInfo.eq(0).find("#table_name").val()+"\n(\n";
for(var i=2;i<(sqlInfo.size()-3);i++){
if(sqlInfo.eq(i).find(".col_Name").val()!=""){
result +=sqlInfo.eq(i).find(".col_Name").val()+" ";
result +=sqlInfo.eq(i).find("#col_Type option:selected").text();
result +=" ("+sqlInfo.eq(i).find(".col_Size").val()+") ";
/* alert(sqlInfo.eq(i).find("#col_check").attr('checked'));
return; */
if(sqlInfo.eq(i).find("#col_check").attr('checked')){
result += " NOT NULL ,\n";
}else {
result += " ,\n";
}
if(sqlInfo.eq(i).find(".col_Primary").attr('checked')){
primarySQL ="PRIMARY KEY ("+sqlInfo.eq(i).find(".col_Name").val()+")";
}
}else {
alert("모두 채우셔야 합니다.");
return;
}
}
result +=primarySQL;
if($(".create_constraint").val()!="####_PK"){
result +=",\n CONSTRAINT "+$(".create_constraint").val();
result +=" "+$("#create_foreign option:selected").text();
result +=" REFERENCES "+$("#create_reference option:selected").text()+" ("+$("#create_reference_table option:selected").text()+")";
}else{
result +="\n"
}
result+=")";
// 이런식으로 저장 해보자. 부모장에 돌려 주기.
window.opener.document.getElementById("sqlInput").value=result;
window.open("about:blank","_self").close();
});
$("#helperCancel").live("click",function(){
// self.closed(); <-- 일부 브라우저 에서 작동 안한다 . crom x
alert("닫기는 브라우저 를 전체로 닫기 때문에 막아 놓았습니다. ");
return;
window.open("about:blank","_self").close();
});
$("#create_foreign").live("click", function() {
var str="";
var sqlInfo=$("#dialog-createTable tr");
for(var i=2;i<(sqlInfo.size()-4);i++){
str +="<option>"+sqlInfo.eq(i).find(".col_Name").val()+"</option>";
}
if(str!=strCr){
strCr=str;
$("#create_foreign").html(str);
}
});
$("#btncolAdd").live("click",function(){
var innerTR_Col="";
innerTR_Col+="<tr> ";
innerTR_Col+=" <td align='center'><input type='text' size='15' ";
innerTR_Col+=" class='col_Name' title='컬럽 이름' /></td> ";
innerTR_Col+=" <td align='center'><select title='데이터 타입' id='col_Type'> ";
innerTR_Col+=" <option>VARCHAR2</option> ";
innerTR_Col+=" <option>NUMBER</option> ";
innerTR_Col+=" <option>CHAR</option> ";
innerTR_Col+=" <option>DATE</option> ";
innerTR_Col+=" <option>TIMESTAMP</option> ";
innerTR_Col+=" <option>DEC</option> ";
innerTR_Col+=" <option>BOLB</option> ";
innerTR_Col+=" <option></option> ";
innerTR_Col+=" </select></td> ";
innerTR_Col+=" <td align='center'><input type='text' size='3' ";
innerTR_Col+=" class='col_Size' value='10' title='데이터 사이즈' maxlength='3' /> ";
innerTR_Col+=" </td> ";
innerTR_Col+=" <TD align='center'><input type='checkbox' id='col_check' ";
innerTR_Col+=" title='NULL 허용 여부' /></TD> ";
innerTR_Col+=" <td align='center'><input name='primary' type='radio' ";
innerTR_Col+=" class='col_Primary' title='기본키'/></td> ";
innerTR_Col+="</tr> ";
$("#btncolAddSpan").append(innerTR_Col);
});
$("#create_reference").live("click", function() {
//
$.ajax({
"url" : "tableData.do",
"type" : "post",
"dataType" : "json",
"data" : {
"dataType" : "init"
},
"success" : function(data) {
var str ="";
$.each(
data,
function(i, v) {
str +="<option>"+v.TableName+"</option>";
});
if (str != strRef) {
strRef = str;
$("#create_reference").html(str);
}
// 테이블 가져 왔는지 확인
//alert(tableListArray.toString());
},
"error" : function(info, xhr) {
if (info.readyState == '4') {
alert('문제가 발생했습니다.\n상태코드 : ' + info.status + '\n\n'
+ info.responseText);
} else {
alert('문제가 발생했습니다.\n잠시후 다시 시도해 주세요.\n 상태코드 : '
+ info.status);
}
}
});
});
$("#btncolMinus").live("click",function(){
var sqlInfo=$("#dialog-createTable tr");
var maxSize=sqlInfo.size();
if(maxSize<=6){
return;
}
$("#dialog-createTable tr").eq(maxSize-4).remove();
});
$("#create_reference_table")
.live(
"click",
function() {
var x = document
.getElementById("create_reference");
//alert(x.options[x.selectedIndex].value);
var ref_selected = x.options[x.selectedIndex].value;
var str = "";
$
.ajax({
"url" : "tableData.do",
"type" : "post",
"dataType" : "json",
"data" : {
"dataType" : "Reference_col",
"selectedItem" : ref_selected
},
"success" : function(data) {
//alert("가져온 데이터 입니다 . " + data);
$.each(data, function(i, v) {
str += "<option>"
+ v.column
+ "</option>";
});
if (str != strRefCol) {
strRefCol = str;
$("#create_reference_table")
.html(str);
}
},
"error" : function(info, xhr) {
if (info.readyState == '4') {
alert('문제가 발생했습니다.\n상태코드 : '
+ info.status
+ '\n\n'
+ info.responseText);
} else {
alert('문제가 발생했습니다.\n잠시후 다시 시도해 주세요.\n 상태코드 : '
+ info.status);
}
}
});
});
});
</script>
<div id="bodyBG">
<div id="dialog-createTable" style="width: 500px; height: 370px; ">
<form name="createForm">
<table style="width: 500px; height: 250px; overflow: auto;">
<tbody><tr>
<td colspan="3">
<h3>
CREATE TABLE <input id="table_name" name="table_name" type="text" size="15" class="create_Name" title="테이블 이름">
</h3>
</td>
<td>
</td>
<td colspan="2">
<input id="btncolAdd" type="button" value="+" title="컬럼추가">
<input id="btncolMinus" type="button" value="-" title="컬럼 삭제">
</td>
</tr>
<tr>
<td width="162" align="center">col_name</td>
<td width="153" align="center">DataType</td>
<td width="69" align="center">DataSize</td>
<td width="72" align="center">NOT NULL</td>
<td width="69" align="center">PK</td>
</tr>
<tr>
<td align="center"><input type="text" size="15" class="col_Name" title="컬럽 이름"></td>
<td align="center"><select title="데이터 타입" id="col_Type">
<option>NUMBER</option>
<option>VARCHAR2</option>
<option>CHAR</option>
<option>DATE</option>
<option>TIMESTAMP</option>
<option>DEC</option>
<option>BOLB</option>
<option></option>
</select></td>
<td align="center"><input type="text" size="3" class="col_Size" value="10" title="데이터 사이즈" maxlength="3">
</td>
<td align="center"><input type="checkbox" id="col_check" title="NULL 허용 여부" checked="checked"></td>
<td align="center"><input name="primary" type="radio" class="col_Primary" title="기본키" checked="checked"></td>
</tr>
</tbody><tbody id="btncolAddSpan" style="overflow: auto;">
</tbody>
<tbody><tr>
<td colspan="5"></td>
</tr>
<tr>
<td colspan="5">
Constraint <input type="text" size="6" class="create_constraint" title="제약명을 입력해주세요." value="####_PK">FOREIGN KEY <select id="create_foreign">
<option>클 릭</option>
</select>
</td>
</tr>
<tr>
<td>
</td>
<td colspan="5" style="text-align: left;">
REFERENCES <select id="create_reference">
<option>클 릭</option>
</select> ( <select id="create_reference_table">
<option>클 릭</option>
</select> )
</td>
</tr>
<tr style="height: 80px">
<td colspan="3">
</td>
<td colspan="2">
<input id="helperOK" type="button" value="O K">||<input id="helperCancel" type="button" value="Cancel">
</td>
</tr>
</tbody></table>
</form>
</div>
</div>
'J-Query' 카테고리의 다른 글
jQuery 라이브러리 사용 방법 (1) | 2012.11.15 |
---|---|
sliding (0) | 2012.11.15 |
jQuey 1.8 이 정식 릴리즈 되었습니다. (0) | 2012.08.24 |
jQuery.slide() (0) | 2012.07.10 |
body CSS 그라데이션 흰색 - > 블랙 (0) | 2012.06.22 |