var first_Focus_i = -1; var currentFocus = -1; var user_input_txt; var refresh_autocomplete = 0; // ajax(ÀÚµ¿¿Ï¼º) start/stop flag var AUTO_COMPLETE_QUEUE = 0; // =========================== sleep function sleep(ms) { //return new Promise(resolve => setTimeout(resolve, ms)); } // =========================== get ÀÚµ¿¿Ï¼º data // --- async function Get_Auto_Complete_Words(tm) { if( tm == '' ) tm = 100; // --- await sleep(tm); user_input_txt = document.s_srch_frm.search_txt.value; if( user_input_txt == '' ) { $("#s_srch_frm").attr( 'autocomplete', 'on' ); // ºê¶ó¿ìÀúÀÇ ÀÚµ¿¿Ï¼º on closeAllLists(); return false; } else if( refresh_autocomplete == 0 ) { return false; } $("#s_srch_frm").attr( 'autocomplete', 'off' ); // ºê¶ó¿ìÀúÀÇ ÀÚµ¿¿Ï¼º off // if( document.s_srch_frm.MAIN_CATE && // document.s_srch_frm.MAIN_CATE.value == 'mobile' ) // { // $("#auto_c_search_txt #srch_txt").val($(".t_srch_txt").val()); ////console.log($("#s_srch_frm #search_txt").val()); //console.log($("#auto_c_search_txt #srch_txt").val()); ////return false; // //Do_Action('auto_c_search_txt'); // ajax_client_main('get_auto_complete', 'auto_c_search_txt'); // } // else // GET_JSON_DATA( 'auto_c_search_txt', '', 'auto_c_search_txt', '', '' ); $("#auto_c_search_txt #srch_txt").val($(".t_srch_txt").val()); ajax_client_main('get_auto_complete', 'auto_c_search_txt'); $(".autocomplete-items").css("display","block"); } // =========================== ¼±ÅÃÇÑ ÀÚµ¿¿Ï¼º °Ë»ö¾î search_txt ÀÔ·Â function insert_autocomplete_word(arr) { //if( arr[2] == 'kyg' || arr[2] == 'pre' ) //{ // var current_path_nm = window.location.pathname; // var ex_current_path_nm = current_path_nm.split("/"); // var current_fnm = ex_current_path_nm[ex_current_path_nm.length-1]; // var current_upcate = ex_current_path_nm[ex_current_path_nm.length-2]; // var current_loc_href= window.location.href; // // if( current_fnm == 'map_srch_v2.php' || current_fnm == 'map_srch_v3.php' || ( document.s_srch_frm.MAIN_CATE && document.s_srch_frm.MAIN_CATE.value == 'mobile' )) // { // detail_vw(arr[2],arr[6],arr[7],arr[8]); // return false; // } //} document.s_srch_frm.search_txt.value = arr[0]; document.s_srch_frm.auto_complete_word.value = arr[1]; document.s_srch_frm.auto_complete_cate.value = arr[2]; document.s_srch_frm.auto_complete_word_02.value = arr[3]; if( document.s_srch_frm.auto_complete_lat ) document.s_srch_frm.auto_complete_lat.value = arr[4]; if( document.s_srch_frm.auto_complete_lng ) document.s_srch_frm.auto_complete_lng.value = arr[5]; } // =========================== function detectIE() { var ua = window.navigator.userAgent; // Test values; Uncomment to check result ¡¦ // IE 10 // ua = 'Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Trident/6.0)'; // IE 11 // ua = 'Mozilla/5.0 (Windows NT 6.3; Trident/7.0; rv:11.0) like Gecko'; // Edge 12 (Spartan) // ua = 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.71 Safari/537.36 Edge/12.0'; // Edge 13 // ua = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2486.0 Safari/537.36 Edge/13.10586'; var msie = ua.indexOf('MSIE '); if(msie > 0) { // IE 10 or older => return version number return parseInt(ua.substring(msie + 5, ua.indexOf('.', msie)), 10); } var trident = ua.indexOf('Trident/'); if(trident > 0) { // IE 11 => return version number var rv = ua.indexOf('rv:'); return parseInt(ua.substring(rv + 3, ua.indexOf('.', rv)), 10); } var edge = ua.indexOf('Edge/'); if(edge > 0) { // Edge (IE 12+) => return version number return parseInt(ua.substring(edge + 5, ua.indexOf('.', edge)), 10); } // other browser return false; } // =========================== autocomplete ÇÔ¼ö function autocomplete(inp) { //inp.addEventListener("input", function(e) { // refresh_autocomplete = 1; // closeAllLists(); // user_input_txt = document.s_srch_frm.search_txt.value; // if( user_input_txt == '' ) { return false; } // currentFocus = -1; // Get_Auto_Complete_Words(100); //}); inp.addEventListener("focus", function(e) { if($(this).val() == '') { console.log('cjsss focus -->'+$(this).val()+'<'); } }); inp.addEventListener("keyup", function(e) { if($(this).val() == '') { Cjs_setCookie('smart_srch_lat', '', 1); Cjs_setCookie('smart_srch_lng', '', 1); if( typeof Setcookie_Han != 'undefined') Setcookie_Han('search_txt', ''); document.s_srch_frm.auto_complete_cate.value = ""; document.s_srch_frm.auto_complete_word.value = ""; document.s_srch_frm.auto_complete_word_02.value = ""; document.s_srch_frm.auto_complete_lat.value = ""; document.s_srch_frm.auto_complete_lng.value = ""; } // ----------------------- if($(this).val().length >= 0) { //console.log(document.s_srch_frm.search_txt.value); var x = document.getElementById(this.id + "autocomplete-list"); //var x = document.getElementById("search_txtautocomplete-list"); if(x) x = x.getElementsByTagName("div"); // ------------------------ if(e.keyCode == 40) { // down arrow //e.preventDefault(); /*If the arrow DOWN key is pressed, increase the currentFocus variable:*/ /*and and make the current item more visible:*/ if( first_Focus_i == -2 ) { first_Focus_i = -1;} currentFocus++; addActive(x); if( x[currentFocus].getElementsByTagName("input")[0] ) { ex_input_value = x[currentFocus].getElementsByTagName("input")[0].value.split('|_|'); insert_autocomplete_word(ex_input_value); } } else if(e.keyCode == 38) { // up //e.preventDefault(); /*If the arrow UP key is pressed, decrease the currentFocus variable:*/ /*and and make the current item more visible:*/ if( first_Focus_i == -2 ) { currentFocus = -1; first_Focus_i = -1; return false;} currentFocus--; addActive(x); if( x[currentFocus].getElementsByTagName("input")[0] ) { ex_input_value = x[currentFocus].getElementsByTagName("input")[0].value.split('|_|'); insert_autocomplete_word(ex_input_value); } } else if(e.keyCode == 27) { // esc closeAllLists(); } else if(e.keyCode == 13) { // enter /*If the ENTER key is pressed, prevent the form from being submitted,*/ //e.preventDefault(); if(currentFocus > -1) { /*and simulate a click on the "active" item:*/ if(x) x[currentFocus].click(); } } else { refresh_autocomplete = 1; closeAllLists(); user_input_txt = document.s_srch_frm.search_txt.value; if( user_input_txt == '' ) { return false; } if( detectIE() >= 12 || detectIE() == false ) { currentFocus = -1; first_Focus_i = -1;} // edge, chrome else { currentFocus = -2; first_Focus_i = -2;} // IE $("#AUTO_COMPLETE_QUEUE").val(++AUTO_COMPLETE_QUEUE); Get_Auto_Complete_Words(100); } } }); function addActive(x) { /*a function to classify an item as "active":*/ if(!x) return false; //if( move_ct == 'prev' && first_Focus_i == -2 && currentFocus == 0 ) first_Focus_i = -1; /*start by removing the "active" class on all items:*/ removeActive(x); if(currentFocus >= x.length) currentFocus = 0; if(currentFocus < 0) currentFocus = (x.length - 1); /*add class "autocomplete-active":*/ x[currentFocus].classList.add("autocomplete-active"); } function removeActive(x) { /*a function to remove the "active" class from all autocomplete items:*/ for (var i = 0; i < x.length; i++) { x[i].classList.remove("autocomplete-active"); } } /*execute a function when someone clicks in the document:*/ document.addEventListener("click", function (e) { closeAllLists(e.target); }); } // ======================================== ÀÚµ¿¿Ï¼º ¸ñ·Ï Á¦°Å function closeAllLists(elmnt) { inp = document.s_srch_frm.search_txt; /*close all autocomplete lists in the document, except the one passed as an argument:*/ var x = document.getElementsByClassName("autocomplete-items"); for (var i = 0; i < x.length; i++) { if(elmnt != x[i] && elmnt != inp) { x[i].parentNode.removeChild(x[i]); } } //$(".autocomplete-items").css("display","none"); //console.log('none'); } // ======================================== ÀÚµ¿¿Ï¼º ¸ñ·Ï »ý¼º /* workdir/_common/script/ajax_ied/ajx_ied_main.js ÀÇ ÈÄó¸® ÇÔ¼ö¿¡¼­ »ç¿ë */ function Smart_Auto_Complete_List(arr) { //console.log(arr); //console.log(AUTO_COMPLETE_QUEUE+"/"+arr.AUTO_COMPLETE_QUEUE); if( AUTO_COMPLETE_QUEUE != arr.AUTO_COMPLETE_QUEUE ) return false; ///console.log(arr.DATA); var arr = arr.DATA; //console.log(arr); var a, b, i, val = document.getElementById("search_txt").value; /*close any already open lists of autocompleted values*/ if( $("#MAP_DEVICE_TP").val() == 'mobile' && val == '' ) { } else if(!val) { return false;} closeAllLists(); // currentFocus = -1; /*create a DIV element that will contain the items (values):*/ a = document.createElement("DIV"); a.setAttribute("id", "search_txt" + "autocomplete-list"); a.setAttribute("class", "autocomplete-items autoc_item_box"); /*append the DIV element as a child of the autocomplete container:*/ document.s_srch_frm.search_txt.parentNode.appendChild(a); /*for each item in the array...*/ bd_i = 0; bf_d_cate = ""; for (i = 0; i < arr.length; i++) { tmp_a_place = ""; tmp_idx_txt = ""; auto_comp_ad_txt = ""; auto_comp_ad_txt_02 = ""; auto_comp_ad_txt_idx = ""; auto_comp_cate = arr[i].d_cate; auto_comp_lat = arr[i].lat; auto_comp_lng = arr[i].lng; cc = arr[i].idx01; sn = arr[i].idx02; rn = arr[i].idx03; // ---------------------------------- //console.log(i+" - "+arr[i].d_cate+" / "+bf_d_cate); //console.log(arr[i]); if( arr[i].d_cate != bf_d_cate ) { autocomplete_item_sty = "border-top:1px solid #e9e9e9;"; } else { autocomplete_item_sty = ""; } // ---------------------------------- if( arr[i].d_cate == 'ad' ) { if( arr[i].p01 != '' ) auto_comp_ad_txt += arr[i].p01; // Áö¿ª or ½Ã±º±¸ or À¾¸éµ¿ if( arr[i].p02 != '' ) auto_comp_ad_txt += (arr[i].p01!=''?' ':'') + arr[i].p02; // Áö¿ª if( arr[i].p03 != '' ) auto_comp_ad_txt += (arr[i].p02!=''?' ':'') + arr[i].p03; // ½Ã±º±¸ auto_comp_word_02 = ""; } else if( arr[i].d_cate == 'sc' || arr[i].d_cate == 's2' || arr[i].d_cate == 'ug' ) { auto_comp_ad_txt = arr[i].p01; auto_comp_word_02 = arr[i].idx03; } else if( arr[i].d_cate == 'sw' ) { auto_comp_ad_txt = arr[i].p01; if( user_input_txt.indexOf('¿ª') == -1 ) auto_comp_ad_txt_02 = "¿ª"; auto_comp_word_02 = arr[i].p03; } else if( arr[i].d_cate == 'bd' ) { bd_i++; if( arr[i].p04 && arr[i].p04 != 'NF' ) tmp_a_place = arr[i].p04; if( arr[i].p05 && arr[i].p05 != 'NF' ) tmp_a_place += '-'+arr[i].p05; if( tmp_a_place == arr[i].p06 ) auto_comp_ad_txt = arr[i].p03+" "+arr[i].p06; else auto_comp_ad_txt = arr[i].p06; auto_comp_word_02 = ""; //if( arr[i].idx01 != '' ) auto_comp_ad_txt_idx += arr[i].idx01; // Áö¿ª or ½Ã±º±¸ or À¾¸éµ¿ //if( arr[i].idx02 != '' ) auto_comp_ad_txt_idx += (arr[i].idx01!=''?' ':'') + arr[i].idx02; // Áö¿ª //if( arr[i].idx03 != '' ) auto_comp_ad_txt_idx += (arr[i].idx02!=''?' ':'') + arr[i].idx03; // ½Ã±º±¸ } else if( arr[i].d_cate == 'ca' ) { auto_comp_ad_txt = arr[i].p03; auto_comp_word_02 = ""; } else if( arr[i].d_cate == 'rlty' ) { if( arr[i].p01 == 'NF' || arr[i].p01 == 'NA') continue; if( arr[i].p01 != '' ) auto_comp_ad_txt += arr[i].p01; // Áö¿ª or ½Ã±º±¸ or À¾¸éµ¿ if( arr[i].p02 != '' ) auto_comp_ad_txt += (arr[i].p01!=''?' ':'') + arr[i].p02; // Áö¿ª if( arr[i].p03 != '' ) auto_comp_ad_txt += (arr[i].p02!=''?'-':'') + arr[i].p03; // ½Ã±º±¸ if( arr[i].idx01 != '' ) auto_comp_word_02 = arr[i].idx01; else auto_comp_word_02 = ""; } else if( arr[i].d_cate == 'kyg' || arr[i].d_cate == 'pre' ) { if( arr[i].idx07 == 'sa_num' ) { auto_comp_ad_txt = arr[i].idx05; auto_comp_word_02 = ""; //auto_comp_ad_txt_idx = arr[i].idx06; // ¹°°Ç ¹øÈ£, ¹ý¿ø¸í auto_comp_ad_txt_idx = arr[i].idx05 + " " + arr[i].idx06; // ¹°°Ç ¹øÈ£, ¹ý¿ø¸í, °Ç¹°¸í } else { auto_comp_ad_txt = arr[i].p03; if( arr[i].p06 && arr[i].p06 != 'NF' ) auto_comp_ad_txt += " "+arr[i].p06; else { //if( arr[i].p04 && arr[i].p04 != 'NF' ) auto_comp_ad_txt += " "+arr[i].p04; //if( arr[i].p05 && arr[i].p05 != 'NF' ) auto_comp_ad_txt += " "+arr[i].p05; if( arr[i].p04 ) auto_comp_ad_txt += " "+arr[i].p04; if( arr[i].p05 ) auto_comp_ad_txt += "-"+arr[i].p05; } auto_comp_word_02 = ""; auto_comp_ad_txt_idx = arr[i].idx05 + " " + arr[i].idx06; // ¹°°Ç ¹øÈ£, ¹ý¿ø¸í, °Ç¹°¸í } } else if( arr[i].d_cate == 'gng' ) { auto_comp_ad_txt = arr[i].idx06; auto_comp_ad_txt += ""; auto_comp_word_02 = ""; auto_comp_ad_txt_idx = ""; if( arr[i].p01 != '' ) auto_comp_ad_txt_idx = arr[i].p01; // Áö¿ª or ½Ã±º±¸ or À¾¸éµ¿ if( arr[i].p02 != '' ) auto_comp_ad_txt_idx += (arr[i].p01!=''?' ':'') + arr[i].p02; // Áö¿ª if( arr[i].p03 != '' ) auto_comp_ad_txt_idx += (arr[i].p02!=''?' ':'') + arr[i].p03; // ½Ã±º±¸ } else if( arr[i].d_cate == 'bun' ) { auto_comp_ad_txt = arr[i].idx04; auto_comp_ad_txt += ""; auto_comp_word_02 = ""; auto_comp_ad_txt_idx = ""; if( arr[i].idx05 != '' ) auto_comp_ad_txt_idx += arr[i].idx05; if( arr[i].idx06 != '' ) auto_comp_ad_txt_idx += (arr[i].idx05!=''?'-':'') + arr[i].idx06; } else auto_comp_word_02 = ""; // ---------------------------------- ¿ª, ´ëÇб³, ´ëÇб³¹Ì¸¸, °Ç¹°¸íÀÏ °æ¿ì ¼¼ºÎÁ¤º¸(Áö¿ª,³ë¼±¹øÈ£) Ç¥½Ã if( arr[i].d_cate == 'sw' || arr[i].d_cate == 'sc' || arr[i].d_cate == 's2' || arr[i].d_cate == 'bd' || arr[i].d_cate == 'ca' ) { if( arr[i].d_cate == 'bd' ) { if( arr[i].idx01 == 'apt' ) tmp_idx_txt += "(¾ÆÆÄÆ®) "; else if( arr[i].idx01 == 'billa' ) tmp_idx_txt += "(´Ù¼¼´ë) "; else if( arr[i].idx01 == 'brgt' ) tmp_idx_txt += "(ºÐ¾ç) "; else if( arr[i].idx01 == 'otel' ) tmp_idx_txt += "(¿ÀÇǽºÅÚ) "; } // -------------------------- else if( arr[i].d_cate == 'sw' ) { if( arr[i].p02 ) tmp_idx_txt += arr[i].p02; if( arr[i].idx02 ) { if( tmp_idx_txt != '' ) tmp_idx_txt += "-"; tmp_idx_txt += arr[i].idx02; } } else if( arr[i].d_cate == 'ca' ) { if( arr[i].p02 ) tmp_idx_txt += arr[i].p02; } else { tmp_idx_txt += arr[i].idx01 + " " + arr[i].idx02 + " " + arr[i].idx03; } if( tmp_idx_txt ) auto_comp_ad_txt_idx = " " + tmp_idx_txt; } // ---------------------------------- b = document.createElement("DIV"); // ---------------------------------- b.style = autocomplete_item_sty; // ---------------------------------- bf_d_cate = arr[i].d_cate; // ---------------------------------- b.org_arr = arr[i]; //console.log(auto_comp_ad_txt+" / "+user_input_txt); console.log(arr[i]); if( typeof auto_comp_ad_txt != 'undefined' && auto_comp_ad_txt.indexOf(user_input_txt) != -1 || ( arr[i].d_cate == 'bd' && bd_i < 3 ) ) b.innerHTML = (auto_comp_ad_txt+auto_comp_ad_txt_02).replace(new RegExp(user_input_txt,"gi"), ''+user_input_txt+''); else b.innerHTML = auto_comp_ad_txt+auto_comp_ad_txt_02; if( auto_comp_ad_txt_idx ) b.innerHTML += " "+auto_comp_ad_txt_idx+""; //if( auto_comp_ad_txt_idx && ( arr[i].d_cate == 'kyg' || arr[i].d_cate == 'pre' ) ) // b.innerHTML += " "+auto_comp_ad_txt_idx+""; tmp_item_input = (auto_comp_ad_txt+auto_comp_ad_txt_02)+"|_|"+auto_comp_ad_txt+"|_|"+auto_comp_cate+"|_|"+auto_comp_word_02; tmp_item_input += "|_|"+auto_comp_lat+"|_|"+auto_comp_lng; tmp_item_input += "|_|"+cc+"|_|"+sn+"|_|"+rn; tmp_item_input += "|_|"+arr[i].p01+"|_|"+arr[i].p02+"|_|"+arr[i].p03+"|_|"+arr[i].p04+"|_|"+arr[i].p05;+"|_|"+arr[i].p06; tmp_item_input += "|_|"+arr[i].idx01+"|_|"+arr[i].idx02+"|_|"+arr[i].idx03+"|_|"+arr[i].idx04+"|_|"+arr[i].idx05+"|_|"+arr[i].idx06+"|_|"+arr[i].idx07; b.innerHTML += ""; b.innerHTML += ""; b.addEventListener("click", function(e) { Keypad_Running_Flag = false; refresh_autocomplete = 1; /*insert the value for the autocomplete text field:*/ ex_tmp_input_value = this.getElementsByTagName("input")[0].value.split('|_|'); insert_autocomplete_word(ex_tmp_input_value); map_lat = document.getElementById("auto_complete_lat").value; map_lng = document.getElementById("auto_complete_lng").value; if(typeof MapV1_setMapCenter !== "undefined") MapV1_setMapCenter(map_lat+"|_|"+map_lng); else $("#s_srch_frm").submit(); if( ex_tmp_input_value[2] == 'kyg' || ex_tmp_input_value[2] == 'pre' || ex_tmp_input_value[2] == 'gen' || ex_tmp_input_value[2] == 'bun' ) { var current_path_nm = window.location.pathname; var ex_current_path_nm = current_path_nm.split("/"); var current_fnm = ex_current_path_nm[ex_current_path_nm.length-1]; var current_upcate = ex_current_path_nm[ex_current_path_nm.length-2]; var current_loc_href= window.location.href; if( ( current_fnm == 'map_srch_v2.php' || current_fnm == 'map_srch_v3.php' ) && ( document.s_srch_frm.MAIN_CATE && document.s_srch_frm.MAIN_CATE.value == 'mobile' ) ) { if(ex_tmp_input_value[2] == 'kyg') { tpl_detail_vw('°æ¸Å',ex_tmp_input_value[19],ex_tmp_input_value[18],ex_tmp_input_value[8]); //console.log(ex_tmp_input_value); //console.log(arr[i]); } else detail_vw(ex_tmp_input_value[2],ex_tmp_input_value[6],ex_tmp_input_value[7],ex_tmp_input_value[8]); } } else if( ex_tmp_input_value[2] == 'bd' ) { open_basic_dview(ex_tmp_input_value[6], ex_tmp_input_value[9], ex_tmp_input_value[10], ex_tmp_input_value[11], ex_tmp_input_value[12], ex_tmp_input_value[13], '', '', '', ex_tmp_input_value[4], ex_tmp_input_value[5] ); } else if( ex_tmp_input_value[2] == 'gng' ) { Pop_Alert_Msg('gng_dview', 3); return false; } /*close the list of autocompleted values, (or any other open lists of autocompleted values:*/ //Get_Auto_Complete_Words(200); closeAllLists(); }); a.appendChild(b); if( $("#MAP_DEVICE_TP").val() == 'mobile' && val == '' ) { $(".autocomplete-items").css("display","block"); //console.log('123123123'); } } $(".autocomplete_arrow").click(function(e){ e.stopPropagation ? e.stopPropagation() : e.cancelBubble = true; refresh_autocomplete = 1; ex_tmp_input_value = $(this).next().val().split('|_|'); insert_autocomplete_word(ex_tmp_input_value); if(typeof MapV1_setMapCenter !== "undefined") { autocomplete_lat = document.getElementById("auto_complete_lat").value; autocomplete_lng = document.getElementById("auto_complete_lng").value; } closeAllLists(); }); }