PageSourceSearch

https://mfds.go.kr/js/search/searchEn.js

js mfds.go.kr collected 2026-09-24 08:29:14 UTC 17,949 bytes, 727 lines download raw bytes

1// 인기검색어, 내가찾은 검색어
2function doKeyword(query) {
3	
4 
5	var searchForm = document.search; 
6	searchForm.startCount.value = "0";
7	searchForm.query.value = query;
8	searchForm.collection.value = "ALL";
9	searchForm.sort.value = "RANK";
10 
11	doSearch();
12}
13
14// 쿠키값 조회
15function getCookie(c_name) {
16	var i,x,y,cookies=document.cookie.split(";");
17	for (i=0;i<cookies.length;i++) {
18		x=cookies[i].substr(0,cookies[i].indexOf("="));
19		y=cookies[i].substr(cookies[i].indexOf("=")+1);
20		x=x.replace(/^\s+|\s+$/g,"");
21	
22		if (x==c_name) {
23			return unescape(y);
24		}
25	}
26}
27
28// 쿠키값 설정
29function setCookie_wise(c_name,value,exdays) {
30	 
31	var exdate=new Date();
32	 
33	exdate.setDate(exdate.getDate() + exdays);
34	var c_value=escape(value) + ((exdays==null) ? "" : "; path=/; expires="+exdate.toUTCString());
35	document.cookie=c_name + "=" + c_value;
36}
37
38// 내가 찾은 검색어 조회
39function getMyKeyword(keyword, totCount) {
40	
41 
42	var MYKEYWORD_COUNT = 6; //내가 찾은 검색어 갯수 + 1
43	
44	var myKeyword = getCookie("mykeyword");
45 
46	if( myKeyword== null) {
47		myKeyword = ""
48	 
49	} 
50 
51	var myKeywords = myKeyword.split("^%");
52 
53 
54	if( totCount > 0 ) {
55		 
56		var existsKeyword = false;
57		for( var i = 0; i < myKeywords.length; i++) {
58			if( myKeywords[i] == keyword) {
59				existsKeyword = true;
60				break;
61			} 
62		}
63
64		if( !existsKeyword ) {
65			myKeywords.push(keyword);
66			if( myKeywords.length == MYKEYWORD_COUNT) {
67				myKeywords = myKeywords.slice(1,MYKEYWORD_COUNT);
68			}
69		}
70		 
71		setCookie_wise("mykeyword", myKeywords.join("^%"), 365);
72		 
73	}
74
75	showMyKeyword(myKeywords.reverse());
76}
77
78//내가 찾은 검색어 조회 //메인에서
79function getMyKeyword2() {
80	
81 
82	var MYKEYWORD_COUNT = 6; //내가 찾은 검색어 갯수 + 1
83	
84	var myKeyword = getCookie("mykeyword");
85 
86	if( myKeyword== null) {
87		myKeyword = ""
88	 
89	} 
90 
91	var myKeywords = myKeyword.split("^%");
92
93	//alert("myKeywords : "+myKeywords);
94	showMyKeyword(myKeywords.reverse());
95}
96
97// 내가 찾은 검색어 삭제
98function removeMyKeyword(keyword) {
99	 
100	var myKeyword = getCookie("mykeyword");
101	if( myKeyword == null) {
102		myKeyword = "";
103	}
104
105	var myKeywords = myKeyword.split("^%");
106
107	var i = 0;
108	while (i < myKeywords.length) {
109		if (myKeywords[i] == keyword) {
110			myKeywords.splice(i, 1);
111		} else { 
112			i++; 
113		}
114	}
115
116	setCookie_wise("mykeyword", myKeywords.join("^%"), 365);
117
118	showMyKeyword(myKeywords);
119}
120 
121//2018-06-18 최근검색어 검색기록 삭제
122function removeAllMyKeyword() {
123 
124 
125	setCookie_wise("mykeyword", "", 365);
126	
127	var myKeyword = getCookie("mykeyword");
128	showMyKeyword(myKeyword);
129}
130
131// 내가 찾은 검색어 
132function showMyKeyword(myKeywords) {
133/*	var str = "<li class=\"tit\"><img src=\"images/tit_mykeyword.gif\" alt=\"내가 찾은 검색어\" /></li>";
134
135	for( var i = 0; i < myKeywords.length; i++) {
136		if( myKeywords[i] == "") continue;
137		alert(myKeywords[i]);
138		str += "<li class=\"searchkey\"><a href=\"#none\" onClick=\"javascript:doKeyword('"+myKeywords[i]+"');\">"+myKeywords[i]+"</a> <img src=\"images/ico_del.gif\" onClick=\"removeMyKeyword('"+myKeywords[i]+"');\"/></li>";
139	}*/
140
141	var str = "<ul class=\"search_ls_word\">";
142
143	for( var i = 0; i < myKeywords.length; i++) {
144		if( myKeywords[i] == "") continue;
145		 
146		str += "<li><a href=\"#none\" onClick=\"javascript:doKeyword('"+myKeywords[i]+"');\">"+myKeywords[i]+"</a> <img src=\"/mfds/images/search/ico_del.gif\" onClick=\"removeMyKeyword('"+myKeywords[i]+"');\" alt=\""+i+" 검색어 삭제\" title=\"삭제\"/></li>";
147	}
148	
149	str += "</ul>";
150 
151	$("#mykeyword").html(str);
152}
153
154
155
156//2018-06-18 내가찾은 검색어 on/off
157function mykeywordUse() {
158 
159
160	if(getCookie("mykeywordUse")=="on"||getCookie("mykeywordUse")==null){
161		setCookie_wise("mykeywordUse", "off", 365);
162		$("#search_ls_alert").show();
163		$("#mykeyword").hide();
164	}else if(getCookie("mykeywordUse")=="off"){
165		setCookie_wise("mykeywordUse", "on", 365);
166		$("#mykeyword").show();
167		$("#search_ls_alert").hide();
168	}
169 
170}
171// 오타 조회
172function getSpell(query) { 
173	$.ajax({
174	  type: "POST",
175	  url: "./popword/popword.jsp?target=spell&charset=",
176	  dataType: "xml",
177	  data: {"query" : query},
178	  success: function(xml) {
179		if(parseInt($(xml).find("Return").text()) > 0) {
180			var str = "<div class=\"resultall\">";
181
182			$(xml).find("Data").each(function(){			
183				if ($(xml).find("Word").text() != "0" && $(xml).find("Word").text() != query) {
184					str += "<span>이것을 찾으셨나요? </span><a href=\"#none\" onClick=\"javascript:doKeyword('"+$(xml).find("Word").text()+"');\">" + $(xml).find("Word").text() + "</a>";
185				}			
186			});
187			
188			str += "</div>";
189
190			$("#spell").html(str);
191		}
192	  }
193	});
194
195	return true;
196}
197
198// 기간 설정
199function setDate(range) {
200	var startDate = "";
201	var endDate = "";
202	
203	var currentDate = new Date();
204	var year = currentDate.getFullYear();
205	var month = currentDate.getMonth() +1;
206	var day = currentDate.getDate();
207
208	if (parseInt(month) < 10) {
209		month = "0" + month;
210	}
211
212	if (parseInt(day) < 10) {
213		day = "0" + day;
214	}
215
216	var toDate = year + "." + month + "." + day;
217
218	// 기간 버튼 이미지 초기화
219	for (i = 1;i < 5 ;i++) {
220		$("#range"+i).attr ("src", "images/btn_term" + i + ".gif");
221	}
222	
223	// 기간 버튼 이미지 선택
224	if (range == "D") {
225		startDate = getAddDay(currentDate, -0);
226		$("#range2").attr ("src", "images/btn_term22.gif");
227	} else if (range == "W") {
228		startDate = getAddDay(currentDate, -6);
229		$("#range3").attr ("src", "images/btn_term32.gif");
230	} else if (range == "M") {
231		startDate = getAddDay(currentDate, -29);
232		$("#range4").attr ("src", "images/btn_term42.gif");
233	} else {
234		startDate = "1970.01.01";
235		endDate = toDate;
236		$("#range1").attr ("src", "images/btn_term12.gif");
237	}
238	
239	if (range != "A" && startDate != "") { 
240		year = startDate.getFullYear();
241		month = startDate.getMonth()+1; 
242		day = startDate.getDate();
243
244		if (parseInt(month) < 10) {
245			month = "0" + month;
246		}
247
248		if (parseInt(day) < 10) {
249			day = "0" + day;
250		}
251
252		startDate = year + "." + month + "." + day;				
253		endDate = toDate;
254	}
255	
256	$("#range").val(range);
257	$("#startDate").val(startDate);
258	$("#endDate").val(endDate);
259}
260
261// 날짜 계산
262function getAddDay ( targetDate, dayPrefix )
263{
264	var newDate = new Date( );
265	var processTime = targetDate.getTime ( ) + ( parseInt ( dayPrefix ) * 24 * 60 * 60 * 1000 );
266	newDate.setTime ( processTime );
267	return newDate;
268}
269
270// 정렬
271function doSorting(sort) {
272	var searchForm = document.search;
273	searchForm.sort.value = sort;
274	//searchForm.reQuery.value = "2";
275	searchForm.submit();
276}
277
278// 검색
279function doSearch() { 
280	var searchForm = document.search; 
281
282 
283	
284 
285	
286	if (searchForm.query.value == "") {
287		alert("검색어를 입력하세요.");
288		searchForm.query.focus();
289		return false;
290	} 
291	
292 
293	//searchForm.collection.value = "ALL";
294	//searchForm.startDate.value = "";
295	//searchForm.endDate.value = "";
296	searchForm.range.value = "A";
297	searchForm.startCount.value = 0;
298	searchForm.searchField.value = "ALL";
299	searchForm.sort.value = "RANK";
300	//searchForm.detailCheck.value = 0; 
301	
302	//고급검색 체크해제
303	//searchForm.detailCheck.value = 0;
304	
305	searchForm.submit();
306}
307
308//검색조건 저장버튼 클릭시 고급검색옵션 창 닫음
309function doExsave(e){ 
310	
311	var searchForm = document.searchHeader; 
312	
313	searchForm.detailCheck.value = 1; 
314	
315	e.preventDefault(); 
316	$('.all_search_extend').attr('aria-expanded','false');
317 
318	var $tobj = $('.all_search_extend').closest('form').find('.all_search_extend');
319	$tobj.addClass('close_extend');
320 
321	$tobj.one('webkitAnimationEnd oanimationend msAnimationEnd animationend',
322	function(e) {
323		$('.all_search_extend').removeClass('active close_extend');
324	});
325	
326	
327  
328}
329
330//헤더 검색
331function doSearch2() { 
332	var searchForm = document.searchHeader; 
333
334 
335	
336	if (searchForm.headerQuery.value == "") {
337		alert("Please enter your search term.");
338		searchForm.headerQuery.focus();
339		return false;
340	} 
341	
342	//고급검색 체그해제 
343 
344	//searchForm.collection.value = "ALL";
345/*	searchForm.startDate.value = "";
346	searchForm.endDate.value = "";
347	searchForm.range.value = "A";
348	searchForm.startCount.value = 0;
349	searchForm.searchField.value = "ALL";
350	searchForm.sort.value = "RANK";*/
351	
352	searchForm.submit();
353}
354
355function doEnter(){
356	
357	
358	if(event.keyCode == 13){
359		doSearch2();
360	}
361}
362
363
364// 컬렉션별 검색
365function doCollection(coll) {
366 
367	var searchForm = document.search; 
368	searchForm.collection.value = coll;
369	
370	//alert(coll);
371	//searchForm.reQuery.value = "2";
372	searchForm.submit();
373}
374	
375// 엔터 체크	
376function pressCheck() {   
377	if (event.keyCode == 13) {
378		return doSearch();
379	}else{
380		return false;
381	}
382}
383
384var temp_query = "";
385
386// 결과내 재검색
387function checkReSearch() {
388	var searchForm = document.search;
389	var query = searchForm.query;
390	var reQuery = searchForm.reQuery;
391
392	if (document.getElementById("reChk").checked == true) {
393		temp_query = query.value;
394		reQuery.value = "1";
395		query.value = "";
396		query.focus();
397	} else {
398		query.value = trim(temp_query);
399		reQuery.value = "";
400		temp_query = "";
401	}
402}
403
404// 페이징
405function doPaging(count) {
406	var searchForm = document.search;
407	searchForm.startCount.value = count;
408	searchForm.reQuery.value = "2";
409	searchForm.submit();
410}
411
412// 기간 적용
413function doRange() {
414	var searchForm = document.search;
415	
416	if($("#startDate").val() != "" || $("#endDate").val() != "") {
417		if($("#startDate").val() == "") {
418			alert("Please enter a start date.");
419			$("#startDate").focus();
420			return;
421		}
422
423		if($("#endDate").val() == "") {
424			alert("Please enter a end date.");
425			$("#endDate").focus();
426			return;
427		}
428
429		if(!compareStringNum($("#startDate").val(), $("#endDate").val(), ".")) {
430			alert("The period is incorrect.");
431			$("#startDate").focus();
432			return;
433		}		
434	}
435
436	searchForm.startDate.value = $("#startDate").val();
437	searchForm.endDate.value = $("#endDate").val();
438	searchForm.range.value = $("#range").val();
439	searchForm.reQuery.value = "2";
440	searchForm.submit();
441}
442
443// 영역
444function doSearchField(field) {
445	var searchForm = document.search;
446	searchForm.searchField.value = field;
447	searchForm.reQuery.value = "2";
448	searchForm.submit();
449}
450
451// 문자열 숫자 비교
452function compareStringNum(str1, str2, repStr) {
453	var num1 =  parseInt(replaceAll(str1, repStr, ""));
454	var num2 = parseInt(replaceAll(str2, repStr, ""));
455
456	if (num1 > num2) {
457		return false;
458	} else {
459		return true;
460	}
461}
462
463// Replace All
464function replaceAll(str, orgStr, repStr) {
465	return str.split(orgStr).join(repStr);
466}
467
468// 공백 제거
469function trim(str) {
470	return str.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
471}
472
473
474
475function setRelationkeyword(xml){
476    
477    var obj = jQuery('#relationiKeywordSet');
478    var str = xml.split("\^");
479    var count = str.length;
480 
481    
482    var wordLen = 0;
483    var j;
484    for(j=0; j<count && wordLen<=40; j++){
485        wordLen += str[j].length;
486    }
487    
488    //if(str == ''){
489    if(j-1==0){
490        jQuery('#relationKeyword').hide();
491    }else{
492        for(i=0;i<j-1;i++){
493             if(i==0){
494                 obj.append("<li class=\"first\"><a href=\"#;\" onClick=\"javascript:doKeyword('"+str[i]+"');\" >"+str[i]+"</a></li>");
495             }else{
496                 obj.append("<li><a href=\"#;\" onClick=\"javascript:doKeyword('"+str[i]+"');\" >"+str[i]+"</a></li>");
497             }
498        }
499    }
500}
501
502
503function getPopkeyword(flag){
504	
505 
506	//cookie에 해당 데이타가 있으면 호출하지 않고 사용한다. (Expire는 1일.)   
507/*	     var cookie = null;//getCookie("popkeyword");
508	     if(cookie == null || cookie=='' || cookie !='ark'){*/
509
510		    jQuery.ajax({
511		        type: "POST",
512		        url: "/search/popWord.do",
513		        success: function(xml) {
514		        	  
515		        	setPopkeyword(xml,flag);
516		        }
517		    });
518/*	     }else{
519	    	
520	    	 setPopkeyword(cookie,flag);
521	     }*/
522	}
523
524
525
526function setPopkeyword(xml,flag){
527	
528 
529 
530	var xmlSplit1 = xml.split('^');
531	var arrRange = '';
532 
533	var xmlSplit2 = new Array(xmlSplit1.length);
534	
535    for(var i = 0; i<xmlSplit1.length; i++){
536 
537    	arrRange = xmlSplit1[i].split(',').length;
538 
539    	xmlSplit2[i] = new Array(arrRange);
540    	
541    	for(var j = 0; j<arrRange; j++){
542    		
543    		xmlSplit2[i][j] = xmlSplit1[i].split(',')[j];
544    	} 
545    }
546    
547   
548    
549/*    var destObj = jQuery('#popWordList');
550    destObj.empty();*/
551    
552    var rank_day = jQuery('#rank_day');
553    var rank_week = jQuery('#rank_week');
554    var rank_month = jQuery('#rank_month');
555    
556    rank_day.empty();
557    rank_week.empty();
558    rank_month.empty();
559    
560    
561    var item = "";
562    var cnt = 1;
563    var idx = 0;
564    var size = xmlSplit1.length;
565    var temp = new Array(2);
566    var query = "";
567    var count = 0
568    
569    
570    
571    
572    if(size > 0)
573    {
574/*   	 var popword = "";
575   	 var j;
576   	 for(var j=0; j<size; j++){
577   		 popword += xmlSplit[j];
578   		 if(popword.length > 20) break;
579   	 }*/
580     
581/*   	 item += "<ul>";    	 
582   	 
583   /// 일간 인기검색어
584   	 	item += "<li class=\"active\">";
585   	 	item += "<a href=\"#rank_day\">일간</a>";
586   	 	item += "<ul class=\"sr_rank_ls\" id=\"rank_day\">";
587*/
588/*			 for(idx = 0 ; idx < size; idx++)
589	    	 {
590				 var query = xmlSplit[idx];
591				 item += "<li class='num1'><strong class='num'>"+cnt+"</strong><a href=\"#\" onClick=\"javascript:goPopword('"+query+"');\"> "+query+"</a></li>";
592				 cnt++;
593	    	 }
594*/			
595   	 		for(idx = 0 ; idx < xmlSplit2[0].length ; idx++ ){
596   	 			
597   	 		temp = xmlSplit2[0][idx].split('@');
598   	 		
599   	 		query = temp[0];
600   	 		count = temp[1];
601   	 			
602   	 				item += "<li>"
603   	 			
604   	 			if(idx==0){
605   	 				item += "<span class=\"sr_numbox\">"+cnt+"</span>";
606   	 			}else if(idx <3&&idx>0){
607   	 				item += "<span class=\"sr_numbox2\">"+cnt+"</span>";
608   	 			}else{
609   	 				item += "<span class=\"sr_numbox3\">"+cnt+"</span>";
610   	 			}
611   	 				item += "<a href=\"#\" onClick=\"javascript:doKeyword('"+query+"');\">"+query+"</a>";
612   	 				item += "<span class=\"sr_rank\">";
613   	 				
614   	 				if(parseInt(count)>0){
615   	 					item += "<i class=\"sr_rankup\"></i>";
616   	 					item += "<span>"+count+"</span>";
617   	 				}else if(parseInt(count)<0){
618   	 					item += "<i class=\"sr_rankdown\"></i>";
619   	 					item += "<span>"+Math.abs(count)+"</span>";
620   	 				}else{
621   	 					item += "<span>-</span>";
622   	 				}
623   	 				
624   	 				//item += "<span>"+count+"</span>";
625   	 				item += "</span>";
626   	 				item += "</li>";	
627   	 				
628   	 			cnt++;
629   	 		}
630   	 		
631   	 	rank_day.html(item);
632   	 		
633   	 			cnt=1;
634   	 			item="";
635 
636   	 	
637   	   /// 주간 인기검색어
638 		
639   	 		for(idx = 0 ; idx < xmlSplit2[1].length ; idx++ ){
640   	 			
641   	   	 		temp = xmlSplit2[1][idx].split('@');
642   	   	 		
643   	   	 		query = temp[0];
644   	   	 		count = temp[1];
645   	   	 			
646   	   	 				item += "<li>"
647   	   	 			
648   	   	   	 			if(idx==0){
649   	    	 				item += "<span class=\"sr_numbox\">"+cnt+"</span>";
650   	    	 			}else if(idx <3&&idx>0){
651   	    	 				item += "<span class=\"sr_numbox2\">"+cnt+"</span>";
652   	    	 			}else{
653   	    	 				item += "<span class=\"sr_numbox3\">"+cnt+"</span>";
654   	    	 			}
655   	    	 				item += "<a href=\"#\" onClick=\"javascript:doKeyword('"+query+"');\">"+query+"</a>";
656   	    	 				item += "<span class=\"sr_rank\">";
657   	    	 				
658   	    	 				if(parseInt(count)>0){
659   	    	 					item += "<i class=\"sr_rankup\"></i>";
660   	    	 					item += "<span>"+count+"</span>";
661   	    	 				}else if(parseInt(count)<0){
662   	    	 					item += "<i class=\"sr_rankdown\"></i>";
663   	    	 					item += "<span>"+Math.abs(count)+"</span>";
664   	    	 				}else{
665   	    	 					item += "<span>-</span>";
666   	    	 				}
667   	    	 				
668   	    	 				//item += "<span>"+count+"</span>";
669   	    	 				item += "</span>";
670   	    	 				item += "</li>";	
671   	    	 				
672   	   	 			cnt++;
673   	   	 		}
674 
675   	 		rank_week.html(item);
676   	 		cnt=1;
677   	 		item="";
678 
679   	   /// 월간 인기검색어
680 
681   	 		for(idx = 0 ; idx < xmlSplit2[2].length ; idx++ ){
682   	 			
683   	   	 		temp = xmlSplit2[2][idx].split('@');
684   	   	 		
685   	   	 		query = temp[0];
686   	   	 		count = temp[1];
687   	   	 			
688   	   	 				item += "<li>"
689   	   	 			
690   	   	   	 			if(idx==0){
691   	    	 				item += "<span class=\"sr_numbox\">"+cnt+"</span>";
692   	    	 			}else if(idx <3&&idx>0){
693   	    	 				item += "<span class=\"sr_numbox2\">"+cnt+"</span>";
694   	    	 			}else{
695   	    	 				item += "<span class=\"sr_numbox3\">"+cnt+"</span>";
696   	    	 			}
697   	    	 				item += "<a href=\"#\" onClick=\"javascript:doKeyword('"+query+"');\">"+query+"</a>";
698   	    	 				item += "<span class=\"sr_rank\">";
699   	    	 				
700   	    	 				if(parseInt(count)>0){
701   	    	 					item += "<i class=\"sr_rankup\"></i>";
702   	    	 					item += "<span>"+count+"</span>";
703   	    	 				}else if(parseInt(count)<0){
704   	    	 					item += "<i class=\"sr_rankdown\"></i>";
705   	    	 					item += "<span>"+Math.abs(count)+"</span>";
706   	    	 				}else{
707   	    	 					item += "<span>-</span>";
708   	    	 				}
709   	    	 				
710   	    	 				//item += "<span>"+count+"</span>";
711   	    	 				item += "</span>";
712   	    	 				item += "</li>";	
713   	    	 				
714   	   	 			cnt++;
715   	   	 		}
716   	 		
717   	 		rank_month.html(item);
718 
719   	  
720   	/* destObj.html(item);*/
721    }
722    
723    //setCookie(xml);    
724}
725
726
727

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.