/** 검색에서 넘어온 파라메터로 화면 초기화 */ function initSearchParam() { // 리스트와 상세화면의 키워드폼 이름이 다름 var keywordSetF = false; if($("#cms_keyword").length > 0) { $("#cms_keyword").val(view_form.keyword.value); $("#cms_keyword_current").val(view_form.keyword.value); keywordSetF = true; } if($("#cms_keywordFV").length > 0) { $("#cms_keywordFV").val(view_form.keyword.value); keywordSetF = true; } if(!keywordSetF && $("#keyword").length > 0) { $("#keyword").val(view_form.keyword.value); $("#keyword_current").val(view_form.keyword.value); } // 필터가 존재할때만 if($(".filters").length > 0) { // 페이징값 if(view_form.pageNo.value > 1) { $(".page").val(view_form.pageNo.value); } // 페이지볼륨 if(view_form.pageVol.value > 1) { var options = $("select[name=pageVol]").find("option"); for(var i=0; i < options.length; i++) { if($(options[i]).attr("value") == view_form.pageVol.value) { $(options[i]).attr("selected", "selected"); } else { $(options[i]).removeAttr("selected"); } } } setFilter(view_form.media.value, $("li.filter_media")); setFilter(view_form.horiVertChoice.value, $("li.filter_horizontal")); setFilter(view_form.size.value, $("li.filter_size")); setFilter(view_form.saleState.value, $("li.filter_saleState")); setFilter(view_form.durationReg.value, $("li.filter_durationReg")); setFilter(view_form.durationTake.value, $("li.filter_durationTake")); } } function setFilter(value, filterForm) { var findF = false; filterForm.find("li").each(function(index) { if($(this).attr("value") == value) { findF = true; } }); if(findF) { var itemName = ""; filterForm.find("li").each(function(index) { if($(this).attr("value") == value) { $(this).attr("selected", "selected"); itemName = $(this).text(); } else { $(this).removeAttr("selected"); } }); var titleStr = filterForm.find("span").text(); var titleFontStr = filterForm.find("font").text(); var header = ""; if(titleStr.indexOf(":") != -1) { // 보도사진 페이지 header = titleStr.substring(0, titleStr.indexOf(":")+2); filterForm.find("span").text(header + itemName); }else { // CMS 페이지 header = titleFontStr; filterForm.find("span").html("" + header + "
" + itemName); } } else { if(value.charAt(0) == 'C') { value = value.substring(1); filterForm.find("li").each(function(index) { if($(this).hasClass("choice")) { $(this).attr("selected", "selected"); $(this).attr("value", "C"+value); } else { $(this).removeAttr("selected"); } }); var titleStr = filterForm.find("span").text(); var header = titleStr.substring(0, titleStr.indexOf(":")+2); filterForm.find("span").text(header + value); } } } /* //날짜 입력 오늘 날짜, 입력되도록 해둠 2017.04.06 이재우 // 익스플로러에서 비정상 동작하여 사용안함 / 오늘로 이동으로 변경함 $(document).on('click', ".datepicker" , function(){ var elmnt = $(this); $("button.ui-datepicker-current").on('click', function(){ $(elmnt).datepicker('setDate',new Date()); $(".ui-datepicker-close").click(); }); }); */ function userBookmarkList() { // 사용자가 찜한 북마크 목록 var param = "action=list"; $.ajax({ type: "POST", url: "bookmark.api?"+param, dataType: "json", success : function(data) { $(data.result).each(function(key, val) { var uciCode = val.uciCode; $("#search_list ul .over_wish").each(function(idx, value) { // 가로맞춤 보기 var list_uci = $("#search_list ul .over_wish").eq(idx).attr("value"); if(list_uci == uciCode) { $("#search_list ul .over_wish").eq(idx).addClass("on"); } }); }); } }); } function checkNumber(event) { event = event || window.event; var keyID = (event.which) ? event.which : event.keyCode; if( ( keyID >=48 && keyID <= 57 ) || ( keyID >=96 && keyID <= 105 ) || (keyID == 8 || keyID == 46 || keyID == 37 || keyID == 39 || keyID == 16 || keyID == 35 || keyID == 36) ) { return; } else if(keyID == 13) { if(event.currentTarget.name = "pageNo") { event.currentTarget.blur(); } else { search(); } } else { return false; } } function goPage(pageNo) { if(pageNo < 1) { pageNo = 1; } else if(pageNo > $("div .paging span.total").html()) { pageNo = $("div .paging span.total").html(); } $("input[name=pageNo]").val(pageNo); search(); } function search() { searchInternal($("#serviceMode").length == 0); } function searchPage() { var pageNo = $("input[name=pageNo]").val().match(/[0-9]/g).join(""); if(Number(pageNo) > Number($("div .paging span.total").html())) { alert("입력이 최대 페이지보다 큽니다"); return; } search(); } function searchInternal(cmsMode) { $("#searchProgress").css("display", "block"); var fullSearch = false; // 전체매체 검색(비제휴 매체 포함) if(cmsMode) { fullSearch = $("#fullSearch").is(":checked"); } var keyword = ""; if(cmsMode) { keyword = $("#cms_keyword_current").val(); } else { keyword = $("#keyword_current").val(); } keyword = $.trim(keyword); var pageNo = $("input[name=pageNo]").val(); var transPageNo = pageNo.match(/[0-9]/g).join(""); if(pageNo != transPageNo) { pageNo = transPageNo; $("input[name=pageNo]").val(pageNo); } var pageVol = $("select[name=pageVol]").val(); var contentType = $(".filter_contentType .filter_list").find("[selected=selected]").attr("value"); var media = $(".filter_media .filter_list").find("[selected=selected]").attr("value"); var durationReg = $(".filter_durationReg .filter_list").find("[selected=selected]").attr("value"); //console.log("xx"+durationReg); var durationTake = $(".filter_durationTake .filter_list").find("[selected=selected]").attr("value"); var colorMode = $(".filter_color .filter_list").find("[selected=selected]").attr("value"); var horiVertChoice = $(".filter_horizontal .filter_list").find("[selected=selected]").attr("value"); var portRight = $(".filter_portRight .filter_list").find("[selected=selected]").attr("value"); var includePerson = $(".filter_incPerson .filter_list").find("[selected=selected]").attr("value"); var group = $(".filter_group .filter_list").find("[selected=selected]").attr("value"); var saleState = $(".filter_saleState .filter_list").find("[selected=selected]").attr("value"); var size = $(".filter_size .filter_list").find("[selected=selected]").attr("value"); view_form.keyword.value = keyword; view_form.pageNo.value = pageNo; view_form.pageVol.value = pageVol; view_form.media.value = media; view_form.durationReg.value = durationReg; view_form.durationTake.value = durationTake; view_form.colorMode.value = colorMode; view_form.horiVertChoice.value = horiVertChoice; view_form.saleState.value = saleState; view_form.size.value = size; var sort = ""; var searchParam = { "keyword":keyword , "pageNo":pageNo , "pageVol":pageVol , "contentType":contentType , "media":media , "durationReg":durationReg , "durationTake":durationTake , "colorMode":colorMode , "horiVertChoice":horiVertChoice , "portRight":portRight , "includePerson":includePerson , "group":group , "saleState":saleState , "size":size , "sort":sort , "fullSearch":fullSearch }; console.log(searchParam); searchKeyword = keyword; //검색결과 없는 페이지를 만들기 위한 검색어 셋팅 if(cmsMode) { $("#cms_keyword").val(keyword); } else { $("#keyword").val(keyword); } var html = ""; $.ajax({ type: "POST", async: true, dataType: "json", data: searchParam, timeout: 1000000, url: searchTarget, success : function(data) { console.log(data); var count = data.count; // 총 갯수 var viewCnt = data.result.length; // 현재 페이지에 보여지는 목록 갯수 if(cmsMode) { makeCmsList(data); } else { makeServiceList(data); } $("#searchProgress").css("display", "none"); var pageVol = parseInt($("select[name='pageVol'] option:selected").val()); // 페이지당 표현단위 if(count < pageVol || viewCnt < pageVol) { // 총 갯수 혹은 현재 페이지 목록갯수가 표현단위보다 작을 때, [다음 페이지] 숨김 $(".more").hide(); }else{ $(".more").show(); } }, error : function(request, status, error) { alert("code:" + request.status + "\n" + "message:" + request.responseText + "\n" + "error:" + error); $("#searchProgress").css("display", "none"); } }); } var searchKeyword = ''; function makeServiceList(data) { var html = ""; if(data.result.length > 0){ $(data.result).each(function(key, val) { html += "
  • "; html += "
    "; html += "
    " + val.ownerName + "
    "; html += ""; html += "
    "; html += "
  • "; }); }else{ html += "
    "; html += "

    "; if(searchKeyword.length > 0) { html += ""+searchKeyword+"에 대한"; } else { html += "조건에 적합한"; } html += " 검색 결과가 없습니다."; html += "

    "; html += ""; html += "
    "; } $("#search_list ul").html(html); $(window).scrollTop(0); var totalCount = data.count; if(totalCount > 1000) totalCount = totalCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); // 천단위 콤마; var totalPage = data.totalPage; if(totalPage > 1000) totalPage = data.totalPage.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); // 천단위 콤마 $("div .result b").text(totalCount); $("div .paging span.total").html(totalPage); if(loginInfo != ""){ // 로그인 시, 찜 목록을 불러오기 userBookmarkList(); } } function makeCmsList(data) { var html = ""; if(data.result.length > 0){ $(data.result).each(function(key, val) { var blind = (val.saleState == 2) ? "blind" : ""; var deleted = (val.saleState == 3) ? "deleted" : ""; var coverClass = ""; if(val.saleState == 2) { coverClass = "img_blind"; } else if(val.saleState == 3) { coverClass = "img_del"; } html += "
  • "; html += "
    "; if(val.saleState != 3) { html += ""; } html += "" + val.uciCode + "" + val.ownerName + "
    "; html += ""; }); }else{ html += "
    "; html += "

    "; if(searchKeyword.length > 0) { html += ""+searchKeyword+"에 대한 검색 결과가 없습니다."; } else { html += "조건에 적합한 검색 결과가 없습니다."; } html += "

    "; html += ""; html += "
    "; } $("#cms_list2 ul").html(html); var totalCount = data.count; if(totalCount > 1000) totalCount = totalCount.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); // 천단위 콤마; var totalPage = data.totalPage; if(totalPage > 1000) totalPage = totalPage.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); // 천단위 콤마; $("div .result b").html(totalCount); $("div .paging span.total").html(totalPage); } function relation_photo() { var keyword = ""; keyword = $.trim(keyword); var pageNo = "1"; var pageVol = "10"; var contentType = $(".filter_contentType .filter_list").find("[selected=selected]").attr("value"); var media = 0; var duration = ""; var colorMode = "0"; var horiVertChoice = "0"; var size = "0"; var portRight = $(".filter_portRight .filter_list").find("[selected=selected]").attr("value"); var includePerson = $(".filter_incPerson .filter_list").find("[selected=selected]").attr("value"); var group = $(".filter_group .filter_list").find("[selected=selected]").attr("value"); var searchParam = { "uciCode":$('#uciCode').val() ,"keyword":keyword , "pageNo":pageNo , "pageVol":pageVol , "contentType":contentType , "media":media , "duration":duration , "colorMode":colorMode , "horiVertChoice":horiVertChoice , "size":size , "portRight":portRight , "includePerson":includePerson , "group":group }; $("#keyword").val($("#keyword_current").val()); console.log(searchParam); var html = ""; $.ajax({ type: "POST", async: false, dataType: "json", data: searchParam, timeout: 1000000, url: "search", success : function(data) { console.log(data); $(data.result).each(function(key, val) { html += '
  • '; }); $(html).appendTo(".cfix"); }, error : function(request, status, error) { alert("code:" + request.status + "\n" + "message:" + request.responseText + "\n" + "error:" + error); } }); }