PageSourceSearch

https://artemuseum.com/js/site_search.js?1750138860

js artemuseum.com collected 2026-09-24 09:35:02 UTC 5,843 bytes, 216 lines download raw bytes

1var SITE_SEARCH = function(){
2	var init = function() {
3		const $numericInput = $('input[type=text][data-inputmode=numeric]');
4		const $numericInputMin = $numericInput.filter('[data-numeric-type=min]');
5		const $numericInputMax = $numericInput.filter('[data-numeric-type=max]');
6
7		/**
8		 * 가격 입력 정책
9		 * - 가격 입력은 소수 둘째 자리까지 입력이 가능하도록 구현
10		 * - 음수는 입력이 불가능함
11		 */
12		$numericInput.on('input', function(e) {
13			const refineValue = e.target.value
14				.replace(/[^\d.]/g, '') // 숫자와 소수점만 허용 처리
15				.replace(/^\./, '') // 맨 앞 소수점 입력 불가 처리
16				.replace(/\.{2,}/g, '.') // 소수점 연속 입력 불가 처리
17				.replace(/(\d*\.\d*)\.(\d*)/, '$1$2'); // 소수점 두번 이상 입력 방지 처리
18
19			e.target.value = refineValue
20				.replace(/(\d+\.?\d{0,2}).*/, '$1'); // 소수점 둘째 자리까지만 처리
21		});
22
23		$numericInput.on('blur', function(e) {
24			const refineValue = e.target.value
25				.replace(/\.$/, ''); // 마지막이 소수점으로 끝날경우 제거
26
27			const numericValue = parseFloat(refineValue);
28
29			e.target.value = Number.isNaN(numericValue) ? '' : numericValue;
30		});
31
32		$numericInput.on('keydown', function(e) {
33			if (e.key === 'Enter') {
34				/** 검색인 경우, 강제 blur 이벤트 발생 및 form submit 처리 */
35				e.target.blur();
36
37				$('#s_form').submit();
38			}
39		});
40
41		/**
42		 * 최소 가격 입력 정책
43		 * - 최소 가격이 최대 가격보다 작거나 같아야 함
44		 */
45		$numericInputMin.on('blur', function(e) {
46			const minValue = parseFloat(e.target.value);
47			const maxValue = parseFloat($numericInputMax.val());
48
49			if (Number.isNaN(minValue) || Number.isNaN(maxValue)) {
50				return;
51			}
52
53			e.target.value = Math.min(Math.max(0, minValue), maxValue);
54		});
55
56		/**
57		 * 최대 가격 입력 정책
58		 * - 최대 가격은 최소 가격보다 크거나 같아야 함
59		 */
60		$numericInputMax.on('blur', function(e) {
61			const minValue = parseFloat($numericInputMin.val());
62			const maxValue = parseFloat(e.target.value);
63
64			if (Number.isNaN(minValue) || Number.isNaN(maxValue)) {
65				return;
66			}
67
68			e.target.value = Math.max(minValue, maxValue);
69		});
70	}
71
72	var openSearch = function(data){
73		$.cocoaDialog.close();
74		var $s_form = $('#s_form');
75		var keyword = '';
76		var type = '';
77		if($s_form.length >0 ){
78			keyword = $s_form.find('input[name=keyword]').val().trim();
79			type = $s_form.find('input[name=type]').val();
80		}
81		$.ajax({
82			type: 'POST',
83			data: {'keyword':keyword, 'type': type,'data':data},
84			url: ('/dialog/search.cm'),
85			dataType: 'html',
86			async: true,
87			cache: false,
88			success: function(html){
89				var $html = $(html);
90				$.cocoaDialog.open({type: 'widget_search', custom_popup: $html});
91				$html.find('input[name=keyword]').off("focus").on("focus", function (e) {
92					// IE
93					if (this.createTextRange) {
94						var range = this.createTextRange();
95						range.move('character', this.value.length);    // input box 의 글자 수 만큼 커서를 뒤로 옮김
96						range.select();
97					}
98					else if (this.selectionStart || this.selectionStart== '0')
99						this.selectionStart = this.value.length;
100				});
101			}
102		});
103	};
104
105	$.urlParam = function(name){
106		var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
107		return results[1] || 0;
108	}
109
110	var search = function(){
111		var $s_form = $('#s_form');
112		var $_keyword = $s_form.find('input[name=keyword]');
113		$_keyword.val($_keyword.val().trim());
114
115		var $_category_code = $s_form.find('select[name=category_code]');
116		if ($_category_code.length) {
117			const val = $_category_code.val();
118			if (val === '') {
119				$_category_code.prop('disabled', true);
120			}
121		}
122
123		var $_min_price = $s_form.find('input[name=min_price]');
124		if ($_min_price.length) {
125			const val = $_min_price.val().trim();
126			if (val === '') {
127				$_min_price.prop('disabled', true);
128			} else {
129				$_min_price.val(val);
130			}
131		}
132
133		var $_max_price = $s_form.find('input[name=max_price]');
134		if ($_max_price.length) {
135			const val = $_max_price.val().trim();
136			if (val === '') {
137				$_max_price.prop('disabled', true);
138			} else {
139				$_max_price.val(val);
140			}
141		}
142
143		$s_form.submit();
144
145		// form 전송 후 disabled 해제 (원래대로)
146		$_category_code.prop('disabled', false);
147		$_min_price.prop('disabled', false);
148		$_max_price.prop('disabled', false);
149	};
150
151	var inlineSearch = function(code){
152		var $s_form = $('#inline_s_form_' + code);
153		var $_keyword = $s_form.find('input[name=keyword]');
154		$_keyword.val($_keyword.val().trim());
155		$s_form.submit();
156	};
157
158	var searchDialog = function(){
159		var $sd_form = $('#sd_form');
160		var $_keyword = $sd_form.find('input[name=keyword]');
161		$_keyword.val($_keyword.val().trim());
162		$sd_form.submit();
163	};
164
165	var changeType = function(type){
166		var $s_form = $('#s_form');
167		var $type = $s_form.find('._type');
168		$type.val(type);
169		$s_form.submit();
170	};
171	var changeSort = function(type){
172		var $s_form = $('#s_form');
173		var $sort = $s_form.find('._sort');
174		$sort.val(type);
175		$s_form.submit();
176	};
177
178	var popularSearch = function(code, keyword) {
179		var $s_form = $('#inline_s_form_' + code);
180		var $_keyword = $s_form.find('input[name=keyword]');
181		$_keyword.val(keyword);
182
183		$s_form.submit();
184		setTimeout(()=>{
185			$_keyword.val('')
186		},0);
187	}
188
189	return {
190		'init' : function() {
191			init();
192		},
193		'inlineSearch' : function(code){
194			inlineSearch(code);
195		},
196		'openSearch' : function(data){
197			openSearch(data);
198		},
199		'search' : function(){
200			search();
201		},
202		'searchDialog' : function(){
203			searchDialog();
204		},
205		'changeType' : function(type){
206			changeType(type);
207		},
208		'changeSort' : function(type){
209			changeSort(type);
210		},
211		'popularSearch' : function(code, keyword) {
212			popularSearch(code, keyword);
213		}
214	}
215
216}();

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.