/**
* ************************************************
* ¾÷¹«±×·ì¸í : °øÅë ÀÚ¹Ù½ºÅ©¸³Æ®
* ¼ºê¾÷¹«¸í : ÄÞº¸¹Ú½º¿ë ajax ½ºÅ©¸³Æ®
* ¼³¸í :
* ÀÛ¼ºÀÚ : dkhjmu
* ÀÛ¼ºÀÏ : 2007. 7. 31 ¿ÀÈÄ 5:25:55
* *************************************************
*/
// ÅäÁöÄÚµå
var COMBOLANDCODE = null;
// ½Ã±º±¸¿¡ ¾²´Â Ç÷¡±×
var AJAX_SGG_CODE = 1;
// À¾¸éµ¿¿¡ ¾²´Â Ç÷¡±×
var AJAX_UMD_CODE = 2;
// ¿¡ÀÌÀÛ½º¸¦ »ç¿ëÇÏ°í ÀÖ´ÂÁö µîÀÇ »óŸ¦ ³ªÅ¸³»´Â Ç÷¡±×
// 1 ÆĽÌÁß
// 0 ¹Ì»ç¿ë
var Ajax_Status = 0;
// false ¿¡ÀÌÀÛ½º¹Ì»ç¿ë(ÀÛ¾÷¿Ï·á)
// true ¿¡ÀÌÀÛ½º »ç¿ëÁß(ÀÛ¾÷Áß)
var Ajax_inUse = false;
// ·Ñ¹éÀÏ °æ¿ì¸¦ ³ªÅ¸³»´Â Ç÷¡±×
var Ajax_rollback=false;
// ¿¡ÀÌÀÛ½º ¿¬°áÀ» À§ÇÑ ÇÔ¼ö
function initRequest(){
if (window.XMLHttpRequest) {
return new XMLHttpRequest();
} else if (window.ActiveXObject) {
var isIE = true;
return new ActiveXObject("Microsoft.XMLHTTP");
}
}
// ¿¡ÀÌÀÛ½º ¿¬°áÀ»ÇÏ´Â ÇÔ¼ö
// searchkey pnu
// code À¾¸éµ¿, ½Ã±º±¸ ±¸ºÐ
// target ½Ã±º±¸, À¾¸éµ¿ ´ë»ó ±¸ºÐ
function doCompletion(searchKey, code, target) {
Ajax_Status = 0;
Ajax_inUse = true;
if (searchKey == "") {
return;
}
//Äڵ带 ã´Â°æ¿ì
var url = ContextPath +"/common/landCode.do?service=selectLandCodeComboBox&searchKey=" + searchKey + "&code=" + code;
if(code==0 && usecode!=null){
url = url + "&usecode="+usecode;
}
var req = initRequest();
//¿äûÀ» º¸³»°í ¹ä´Â ºÎºÐ
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {
//°á°ú °ªÀ» ÆĽÌÇÏ´Â ºÎºÐ
parseMessages(req.responseText, code, target);
Ajax_Status = 1;
Ajax_inUse = false;
} else if (req.status == 204) {
alert("204");
}
}
};
req.open("post", url, true);
req.send(null);
}
// µ¥ÀÌÅÍ°¡ ºÒ¾ÈÇÑ °æ¿ì ·Ñ¹éÇÑ´Ù.
function rollback(){
Ajax_rollback=true;
document.getElementById("selectLandType_").value = 1;
document.getElementById("sggnm").selectedIndex=0;
document.getElementById("umdnm").selectedIndex=0;
document.getElementById("rinm").selectedIndex=0;
document.getElementById("textfield").value = eliminateZero("0000");
document.getElementById("textfield2").value = eliminateZero("0000");
}
// µ¥ÀÌÅ͸¦ ÆĽÌÇÏ´Â ÇÔ¼ö
function parseMessages(responseText, code, target) {
document.getElementById("ri").style.visibility = "hidden";
//´ë»óÀÌ ½Ã±º±¸
if (code == 0) {
var resultString = "";
document.getElementById("sgg").innerHTML = resultString;
if(target!="" && target!=null){
document.getElementById("sggnm").value=target;
if(document.getElementById("sggnm").value==""){
rollback();
}
}
}
//´ë»óÀÌ À¾¸éµ¿
if (code == 1) {
var resultString = "";
document.getElementById("umd").innerHTML = resultString;
if(target!="" && target!=null){
document.getElementById("umdnm").value=target;
if(document.getElementById("umdnm").value==""){
rollback();
}
}
}
// ´ë»óÀÌ ¸®
if (code == 2) {
var resultString = "";
// if (resultString.length > 140) { // org bug
if (resultString.length > 130) {
document.getElementById("ri").style.visibility = "visible";
document.getElementById("ri").innerHTML = resultString;
if(target!="" && target!=null){
document.getElementById("rinm").value=target;
if(document.getElementById("rinm").value==""){
rollback();
}
}
}
}
}
// pnu¸¦ ¸¸µé¾î¾î¼ urlÀ» ÇÕÇØÁÖ´Â ÇÔ¼ö
function sumCode(url) {
var landCode = getLandCode();
if(landCode==null){
return 0;
}
var bobn = document.getElementById("textfield").value;
var bubn = document.getElementById("textfield2").value;
document.getElementById("bobn").value = bobn;
document.getElementById("bubn").value = bubn;
var ledgGbn = landCode.substring(10, 11);
// alert("bobn : " + bobn + " = bubn : " + bubn + " = ledgGbn : " + ledgGbn);
if(ledgGbn == "1" || ledgGbn == "2"){
url = url + "&landcode=" + landCode;
}else{
url = url + "&landcode=" + landCode + "&bobn=" + bobn + "&bubn=" + bubn;
}
if(document.getElementById("scale")!=null){
if(nScaleValue==false){
url=url+"&scale=0";
}else if(document.getElementById("scale").value!=null && document.getElementById("scale").value!=""){
url=url+"&scale="+trimByFront(document.getElementById("scale").value);
}else{
url=url+"&scale=0";
}
}else{
url=url+"&scale=0";
}
if(document.getElementById("gyujae")!=null){
url=url+"&gyujae="+document.getElementById("gyujae").checked;
}
if(document.getElementById("label")!=null){
url=url+"&label_type="+document.getElementById("label_type").value;
}
document.getElementById("sggCDname").action=url;
document.getElementById("sggCDname").method="post";
document.getElementById("sggCDname").submit();
document.getElementById("upLoad").style.visibility = "visible";
}
//pnu¸¸ ¸¸µé¾î¼ ³Ñ±â´Â ÇÔ¼ö
function sumCode() {
var landCode = getLandCode();
if(landCode==null){
return 0;
}
var url = sumcodeurl + "&landcode=" + landCode;
if(document.getElementById("scale")!=null){
if(nScaleValue==false){
url=url+"&scale=0";
}else if(document.getElementById("scale").value!=null && document.getElementById("scale").value!=""){
url=url+"&scale="+trimByFront(document.getElementById("scale").value);
}else{
url=url+"&scale=0";
}
}else{
url=url+"&scale=0";
}
if(document.getElementById("gyujae")!=null){
url=url+"&gyujae="+document.getElementById("gyujae").checked;
}
if(document.getElementById("label")!=null){
url=url+"&label_type="+document.getElementById("label_type").value;
}
document.getElementById("sggCDname").action=url;
document.getElementById("sggCDname").submit();
document.getElementById("upLoad").style.visibility = "visible";
}
function sumCode_road(sTransLandCd){
var landCode = sTransLandCd;
if(landCode==null){
return 0;
}
var url = sumcodeurl + "&landcode=" + landCode;
if(document.getElementById("scale")!=null){
if(nScaleValue==false){
url=url+"&scale=0";
}else if(document.getElementById("scale").value!=null && document.getElementById("scale").value!=""){
url=url+"&scale="+trimByFront(document.getElementById("scale").value);
}else{
url=url+"&scale=0";
}
}else{
url=url+"&scale=0";
}
if(document.getElementById("gyujae")!=null){
url=url+"&gyujae="+document.getElementById("gyujae").checked;
}
if(document.getElementById("label")!=null){
url=url+"&label_type="+document.getElementById("label_type").value;
}
//alert("url_road = " + url);
document.getElementById("sggCDname").action=url;
document.getElementById("sggCDname").method="post";
document.getElementById("sggCDname").submit();
document.getElementById("upLoad").style.visibility = "visible";
}
//°³º°°ø½ÃÁö°¡¿ë url¸¸µå´Â ÇÔ¼ö
function sumCode2(url) {
var landCode = getLandCode();
if(landCode==null){
return;
}
url = url + "&landcode=" + landCode;
if(document.getElementById("scale")!=null){
if(document.getElementById("scale").value!=null && document.getElementById("scale").value!=""){
url=url+"&scale="+trimByFront(document.getElementById("scale").value);
}else{
url=url+"&scale=0";
}
}else{
url=url+"&scale=0";
}
if(document.getElementById("gyujae")!=null){
url=url+"&gyujae="+document.getElementById("gyujae").checked;
}
return url;
}
// pnu¸¦ ¸¸µå´Â °øÅëÄÚµå
function getLandCode(){
var sgg=document.getElementById("sggnm").value;
//if(sgg==null||sgg==""){
if(sgg==null || sgg=="" || sgg == "½Ã,±º,±¸"){
alert("½Ã±º±¸ ¼±ÅÃÇØ ÁÖ¼¼¿ä");
return;
}
var umd = document.getElementById("umdnm").value;
//if(umd==null||umd==""){
if(umd==null || umd=="" || umd == "À¾,¸é,µ¿"){
alert("À¾¸éµ¿À» ¼±ÅÃÇØ ÁÖ¼¼¿ä");
return;
}
if(document.getElementById("ri").style.visibility=="visible"){
var ri= document.getElementById("rinm").value;
//if(ri==null||ri==""){
if(ri==null || ri=="" || ri == "¸®"){
alert("¸®¸¦ ¼±ÅÃÇØ ÁÖ¼¼¿ä");
return;
}
}
if(document.getElementById("textfield").value==null || document.getElementById("textfield").value==""){
alert("º»¹øÀ» ÀÔ·ÂÇØ ÁÖ¼¼¿ä");
document.getElementById("textfield").focus();
return;
}
var landCode = umd.substring(0, 8);
/*
landCode = landCode + addZeroCode(document.getElementById("rinm").value.substring(8, 10), 2) + document.getElementById("selectLandType").value;
landCode = landCode + addZeroCode(document.getElementById("textfield").value, 4);
landCode = landCode + addZeroCode(document.getElementById("textfield2").value, 4);
*/
landCode = landCode + addZeroCode(document.getElementById("rinm").value.substring(8, 10), 2) + document.getElementById("selectLandType_").value;
if(document.getElementById("selectLandType_").value == "1" || document.getElementById("selectLandType_").value == "2"){
landCode = landCode + addZeroCode(document.getElementById("textfield").value, 4);
landCode = landCode + addZeroCode(document.getElementById("textfield2").value, 4);
}else{
landCode = landCode + document.getElementById("textfield").value;
landCode = landCode + document.getElementById("textfield2").value;
}
return landCode;
}
// ¿¡ÀÌÀÛ½º¸¦ ÀÌ¿ëÇؼ ¼±ÅÃµÈ Áö¹øÀ» Á¤ÇØÁÖ´Â ÇÔ¼ö
function selectedLandCode(landcode) {
Ajax_rollback=false;
if(landcode=="" || landcode==null||landcode=='null'||landcode=='null00000000'){
doCompletion("0000000000", 0, "");
return;
}
landcode = landcode.toString();
COMBOLANDCODE = landcode;
var sgg = landcode.substring(0, 5);
sgg = sgg + "00000";
doCompletion("0000000000", 0, sgg);
/*
if(landcode.length==19){
var text1 = landcode.substring(11, 15);
var text2 = landcode.substring(15, 20);
document.getElementById("textfield").value = eliminateZero(text1.toString());
document.getElementById("textfield2").value = eliminateZero(text2.toString());
}
*/
if(strlen(landcode)==19){
var text1 = "";
var text2 = "";
var bunji = landcode.substring(11);
var j = 0;
for (var i = 0; i < strlen(bunji); i++) {
if (strlen(bunji.substring(j, j+1)) == 2) {
i++;
}
if (i < 4) {
text1 += bunji.substring(j, j+1);
} else {
text2 += bunji.substring(j, j+1);
}
j++;
}
if (text1.length == 4) {
if(Number(text1)) text1 = eliminateZero(text1);
}
if(Number(text2)){
if (text2.length == 4) {
text2 = eliminateZero(text2);
}
}
document.getElementById("textfield").value = text1;
document.getElementById("textfield2").value = text2;
}
var umd = landcode.substring(0, 8);
var ri = landcode.substring(8, 10);
if(umd.substring(5,8)=="000"){
doCompletion(sgg, 1);
return;
}
// ½Ã°£ °£°ÝÀ» µÎ¾î¼ ½ÇÇàÇÑ´Ù
setTimeout("invokeAjaxFunction(COMBOLANDCODE.toString(), AJAX_SGG_CODE)", 100);
umd = umd + "00";
if (ri != "00") {
setTimeout("invokeAjaxFunction(COMBOLANDCODE.toString(), AJAX_UMD_CODE)", 2000);
}
var im = landcode.substring(10, 11);
document.getElementById("selectLandType_").value=parseInt(im, 10);
if(document.getElementById("selectLandType_").value==null){
document.getElementById("selectLandType_").value=1;
}
}
function selectedRoadCode(landcode){
//alert(landcode);
}
// ¿¬¼ÓÀ¸·Î ¼öÇàÇÏ°Ô ÇÏ´Â ÇÔ¼ö
function invokeAjaxFunction(landcode, runcode) {
if (Ajax_inUse == false && Ajax_rollback==false) {
var search;
var target;
if (runcode == AJAX_SGG_CODE) {
search = landcode.substring(0, 5);
search = search + "00000";
target = landcode.substring(0, 8)+"00";
} else if (runcode == AJAX_UMD_CODE) {
search = landcode.substring(0, 8);
search = search + "00";
target=landcode.substring(0, 10);
}
doCompletion(search, runcode, target);
if (runcode == 1) {
setTimeout("selectComboBox(COMBOLANDCODE.toString(), AJAX_SGG_CODE)", 100);
} else {
setTimeout("selectComboBox(COMBOLANDCODE.toString(), AJAX_UMD_CODE)", 100);
}
} else {
if (runcode == 1) {
setTimeout("invokeAjaxFunction(COMBOLANDCODE.toString(), AJAX_SGG_CODE)", 100);
} else {
setTimeout("invokeAjaxFunction(COMBOLANDCODE.toString(), AJAX_UMD_CODE)", 100);
}
}
}
// ÄÞº¸¹Ú½º¸¦ ¼±ÅÃÇÏ°Ô ¸¸µå´Â ÇÔ¼ö
function selectComboBox(landcode, runcode) {
if (Ajax_Status == 1) {
Ajax_Status = 0;
} else {
if (runcode == 1) {
setTimeout("selectComboBox(COMBOLANDCODE.toString(), AJAX_SGG_CODE)", 100);
} else {
setTimeout("selectComboBox(COMBOLANDCODE.toString(), AJAX_UMD_CODE)", 100);
}
}
}
// url·Î ¿äûÀ» º¸³»°í ¹Þ´Â ÇÔ¼ö
function doCompletionLandUse(url) {
url= sumCode2(url);
var req = initRequest();
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {
parseMessagesLandUse(req.responseXML);
} else if (req.status == 204) {
alert("204");
}
}
};
req.open("post", url, true);
req.send(null);
}
// xmlÀ» ÆĽÌÇÏ´Â ÇÔ¼ö(¹Ì»ç¿ë)
function parseMessagesLandUse(responseXML){
var landuseinfo=responseXML.getElementsByTagName("landuseinfo")[0];
var vlocation=landuseinfo.getElementsByTagName("vlocation")[0].childNodes[0].nodeValue;
var sublocation=landuseinfo.getElementsByTagName("subLocation")[0].childNodes[0].nodeValue;
var landObj=landuseinfo.getElementsByTagName("landObj")[0].childNodes[0].nodeValue;
var area=landuseinfo.getElementsByTagName("area")[0].childNodes[0].nodeValue;
var part1=landuseinfo.getElementsByTagName("part1")[0].childNodes[0].nodeValue;
var part2=landuseinfo.getElementsByTagName("part2")[0].childNodes[0].nodeValue;
var part3=landuseinfo.getElementsByTagName("part3")[0].childNodes[0].nodeValue;
var part4=landuseinfo.getElementsByTagName("part4")[0].childNodes[0].nodeValue;
var part5=landuseinfo.getElementsByTagName("part5")[0].childNodes[0].nodeValue;
var imageFileName=landuseinfo.getElementsByTagName("imageFileName")[0].childNodes[0].nodeValue;
var remarkImageInfoList=landuseinfo.getElementsByTagName("remarkImageInfoList")[0].childNodes[0].nodeValue;
var strMapScale=landuseinfo.getElementsByTagName("strMapScale")[0].childNodes[0].nodeValue;
document.all.vlocation.innerHTML=vlocation;
document.all.subLocation.innerHTML=sublocation;
document.all.landObj.innerHTML=landObj;
document.all.area.innerHTML=area;
document.all.part1.innerHTML=part1;
document.all.part2.innerHTML=part2;
document.all.part3.innerHTML=part3;
document.all.part4.innerHTML=part4;
document.all.part5.innerHTML=part5;
document.all.imageFileName.innerHTML=imageFileName;
document.all.remarkImageInfoList.innerHTML=remarkImageInfoList;
document.all.scale.value=strMapScale;
}