var assistGoodNames = new Array(); var goodInfoList = new Array(); var goodItemInfoList = new Array(); //품목 try { document.execCommand("BackgroundImageCache", false, true);} catch(err) {} // 탭메뉴 공통적으로 사용 //ex) tabOn(1,1); function tabOn(tabid,a) { for (var i=1;i<=10;i++) { if(i<10){inn="0"+i;} else {inn=""+i;} tabMenu = document.getElementById("tab"+tabid+"m"+i); tabContent = document.getElementById("tab"+tabid+"c"+i); tabMore = document.getElementById("tab"+tabid+"more"+i); if (tabMenu) { //객체가존재하면 if (tabMenu.tagName=="IMG") { tabMenu.src = tabMenu.src.replace("_on.", "_off."); } //이미지일때 if (tabMenu.tagName=="A") { tabMenu.className=""; } //앵커일때 } if (tabContent) { tabContent.style.display="none"; } if (tabMore) { tabMore.style.display="none"; } } if(a<10){ann="0"+a;} else {ann=""+a;} tabMenu = document.getElementById("tab"+tabid+"m"+a); tabContent = document.getElementById("tab"+tabid+"c"+a); tabMore = document.getElementById("tab"+tabid+"more"+a); // alert(tabMenu.tagName); if (tabMenu) { //객체가존재하면 if (tabMenu.tagName=="IMG") { tabMenu.src = tabMenu.src.replace("_off.", "_on."); } //이미지일때 if (tabMenu.tagName=="A") { tabMenu.className="on"; } //앵커일때 } if (tabContent) { tabContent.style.display="block"; } if (tabMore) { tabMore.style.display="block"; } } function goContent(){ $('#contents').focus(); } function goMainContent(){ $('#contents').focus(); } $(document).ready(function(){ //이미지 롤오버 $(".overimg").mouseover(function (){ var file = $(this).attr('src').split('/'); var filename = file[file.length-1]; var path = ''; for(var i=0 ; i < file.length-1 ; i++){ path = ( i == 0 )?path + file[i]:path + '/' + file[i]; } $(this).attr('src',path+'/'+filename.replace('_off.','_on.')); }).mouseout(function(){ var file = $(this).attr('src').split('/'); var filename = file[file.length-1]; var path = ''; for(var i=0 ; i < file.length-1 ; i++){ path = ( i == 0 )?path + file[i]:path + '/' + file[i]; } $(this).attr('src',path+'/'+filename.replace('_on.','_off.')); }); // 메인화면 상단 자동완성 검색어 조회 $.ajax({ type:"POST", url:"/tprice/common/code/getAutoCompleteGoodNameList.do", dayaType:"json", success:function(data) { goodNameList = data.autoCompleteGoodNameList; $.each(goodNameList, function(i) { assistGoodNames.push(goodNameList[i].GOOD_NAME); goodInfoList[i] = new Array(); goodInfoList[i] = [goodNameList[i].GOOD_ID ,goodNameList[i].GOOD_NAME ,goodNameList[i].GOOD_SMLCLS_CODE ,goodNameList[i].GOOD_SMLCLS_NAME ,goodNameList[i].GOOD_MIDCLS_CODE ,goodNameList[i].GOOD_MIDCLS_NAME ,goodNameList[i].FILE_RGTN_SEQ ]; }); } ,failure:function(data) { } }); var $search = $('#schWord'); var $listBox = $('#autocomplete-list'); var $list = $listBox.find('ul'); // 입력 필드에서 검색어를 입력할 때마다 자동완성 목록을 업데이트 $search.on('input', function() { var query = $(this).val().toLowerCase(); $listBox.hide(); // 목록 숨기기 $list.empty(); // 목록 비우기 // 검색어가 있으면 저장된 데이터에서 자동완성 항목을 필터링 if (query) { var matches = assistGoodNames.filter(function(item) { return item.toLowerCase().includes(query); // 대소문자 구분 없이 필터링 }); if (matches.length > 0) { matches.forEach(function(item) { var $btn = $('').text(item); var $li = $('
').append($btn); $list.append($li); }); $listBox.show(); // 목록 표시 } } }); /* // 목록 항목에 포커스를 주는 함수 function focusListItem(index) { var items = $list.children('li'); items.removeClass('focused'); // 이전 포커스를 제거 if (index >= 0 && index < items.length) { $(items[index]).addClass('focused'); } } */ /* 25.04 웹접근성 상품명입력 자동입력 변경 이승진 */ // 'Tab' 키를 눌러 목록 항목을 탐색 /* var selectedIndex = -1; let isTab = false; $search.on('keydown', function(e) { var items = $list.children('li'); var searchval = ""; if (e.key === 'Tab') { e.preventDefault(); // 기본 동작인 포커스 이동 막기 isTab = (e.key === 'Tab' && e.shiftKey); searchval = $("#schWord").val(); // alert(searchval); if(searchval == "" || searchval == null){ if(isTab){ $("#header .logo").focus(); return; }else{ $(".search input").focus(); return; } } if (e.shiftKey) { // 'Shift + Tab' 눌렀을 때 첫 번째 항목에서 벗어나면 입력 필드로 돌아감 if (selectedIndex === 0) { var items1 = $list.children('li'); items1.removeClass('focused'); // 이전 포커스를 제거 selectedIndex = -1; $listBox.hide(); // 목록 숨기기 $list.empty(); // 목록 비우기 $(".search input").val(""); $("#header .logo").focus(); return; } selectedIndex--; } else { // 마지막 항목에서 'Tab'을 눌렀을 때 입력 필드로 포커스 if (selectedIndex === items.length - 1) { var items2 = $list.children('li'); items2.removeClass('focused'); // 이전 포커스를 제거 $listBox.hide(); // 목록 숨기기 $list.empty(); // 목록 비우기 selectedIndex = -1; $(".search input").val(""); $(".search input").focus(); return; } selectedIndex++; } focusListItem(selectedIndex); // 포커스 이동 } else if (e.key === 'Enter') { // 선택된 항목을 입력 필드에 채우기 if (selectedIndex !== -1) { $search.val(items.eq(selectedIndex).text()); $listBox.hide(); // 목록 숨기기 $(".search input").focus(); } } isTab = false; }); */ // 항목 클릭 시, 선택한 항목을 입력 필드에 채우기 $list.on('click', 'li', function() { $search.val($(this).text()); $listBox.hide(); // 목록 숨기기 $("#btn_searchTop").focus(); }); // 초점 벗어나면 검색어 자동완성 숨기기 $('.logo a, kca a, .h_sitemap a, #close_search').on('focusin', function() { $listBox.hide(); }); // 검색어 자동완성 적용 /* 25.04 웹접근성 인증 리더기로 안된다고 해서 주석 이승진 $("#schWord").autocomplete({ source: assistGoodNames, select: function(event, ui) { $("#schWord").val(ui.item.value); return false; // 자동완성 목록이 닫히지 않도록 }, // focus: function () { // prevent value inserted on focus //자동완성 검색 키워를 입력하여 콤보박스 형태로 자동완성되었을때 //Key Down, Key Up 으로 선택시 입력 Text 박스에 입력한 //자동완성 키워드가 리셋되는 형상을 방지 하기위해 return false 함. //focus: function () 을 사용하지 않거나 사용하되 return true 를 하면 // 입력 Text 박스에 입력한 자동완성 키워드가 리셋 됨. // placeholder 도입으로 주석처리 by 황인환 2018-04-20 // 주석처리로 인해 키보드 조작이 안되서 다시 원복 by 황인환 2020-04-22 // return false; // }, open: function(){ var menu = $(".ui-menu"); var firstItem = $(".ui-menu-item:first-child"); setTimeout(function() { // firstItem.focus(); }, 2000); menu.on("focus",".ui-menu-item", function(){ menu.find(".ui-state-focus").removeClass("ui-state-focus"); $(this).addClass("ui-state-focus"); }); } }); // 'Tab' 키 이벤트 처리 $('#schWord').on('keydown', function(e) { if (e.key === 'Tab') { var activeItem = $('.ui-menu .ui-state-focus'); // 포커스된 항목 if (activeItem.length) { // Tab을 눌렀을 때 포커스된 항목을 선택 var selectedItem = activeItem.first(); $(this).val(selectedItem.text()); // 선택된 항목의 값으로 설정 e.preventDefault(); // 기본 동작인 탭 키 포커스 이동 막기 } } }); $('#schWord').keydown(function(key){ if(key.keyCode == 13) { $("#btn_searchTop").click(); } }); */ // 검색 버튼 $("#btn_searchTop").click(function(){ var goodName = $("#schWord").val(); var goodId = ""; var goodSmlclsCode = ""; var goodClassCode = ""; for(var i=0; i