검색엔진 개발건

페이징, 문화원리스트, 생산년도 검색 제외하고 완료
This commit is contained in:
JSYOO 2021-10-15 16:38:25 +09:00
parent 53f13b0f4a
commit 16bd022b6d
8 changed files with 666 additions and 75 deletions

View File

@ -72,10 +72,20 @@ public class SearchVO {
private String filter_info_sido ; //필터 더보기버튼 유지
private String filter_info_type ; //필터 더보기버튼 유지
private String reQueryChk ="query"; //결과내재검색 체크 유지
private String filter_mylist; //검색결과 필터 순서 저장
private String filter_info_mylist; //검색결과 필터 info 순서 저장
//임시 변수
private String itemType; // 대출,열람,기타탭
public String getItemType() {
return itemType;
}
public void setItemType(String itemType) {
this.itemType = itemType;
}
public String getFilter_info_mylist() {
return filter_info_mylist;
}
@ -386,6 +396,12 @@ public class SearchVO {
+ filter_mylist + ", filter_info_mylist=" + filter_info_mylist
+ "]";
}
public String getReQueryChk() {
return reQueryChk;
}
public void setReQueryChk(String reQueryChk) {
this.reQueryChk = reQueryChk;
}

View File

@ -29,6 +29,7 @@ import nlib.col.service.DeptVO;
import nlib.col.service.InterestService;
import nlib.col.service.RentService;
import nlib.user.service.NlibLoginVO;
import nlib.util.StringUtil;
/**
* <pre>
@ -160,13 +161,18 @@ public class InterestController extends NlibCommonController
String message = "";
count = interestService.countInterest(vo);
//중복된 관심자료가 있을시
if(count > 0)
if(!StringUtil.getString(masterId,"").equals(""))
{
message="이미 추가된 관심자료입니다.";
//중복된 관심자료가 있을시
if(count > 0)
{
message="이미 추가된 관심자료입니다.";
}else {
interestService.insertInterest(vo);
message="관심자료에 추가되었습니다.";
}
}else {
interestService.insertInterest(vo);
message="관심자료에 추가되었습니다.";
message="관심자료에 추가할 수 없습니다.";
}
return message;
}

View File

@ -119,8 +119,8 @@ public class NlibSearchController extends NlibCommonController {
model.addAttribute("pageSizeCodes", pageSizeCodes);
model.addAttribute("masterType", masterType);
model.addAttribute("dtlsType", dtlsType);
model.addAttribute("firstCategoryInfo", clsf);
model.addAttribute("secondCategoryInfo", clsf);
model.addAttribute("firstCategoryList", clsf);
model.addAttribute("secondCategoryList", clsf);
/*model.addAttribute("orgList",vo);*/
@ -137,6 +137,17 @@ public class NlibSearchController extends NlibCommonController {
sf1Vo.setSearchPort(searchPort);
sf1Vo.setSearchTimeOut(searchTimeOut);
searchVO.setQuery(StringUtil.getString(searchVO.getQuery(), ""));
searchVO.setReQuery(StringUtil.getString(searchVO.getReQuery(), ""));
//결과내재검색만 입력했을경우
if(searchVO.getQuery().length() == 0 && searchVO.getReQuery().length() > 0)
{
searchVO.setQuery(searchVO.getReQuery());
searchVO.setReQuery("");
searchVO.setReQueryChk("query");
}
SearchCollectionResult collResult = searchService.getSearch(searchVO, sf1Vo);
all_totalCount = Integer.toString(searchService.getSearch_All_cnt(searchVO, sf1Vo));
@ -324,14 +335,19 @@ public class NlibSearchController extends NlibCommonController {
e.printStackTrace();
}
String resultUrl ="";
List<String> councilList = new ArrayList<String>();
councilList.add("마포문화원");
councilList.add("서울문화원");
councilList.add("종로문화원");
/*List<DataMap> councilList = resourcesService.selectCouncilList(); */
model.addAttribute("councilList", councilList);
//자료유형
model.addAttribute("firstClassList", codeService.listCodes(Constant.CODE_ID_MASTER_TYPE_DIV_CD));
model.addAttribute("secondClassList", codeService.listCodes(Constant.CODE_ID_DTLS_TYPE_DIV_CD));
List<DataMap> councilList = resourcesService.selectCouncilList();
model.addAttribute("councilList", councilList);
// ams 서버 패스 정보
CmmUtil.setAmsPathModelMap(request,model);

View File

@ -257,7 +257,7 @@ function fn_search_article(pageIndex) {
<a href="javascript:void(0);" onclick="selectCreateDate(); return false;">적용</a>
</div>
</ul>
<ul> <h3>생산기관</h3>
<ul> <h3>생산기관</h3>z
</ul>
</div>
<input type="text" name="articleNo" id="articleNo" value="" title="선택글번호" readonly />

View File

@ -43,14 +43,12 @@
<title>${pageTitle}</title>
<!-- GRID -->
<link type="text/css" rel="stylesheet"
href="${pageContext.request.contextPath}/js/jsgrid/nlib-jsgrid.css" />
<link type="text/css" rel="stylesheet"
href="${pageContext.request.contextPath}/js/jsgrid/nlib-jsgrid-theme.css" />
<script
src="${pageContext.request.contextPath}/js/jquery-ui/jquery-ui.js"></script>
<script
src="${pageContext.request.contextPath}/js/jsgrid/nlib-jsgrid.js"></script>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/js/jsgrid/nlib-jsgrid.css" />
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/js/jsgrid/nlib-jsgrid-theme.css" />
<script src="${pageContext.request.contextPath}/js/jquery-ui/jquery-ui.js"></script>
<script src="${pageContext.request.contextPath}/js/jsgrid/nlib-jsgrid.js"></script>
<script src="${pageContext.request.contextPath}/js/search/util.js"></script>
<script src="${pageContext.request.contextPath}/js/search/reference.js"></script>
<script type="text/javaScript" language="javascript">
@ -70,6 +68,22 @@ window.onload = function() {
//초기 자료 조회
fn_search_article($("#pageIndex").val());
$("#referencelistForm input:checkbox[name='reQueryChk']").on('change', function() {
if ( $(this).prop('checked') )
{
$("#reQuery").css("display","block");
$("#query").css("display","none");
$("#reQueryChk").val("reQuery");
}else{
$("#reQuery").css("display","none");
$("#query").css("display","block");
$("#reQueryChk").val("query");
}
});
$("input:checkbox").on('change', function() {
if ( $(this).prop('checked') )
{
@ -80,15 +94,13 @@ window.onload = function() {
}
});
//필터클릭체크
reference_filterClk();
//필터삭제
reference_filterDel();
}; // window.onload
function fnFilterSch(){
$("input[name=query]").val($("#searchKeyword").val());
document.referencelistForm.action="${pageContext.request.contextPath}/search/searchList.do";
document.referencelistForm.submit();
}
<%//검색필터 서브메뉴 보이기%>
function fn_show_sub(subId,subClass){
if($("#" + subId).css("display") == "none")
@ -99,6 +111,11 @@ function fn_show_sub(subId,subClass){
$("#" + subId).css("display","none");
}
}
//탭 이동
function fn_tabMove_sch(itemType){
$("#itemType").val(itemType);
fnFilterSch();
}
<%//검색필터 메뉴 더보기%>
function fn_show_more(showMoreId){
@ -114,11 +131,6 @@ function fn_show_more(showMoreId){
}
}
//탭 이동
function fn_tabMove_sch(itemType){
$("#itemType").val(itemType);
fn_search_article($("#pageIndex").val());
}
function docView(){
@ -179,7 +191,6 @@ function fn_search_article(pageIndex) {
<input type="hidden" name="collection" value="<c:out value='${searchVO.collection}'/>" />
<input type="hidden" name="sortField" value="<c:out value='${searchVO.sortField}'/>" />
<input type="hidden" name="searchField" value="<c:out value='${searchVO.searchField}'/>" />
<input type="hidden" name="query" value="${searchVO.query}" />
<input type="hidden" name="exactQuery" value='${searchVO.exactQuery}'/>
<input type="hidden" name="andQuery" value='${searchVO.andQuery}' />
<input type="hidden" name="notQuery" value='${searchVO.notQuery}' />
@ -200,8 +211,8 @@ function fn_search_article(pageIndex) {
<input type="hidden" name="content_type" value='${searchVO.content_type}' />
<input type="hidden" name="all_totalCount" value='${all_totalCount}' />
<input type="hidden" name="itemType" value="${searchVO.itemType }" />
<input type="hidden" name="gubun" value='2' />
<input type="hidden" name="filter_class" />
<input type="hidden" name="filter_sido" />
<input type="hidden" name="filter_thema" />
@ -209,6 +220,7 @@ function fn_search_article(pageIndex) {
<input type="hidden" name="filter_info_sido" />
<input type="hidden" name="filter_info_type" />
<input type="hidden" name="filter_mylist" id="filter_mylist" value="${searchVO.filter_mylist}" />
<input type="hidden" name="filter_info_mylist" id="filter_info_mylist" value="${searchVO.filter_info_mylist}" />
@ -226,21 +238,20 @@ function fn_search_article(pageIndex) {
</c:if>
</c:forEach>
</c:forEach>
</select> <input type="hidden" name="pageSize" id="pageSize" title=""
value="${pageSize }" /> <input type="hidden" name="pageIndex"
id="pageIndex" title="페이지번호" value="${pageIndex }" /> <input
type="hidden" name="itemType" id="itemType" title=""
value="${itemType }" /> <input type="text" name="searchKeyword"
id="searchKeyword" title="검색어" value="${searchKeyword }" size="35"
maxlength="50" /> <input type="button" name="btnSearch"
id="btnSearch" onclick="fnFilterSch();" value="검색" />
</select>
<input type="hidden" name="pageSize" id="pageSize" title="" value="${pageSize }" />
<input type="hidden" name="pageIndex" id="pageIndex" title="페이지번호" value="${pageIndex }" />
<input type="text" name="query" id="query" title="검색어" <c:if test="${!(searchVO.reQueryChk eq 'query') }">style="display:none;"</c:if> placeholder="검색어를 입력하세요." value="${searchVO.query}" size="35" maxlength="50" />
<input type="text" name="reQuery" id="reQuery" title="재검색" <c:if test="${!(searchVO.reQueryChk eq 'reQuery') }">style="display:none;"</c:if> placeholder="결과내재검색" value="${searchVO.reQuery}" size="35" maxlength="50" />
<input type="button" name="btnSearch" id="btnSearch" onclick="fnFilterSch();" value="검색" />
<input type="checkbox" id="reQueryChk" name="reQueryChk" value="query" <c:if test="${searchVO.reQueryChk eq 'reQuery' }">checked="checked"</c:if>><label for="reQueryChk">결과내재검색</label>
<div>
<dl>
<dt class="blind">검색결과 안내</dt>
<dd>
<c:choose>
<c:when test="${searchVO.query ne '' && (!empty searchVO.query) }">
<em>'${searchVO.query}'</em>에 대한 검색결과는 총 <strong><fmt:formatNumber
<c:when test="${searchVO.realQuery ne '' && (!empty searchVO.realQuery) }">
<em>'${searchVO.realQuery}'</em>에 대한 검색결과는 총 <strong><fmt:formatNumber
value="${reference.totalCount}" pattern="#,###" /></strong>건 입니다.
</c:when>
<c:otherwise>
@ -252,20 +263,20 @@ function fn_search_article(pageIndex) {
</dl>
</div>
<div>
<input type="button" style="width: 100px;" name="btnSearch"
onclick="fn_tabMove_sch('all');" value="전체()" /> <input
type="button" style="width: 100px;" name="btnSearch"
onclick="fn_tabMove_sch('visit_Coll');" value="방문열람()" /> <input
type="button" style="width: 100px;" name="btnSearch"
onclick="fn_tabMove_sch('rent_Coll');" value="대출()" /> <input
type="button" style="width: 100px;" name="btnSearch"
onclick="fn_tabMove_sch('online_Coll');" value="온라인열람()" /> <input
type="button" style="width: 100px;" name="btnSearch"
onclick="fn_tabMove_sch('etc_Coll);" value="기타()" />
<input type="button" style="width: 100px;" name="btnSearch" onclick="fn_tabMove_sch('all');" value="전체()" />
<input type="button" style="width: 100px;" name="btnSearch" onclick="fn_tabMove_sch('visit_Coll');" value="방문열람()" />
<input type="button" style="width: 100px;" name="btnSearch" onclick="fn_tabMove_sch('rent_Coll');" value="대출()" />
<input type="button" style="width: 100px;" name="btnSearch" onclick="fn_tabMove_sch('online_Coll');" value="온라인열람()" />
<input type="button" style="width: 100px;" name="btnSearch" onclick="fn_tabMove_sch('etc_Coll);" value="기타()" />
</div>
<div style="text-align: left;">
<div id="searchMenu"
style="display: inline-block; width: 200px; margin-top: 5px; vertical-align: top;">
<div id="searchMenu" style="display: inline-block; width: 200px; margin-top: 5px; vertical-align: top;">
<ul>
<h3>검색필터</h3>
<ul id="reference_fillter_append">
</ul>
</ul>
<ul>
<h3>자료유형</h3>
<li>
@ -312,16 +323,17 @@ function fn_search_article(pageIndex) {
<ul>
<h3>주제분야</h3>
<c:set var="count" value="0" />
<c:forEach var="firstCategoryList" items="${firstCategoryInfo}" varStatus="status">
<c:if test="${firstCategoryList.upClsfId eq '2' }">
<c:forEach var="firstCategoryInfo" items="${firstCategoryList}" varStatus="status">
<c:if test="${firstCategoryInfo.upClsfId eq '2' }">
<li
<c:if test ="${count >= 4}"> class="showMoreClsf" style="display:none;" </c:if>>
<div class="depth-1 <c:if test="${fn:contains(searchVO.filter_category, firstCategoryList.cslfId) }"> on</c:if>">
<ul id="${firstCategoryList.clsfId}_clsf_sub" class="clsfSub"
style="display: none;">
<c:forEach var="secondCategoryList" items="${secondCategoryInfo}" varStatus="seStatus">
<c:if test="${firstCategoryList.clsfId eq secondCategoryList.upClsfId }">
<li>${secondCategoryList.clsfNm}</li>
<div class="depth-1 <c:if test="${fn:contains(searchVO.filter_category, firstCategoryInfo.clsfId) }"> on</c:if>">
<div class="check"><input type="checkbox" value="${firstCategoryInfo.clsfId}" id="theme-chk${count+1}" name="first_category" <c:if test="${fn:contains(searchVO.first_category, firstCategoryInfo.clsfId) }">checked="checked"</c:if>/><label for="theme-chk${count+1}">${firstCategoryInfo.clsfNm}(<span>0</span>)</label></div>
</div>
<ul class="depth-2" style="display: none;">
<c:forEach var="secondCategoryInfo" items="${secondCategoryList}" varStatus="seStatus">
<c:if test="${firstCategoryInfo.clsfId eq secondCategoryInfo.upClsfId }">
<li><div class="check"><input type="checkbox" value="${secondCategoryInfo.clsfId}" id="theme-chk${count+1}-${seStatus.index+1}" name="second_category" <c:if test="${fn:contains(searchVO.second_category, secondCategoryInfo.clsfId) }">checked="checked"</c:if>/><label for="theme-chk${count+1}-${seStatus.index+1}">${secondCategoryInfo.clsfNm}(<span>0</span>)</label></div></li>
</c:if>
</c:forEach>
</ul>
@ -336,22 +348,24 @@ function fn_search_article(pageIndex) {
<h3>생산년도</h3>
<div>
<input type="radio" name="createDate" value="allDate">전체<br>
<input type="radio" name="createDate" value="date"><input
type="text" placeholder="예)2017">~<input type="text"
placeholder="예)2018"><br> (<input type="checkbox">미상포함)
<a href="javascript:void(0);"
onclick="selectCreateDate(); return false;">적용</a>
<input type="radio" name="createDate" value="date">
<input type="text" placeholder="예)2017">~<input type="text" placeholder="예)2018"><br>
(<input type="checkbox">미상포함)
<a href="javascript:void(0);" onclick="selectCreateDate(); return false;">적용</a>
</div>
</ul>
<ul>
<h3>생산기관</h3>
<c:forEach var="councilList" items="${councilList}" varStatus="status">
${councilList} <br>
</c:forEach>
</ul>
</div>
<div style="display: inline-block;">
<table id="itemList">
<tr>
<th style='width:800px;'>자료정보</th>"
<th style='width:200px;'>이용</th>"
<th style='width:800px;'>자료정보</th>
<th style='width:200px;'>이용</th>
</tr>
<c:forEach var="result" items="${reference.searchResultList}">
<tr>
@ -360,6 +374,24 @@ function fn_search_article(pageIndex) {
<img src="${result.MAIN_IMG}" style="width:150px;height:200px;" alt="${result.TITLE}" />
<c:if test="${!empty result.COPYRIGHT and result.COPYRIGHT ne ''}"><p class="source-origin">출처:${result.COPYRIGHT}</p></c:if>
</c:if>
<input type="button" value="관심" onclick="insertInterest('${result.MASTER_ID}');">
<c:forEach var="operList" items="${operList}">
<c:if test="${result.MASTER_ID eq operList.masterId}">
<c:if test="${(!empty operList.openDivCd) && (operList.openDivCd ne '3') }">
온라인열람&nbsp;
</c:if>
<c:if test="${(!empty operList.operOutRangeCd) && (operList.operOutRangeCd ne '02')}">
대출&nbsp;
</c:if>
<c:if test="${(!empty operList.operReadRangeCd) && (operList.operReadRangeCd ne '03')}">
방문열람&nbsp;
</c:if>
<c:if test="${(!empty operList.openDivCd) && (operList.openDivCd ne '3') && (!empty operList.operOutRangeCd) && (operList.operOutRangeCd ne '02') && (!empty operList.operReadRangeCd) && (operList.operReadRangeCd ne '03') }">
기타
</c:if>
</c:if>
</c:forEach>
<br>
<span class="tit-txt">[${result.FIRST_CLASS_NM}]<c:out value="${result.TITLE}"/></span><br>
<c:if test="${!empty result.FIRST_CLASS_NM}"><em><%--자료유형 : --%>자료유형 : </em>${result.FIRST_CLASS_NM} <c:if test="${!empty result.SECOND_CLASS_NM}">&gt; ${result.SECOND_CLASS_NM}</c:if></c:if>
<c:if test="${!empty result.FIRST_CATEGORY_NM}"><em><%--주제분야 : --%>주제분야 : </em>${result.FIRST_CATEGORY_NM} <c:if test="${!empty result.SECOND_CATEGORY_NM}">&gt; ${result.SECOND_CATEGORY_NM}</c:if></c:if>
@ -458,7 +490,7 @@ function fn_search_article(pageIndex) {
</c:forEach>
//fnLabel_reference();
fnLabel_reference();
//filterFn();

View File

@ -271,9 +271,9 @@
</div>
<ul class="depth-2">
<c:forEach items="${schSecondCategoryList}" var="secondCategoryInfo" varStatus="seStatus">
<c:if test="${firstCategoryInfo.sCodeId eq fn:substring(secondCategoryInfo.sCodeId,0,1)}" >
<li><div class="check"><input type="checkbox" value="${secondCategoryInfo.sCodeId}" id="theme-chk${fiStatus.index+1}-${seStatus.index+1}" name="second_category" <c:if test="${fn:contains(searchVO.second_category, secondCategoryInfo.sCodeId) }">checked="checked"</c:if>/><label for="theme-chk${fiStatus.index+1}-${seStatus.index+1}">${secondCategoryInfo.sCodeNm}(<span>0</span>)</label></div></li>
</c:if>
<c:if test="${firstCategoryInfo.sCodeId eq fn:substring(secondCategoryInfo.sCodeId,0,1)}" >
<li><div class="check"><input type="checkbox" value="${secondCategoryInfo.sCodeId}" id="theme-chk${fiStatus.index+1}-${seStatus.index+1}" name="second_category" <c:if test="${fn:contains(searchVO.second_category, secondCategoryInfo.sCodeId) }">checked="checked"</c:if>/><label for="theme-chk${fiStatus.index+1}-${seStatus.index+1}">${secondCategoryInfo.sCodeNm}(<span>0</span>)</label></div></li>
</c:if>
</c:forEach>
</ul>
</li>

View File

@ -0,0 +1,235 @@
//filter clk evt
function reference_filterClk(){
$(document).on("click","#referencelistForm [name=second_class],#referencelistForm [name=second_category]",function(){
//first chk
if( $(this).parents('.depth-2').find('input:checkbox[name="' + event.target.name + '"]:checked').length >= 1){
$(this).parents('.depth-2').siblings('.depth-1').find('input').prop("checked", true);
}else{
$(this).parents('.depth-2').siblings('.depth-1').find('input').prop("checked", false);
}
//filter_mylist clk array
var filter_mylist = "";
var filter_mylist_clk = "";
filter_mylist = $('#filter_mylist').val();
if($(this).attr('name') == 'second_class'){
filter_mylist_clk = 'class_'+$(this).val() +',';
}else if($(this).attr('name') == 'second_category'){
filter_mylist_clk = 'category_'+$(this).val() +',';
}
if($(this).is(":checked")){
filter_mylist += filter_mylist_clk;
}else{
filter_mylist = filter_mylist.replace(filter_mylist_clk,'');
}
$('#filter_mylist').val(filter_mylist);
/* //depth-1
var on_classArr = document.querySelectorAll("div.depth-1.on");
var filter_class = "" ;
var filter_category = "" ;
for(var i=0; i<on_classArr.length; i++){
if($(on_classArr[i]).find('input').attr('name') == 'first_class') {
filter_class = $(on_classArr[i]).find('input').val();
}else{
filter_category = $(on_classArr[i]).find('input').val();
}
}
var listForm = document.forms["listForm"];
listForm.startCount.value = 1;
listForm.filter_class.value = filter_class;
listForm.filter_sido.value = filter_sido;
listForm.filter_category.value = filter_category; */
fnFilterSch();
});
}
//reference 결과 필터 del 클릭
function reference_filterDel(){
$(document).on("click","#referencelistForm button[id^='c_cate_data-type-chk'],#referencelistForm button[id^='j_cate_theme-chk'],#referencelistForm button[id^='s_cate_local-chk']",function(){
var s_cate_id = $(this).attr("id");
s_cate_id = s_cate_id.substring(s_cate_id.lastIndexOf("_")+1);
var reference_gubun_name = "";
if( $(this).attr('id').indexOf("theme-chk") != -1){
reference_gubun_name = "second_category";
}else if( $(this).attr('id').indexOf("data-type-chk")!= -1){
reference_gubun_name = "second_class";
}else if( $(this).attr('id').indexOf("local-chk") != -1){
reference_gubun_name = "sojang_council";
}
//first
var first_nm = $(this).attr('id').replace('c_cate_', '').replace('j_cate_', '').replace('s_cate_', '');
first_nm = first_nm.substring(0,first_nm.indexOf("_",-2)); //data-type-chk1-4
first_nm = first_nm.substring(0,first_nm.lastIndexOf("-")) ; //data-type-chk1
if($("#referencelistForm input:checkbox[id^='"+ first_nm +"-']:checked").length ==1){
$("input:checkbox[id='" + first_nm + "']").prop("checked", false);
}
//second
$("#referencelistForm input[name='"+ reference_gubun_name+ "']:input[value='"+s_cate_id+"']").each(function () {
$(this).prop("checked",false);
});
//filter_mylist clk array remove
var filter_mylist = "";
var filter_mylist_clk = "";
filter_mylist = $('#filter_mylist').val();
if($(this).attr('id').indexOf('c_cate_data-type') >= 0 ){
filter_mylist_clk = 'class_'+ s_cate_id +',';
}else if($(this).attr('id').indexOf('s_cate_local')>= 0 ){
filter_mylist_clk = 'council_'+ s_cate_id +',';
}else if($(this).attr('id').indexOf('j_cate_theme')>= 0 ){
filter_mylist_clk = 'category_'+ s_cate_id +',';
}
filter_mylist = filter_mylist.replace(filter_mylist_clk,'');
$('#filter_mylist').val(filter_mylist);
//depth-1
var on_classArr = document.querySelectorAll("div.depth-1.on");
var filter_class = "" ;
var filter_sido = "" ;
var filter_thema = "" ;
var filter_category = "" ;
for(var i=0; i<on_classArr.length; i++){
if($(on_classArr[i]).find('input').attr('name') == 'first_class') {
filter_class = $(on_classArr[i]).find('input').val();
}else if($(on_classArr[i]).find('input').attr('name') == 'sido_name') {
filter_sido = $(on_classArr[i]).find('input').val();
}else{
filter_category = $(on_classArr[i]).find('input').val();
}
}
/* var listForm = document.forms["listForm"];
listForm.startCount.value = 1;
listForm.filter_class.value = filter_class;
listForm.filter_sido.value = filter_sido;
listForm.filter_category.value = filter_category;
fnSearch_ajax('#referencelistForm'); */
fnFilterSch();
});
}
function fnLabel_reference(){
var mylist_arr = $("#referencelistForm [name=filter_mylist]").val().split(",");
var comparisonData;
for(var j=0; j < mylist_arr.length ; j++){
if(mylist_arr[j].indexOf("class") >= 0){
var checked = document.querySelectorAll("#referencelistForm [name='second_class']:checked");
for(var i=0; i<checked.length; i++){
var checkVal = util.xssCheck($(checked[i]).val());
if(mylist_arr[j].indexOf(checkVal) >= 0 ){
var second_cate_id = "c_cate_"+ $(checked[i]).attr('id') +"_id_" +checkVal ;
var first_cate_nm =$(checked[i]).parents('.depth-2').siblings('.depth-1').find('input').next().text();
var second_cate_nm = $(checked[i]).next().text();
first_cate_nm = first_cate_nm.substring(0,first_cate_nm.indexOf("(",-1));
second_cate_nm = second_cate_nm.substring(0,second_cate_nm.lastIndexOf("("));
if(comparisonData != second_cate_id){
first_cate_nm = util.xssCheck(first_cate_nm);
second_cate_nm = util.xssCheck(second_cate_nm);
second_cate_id = util.xssCheck(second_cate_id);
$("#reference_fillter_append").append("<li><em>"+ first_cate_nm+ "</em><span class=\"sign\">&gt;</span>"+ second_cate_nm + "<button type=\"button\" class=\"btn-del-filter\" id=\""+second_cate_id+"\">삭제</button></li>").text();
comparisonData = second_cate_id;
}
}
}
}
else if(mylist_arr[j].indexOf("category") >= 0){
var checked = document.querySelectorAll("#referencelistForm [name='second_category']:checked");
var comparisonData;
//필터라벨
for(var i=0; i<checked.length; i++){
var checkVal = util.xssCheck($(checked[i]).val());
if(mylist_arr[j].indexOf(checkVal) >= 0 ){
var second_cate_id = "j_cate_"+ $(checked[i]).attr('id') +"_id_" +checkVal ;
var first_cate_nm =$(checked[i]).parents('.depth-2').siblings('.depth-1').find('input').next().text();
var second_cate_nm = $(checked[i]).next().text();
first_cate_nm = first_cate_nm.substring(0,first_cate_nm.indexOf("(",-1));
second_cate_nm = second_cate_nm.substring(0,second_cate_nm.indexOf("(",-1));
if(comparisonData != second_cate_id){
first_cate_nm = util.xssCheck(first_cate_nm);
second_cate_nm = util.xssCheck(second_cate_nm);
second_cate_id = util.xssCheck(second_cate_id);
$("#reference_fillter_append").append("<li><em>"+ first_cate_nm+ "</em><span class=\"sign\">&gt;</span>"+ second_cate_nm + "<button type=\"button\" class=\"btn-del-filter\" id=\""+second_cate_id+"\">삭제</button></li>").text();
comparisonData = second_cate_id;
}
}
}
}
} //for end
}
function fnLabel_reference_detail(){
$('#referencelistForm input[name=sojang_council]').prop("checked",false);
$('#referencelistForm input[name=sido_name]').prop("checked",false);
$("#referencelistForm .cmm-list-chk").each(function (index, item) {
$(this).prop("checked",true);
});
$("#reference_council_append").empty();
var mylist_arr = $("#referencelistForm [name=filter_mylist]").val().split(",");
for(var j=0; j < mylist_arr.length ; j++){
if(mylist_arr[j].indexOf("council") >= 0){
var checked = document.querySelectorAll("#referencelistForm [name='sojang_council']:checked");
for(var i=0; i<checked.length; i++){
var checkVal = util.xssCheck($(checked[i]).val());
if(mylist_arr[j].indexOf(checkVal) >= 0 ){
var second_cate_id = $(checked[i]).attr('id')+"_id";
var second_cate_id_del = $(checked[i]).attr('id')+"_id_del";
var first_cate_nm =$(checked[i]).parents('.depth-2').siblings('.depth-1').find('input').next().text();
var second_cate_nm = $(checked[i]).next().text();
first_cate_nm = first_cate_nm.substring(0,first_cate_nm.indexOf("(",-1));
second_cate_nm = second_cate_nm.substring(0,second_cate_nm.indexOf("(",-1));
second_cate_id = util.xssCheck(second_cate_id);
second_cate_id_del = util.xssCheck(second_cate_id_del);
first_cate_nm = util.xssCheck(first_cate_nm);
second_cate_nm = util.xssCheck(second_cate_nm);
$("#reference_council_append").append("<li id=\""+second_cate_id+"\"><button type=\"button\" title=\"삭제\" id=\""+second_cate_id_del+"\"><span class=\"sign\">"+ first_cate_nm+" &gt; </span>"+ second_cate_nm+"</button></li>");
}
}
}//if end
}//for end
var checked2 = document.querySelectorAll("#referencelistForm [name='sido_name']:checked");
for(var i=0; i<checked2.length; i++){
$(checked2[i]).prop("checked", true);
}
}
function fnFilterSch(){
document.referencelistForm.action="/search/searchList.do";
document.referencelistForm.submit();
}

View File

@ -0,0 +1,286 @@
// 스크립트 전용 mobile 체크 전역 변수 - 단순 window width size로 체크
window.isUserMobile = window.innerWidth <= 768;
util = (function( w, $ ) {
'use strict';
var config = {
pop : null,
addr_c_name : 'KCCF_C_ADDR',
location_id : 'location_set',
location_to_id : 'location_set_to',
b_cnt_id : 'strong_b_cnt',
o_cnt_id : 'strong_o_cnt',
em_b_cnt_id : 'em_b_cnt',
em_o_cnt_id : 'em_o_cnt',
cms_host : 'https://cms.nculture.org',
newcms_host : 'https://ncms.nculture.org',
url: {
activityHstAllCnt:'/cmm/cmmActivityHstAllListTotCnt.do',
recentlyView:'/cmm/regCmmRecentlyView.do'
}
};
function numberWithCommas(x) {
x = x+'';
return x.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
function replaceAll(val, s1, s2){
var str = val.replace( /(\s*)/g, "" );
return str.split(s1).join(s2);
}
function setEnterkeyEnabled( e, callback ) {
if ( e && e.which === 13 ) {
callback();
e.preventDefault();
}
}
function getBytes( s, b, i, c ) {
for ( b = i = 0; c = s.charCodeAt( i++ ); b += c >> 11 ? 3 : c >> 7 ? 2 : 1 );
return b;
}
function getPath( url ) {
if ( url === null || url === '' ) {
return '';
}
return url.replace( w.location.protocol + '//' + w.location.host, '' );
}
function downloadFile(form, atchFileId, fileSn) {
var varForm = document.forms[form];
varForm.action = '/cmm/downloadFile.do?atchFileId='+ atchFileId +'&fileSn='+ fileSn;
varForm.submit();
}
function updateFile(obj) {
$(obj).parent().parent().find("input").eq(0).val('U');
}
function clearFile(obj) {
var fileObj = $(obj).parent().find("input").eq(2);
fileObj.parent().html(fileObj.parent().html());
}
function deleteFile(obj) {
$(obj).parent().parent().find('div').eq(1).hide();
$(obj).parent().parent().find('div').eq(0).show();
$(obj).parent().parent().find('div').eq(0).html($(obj).parent().parent().find('div').eq(0).html());
$(obj).parent().parent().find('input').eq(0).val('D');
}
function undeleteFile(obj) {
$(obj).parent().parent().find('div').eq(1).show();
$(obj).parent().parent().find('div').eq(0).hide();
$(obj).parent().parent().find('input').eq(0).val('R');
}
function cmmActivityReload(){
w.setTimeout(function() {
getCmmActivityHstAllListTotCnt();
}, 5500);
}
function getCmmActivityHstAllListTotCnt(){
$.ajax({
type : 'GET',
url : config.url.activityHstAllCnt,
data: {},
dataType: 'json',
cache: false,
error : function(error) {
$('#'+config.b_cnt_id).html('0');
$('#'+config.o_cnt_id).html('0');
$('#'+config.em_b_cnt_id).html('0');
$('#'+config.em_o_cnt_id).html('0');
},
success : function(response) {
$('#'+config.b_cnt_id).html('0');
$('#'+config.o_cnt_id).html('0');
if(response.successYn != 'N'){
if(response.resultList.length > 0){
$('#'+config.b_cnt_id).html(response.resultList[0].cnt);
$('#'+config.o_cnt_id).html(response.resultList[1].cnt);
}
}
$('#'+config.em_b_cnt_id).html($('#'+config.b_cnt_id).html());
$('#'+config.em_o_cnt_id).html($('#'+config.o_cnt_id).html());
},
complete : function() {
}
});
}
function fnRecentlyViewContent(id, type, url) {
if ($.active > 0) {
return false;
}
if(type != 'C'){
return false;
}
$.ajax({
method: 'POST',
url: config.url.recentlyView,
data: {cId:id , cType:type , lUrl:url},
dataType: 'json'
})
.done(function( json ) {
getCmmActivityHstAllListTotCnt();
});
}
function isNull(data){
var rtnData;
if(data == null){
rtnData = "";
} else{
rtnData = data;
}
return rtnData;
}
function snsShare(snsType, url) {
var url,name,specs,changedUrl,title;
if(w.document.title.indexOf("|") > -1){
title = encodeURIComponent($.trim(w.document.title.split("|")[1]));
}else{
if(isNull(url) != '' && url.indexOf('/lib/') > -1){ // 넘겨받은 url
title = encodeURIComponent($.trim('지역문화Pick')); // 지역문화Pick 레이어에서 공유시
}else{
title = encodeURIComponent($.trim(w.document.title));
}
}
if(isNull(url) != ''){
if(url.indexOf(location.host) == -1 && url.indexOf(config.cms_host) == -1 && url.indexOf(config.newcms_host) == -1){
url = location.protocol + '//' + location.host + url;
}
changedUrl = encodeURIComponent(url);
}else{
if($('input[name="contentId"]').length > 0){
changedUrl = encodeURIComponent(w.document.URL.split("?")[0]+'?contentId='+$('input[name="contentId"]').eq(0).val());
}else{
changedUrl = encodeURIComponent(w.document.URL.split("?")[0]+'?targetId='+$('input[name="targetId"]').eq(0).val());
}
if(w.document.URL.indexOf('/cul/') > -1){
if($('input[name="contentType"]').length > 0){
changedUrl += encodeURIComponent('&contentType='+$('input[name="contentType"]').eq(0).val());
}
}
}
if(snsType == '1'){
url = 'https://www.facebook.com/sharer/sharer.php?u=' +changedUrl+'&amp;t='+title;
name = 'facebooksharedialog';
specs = "menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600";
}else if(snsType == '2'){
url = 'https://twitter.com/intent/tweet?text=[%EA%B3%B5%EC%9C%A0]%20' + title+'&url='+changedUrl;
name = 'twittersharedialog';
specs = "menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=300,width=600";
}else if(snsType == '3'){
url = 'http://blog.naver.com/openapi/share?url=' +changedUrl+'&amp;title='+title;
name = 'naversharedialog';
specs = "menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=600,width=600";
}else if(snsType == '4'){
url = 'https://story.kakao.com/s/share?url='+changedUrl;
name = 'kakaostorysharedialog';
specs = "menubar=no,toolbar=no,resizable=yes,scrollbars=yes,height=400,width=600";
}
if(config.pop != null){
config.pop.close();
}
config.pop = w.open(url, name, specs);
}
function setLocation(){
if($.cookie(config.addr_c_name).indexOf('세종') != -1){
$('#'+config.location_id).html($.cookie(config.addr_c_name).split('|')[0]);
}else{
$('#'+config.location_id).html($.cookie(config.addr_c_name).split('|').join(' '));
}
if($('#'+config.location_to_id).length>0){
$('#'+config.location_to_id).html($('#'+config.location_id).html());
}
}
function nl2br(str){
var breakTag = '<br/>';
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag +'$2');
}
function isWindowSmall() {
return $(window).width() <= 768;
}
function risDownloadFile(aId, mId, formName) {
if (typeof(formName) == 'undefined') formName = 'risDownloadForm' // [include_cmm_popup.jsp] 파일에 선언
var varForm = document.forms[formName];
if (typeof(varForm.aId) != 'undefined') {
varForm.action = '/cmm/risDownloadFile.do';
varForm.aId.value = aId;
varForm.mId.value = mId;
} else {
varForm.action = '/cmm/risDownloadFile.do?aId='+aId+'&mId'+mId;
}
if ( $.cookie('KCCF_E_POP') == 'Y' ){
varForm.submit();
}else{
$('#export-data').show();
}
}
function assetImgUrl(filePath, amsAssetsPath, amsThumbnailPath) {
var linkUrl = amsAssetsPath + amsThumbnailPath;
var stringVal = util.isNull(filePath);
if(stringVal != ''){
if (stringVal.indexOf('http') >= 0) {
linkUrl = '';
} else if(stringVal.indexOf("/") !== -1){
linkUrl = amsAssetsPath;
}
}
var imgUrl = linkUrl + filePath;
return imgUrl;
}
function uploadImgUrl(filePath, uploadHomePath) {
var stringVal = util.isNull(filePath);
var imgUrl = stringVal;
if(stringVal != ''){
if (stringVal.indexOf('/upload') == 0) {
imgUrl = uploadHomePath + stringVal;
}
}
return imgUrl;
}
function docView(mId, sd) {
var url = '/npdfView.do?npdf='+mId;
if (typeof(sd) != 'undefined') url += '&sd='+sd;
var newWindow = window.open('about:blank');
newWindow.location.href=url;
}
function xssCheck(str) {
var rtnData;
if(str == null){
rtnData = "";
} else{
str = str.replace(/\&/g, "&amp;");
str = str.replace(/\//g, "&#x2F;");
str = str.replace(/</g, "&lt;").replace(/>/g, "&gt;");
str = str.replace(/'/g, "&#039;").replace(/"/g, "&quot;");
str = str.replace(/\(/g, "&#040;").replace(/\)/g, "&#041;");
rtnData = str;
}
return rtnData;
}
return {
config:config,
numberWithCommas:numberWithCommas,
replaceAll: replaceAll,
getBytes: getBytes,
setEnterkeyEnabled: setEnterkeyEnabled,
getPath: getPath,
downloadFile:downloadFile,
updateFile:updateFile,
clearFile:clearFile,
deleteFile:deleteFile,
undeleteFile:undeleteFile,
cmmActivityReload:cmmActivityReload,
getCmmActivityHstAllListTotCnt:getCmmActivityHstAllListTotCnt,
fnRecentlyViewContent:fnRecentlyViewContent,
isNull:isNull,
snsShare:snsShare,
setLocation:setLocation,
nl2br:nl2br,
isWindowSmall:isWindowSmall,
risDownloadFile:risDownloadFile,
assetImgUrl:assetImgUrl,
uploadImgUrl:uploadImgUrl,
docView:docView,
xssCheck:xssCheck
};
})( window, jQuery );