개발자의 길

[javascript] JSP_query 변환 본문

2. JS

[javascript] JSP_query 변환

자르르 2016. 12. 15. 10:43


쿼리 변환


상단에 변환할 쿼리입력

하단에 변환할 StringBuffer 변수 넣어서 변환


소스

------------------------------------------------------------------------------------------

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>

 <HEAD>

  <TITLE>JSP 쿼리생성</TITLE>

  <META NAME="Generator" CONTENT="EditPlus">

  <META NAME="Author" CONTENT="">

  <META NAME="Keywords" CONTENT="">

  <META NAME="Description" CONTENT="">

 </HEAD>

<script>


// String replace

function replace(replace_string, str1, str2) {

var pos;

while (replace_string.indexOf(str1)>-1) {

pos = replace_string.indexOf(str1);

replace_string = "" + (replace_string.substring(0, pos) + str2 + replace_string.substring((pos + str1.length), replace_string.length));

}

return replace_string;

}


function F_outQuery(){

var DF = document.frmForm;

var inQuery = DF.inQuery.value;

var frontQuery = DF.frontQuery.value;

// var resultQuery = 'String strNewLineSql = logSqlNewLine ? "\\n" : "";\n';

var resultQuery = 'StringBuffer query=new StringBuffer();\n';

arrylineQuery = inQuery.split("\n");

// resultQuery = "String strNewLineSql = logSqlNewLine ? \"\n\" : "";";


for(i=0; i<arrylineQuery.length; i++){

arrylineQuery[i] = replace(arrylineQuery[i],"\r","");

arrylineQuery[i] = replace(arrylineQuery[i],"\n","");

resultQuery += frontQuery+'("   '+ arrylineQuery[i] +' ");\n';

}


DF.outQuery.value = resultQuery;

}

</script>

 <BODY>

<form name="frmForm">

<textarea name="inQuery" rows="25" cols="100"></textarea><br><p>

<textarea name="outQuery" rows="25" cols="100"></textarea><br>

<input type="text" name="frontQuery" value='query.append'><input type="button" onclick="javascript:F_outQuery()" value="변환">

<input type="button" value="지우기" onclick="javascript:reset()">

</form>

 </BODY>

</HTML>






이 포스팅은 쿠팡 파트너스 활동의 일환으로, 이에 따른 일정액의 수수료를 제공받습니다.
공유하기 링크
Comments