PageSourceSearch

https://www.koreastudy.or.kr/ikedu/js/com.form.js

js koreastudy.or.kr collected 2026-10-02 18:37:09 UTC 15,766 bytes, 712 lines download raw bytes

1/**
2 * 1. form element 초기화
3 * 2. form 데이터 바인딩
4 * 3. form 데이터 조회
5 * 4. form 데이터 수정/저장
6 * 5. form data 삭제
7 * 6. Enter Key TabIndex 이동
8 * 7. 입력한 tabIndex로 객체리턴
9 * 8. Enter Key 함수 호출 Search 용 
10 * 9. form Disabled 처리
11 * 10.form Readonly 처리
12 */
13
14
15
16/**
17 * 1. form element 초기화
18 */
19function fn_FormClear(frm) {	
20	var elems = $(frm).find('input, select, textarea, hidden');
21	
22	$(frm).get(0).reset();
23		
24	$.each(elems, function() {
25		if (this.type == "hidden") {
26			
27			if(this.name != "STATUS")
28				this.value = "";
29			
30			// 중복확인 FormClear 시 색깔 처리
31			if(this.id == "dplctCheckResult")
32			{
33				this.value = "N";
34				$(this).prev().addClass("dplctCheckResult_bass");
35			}
36				
37		}
38	});
39	var sourceElems = $(frm).find('select');
40	if(sourceElems.length > 0){
41		$.each(sourceElems, function() {
42			$("#"+this.name+" option:eq(0)").attr("selected", "selected");
43		});
44	}
45
46	return elems;
47}
48
49/**
50 * 2. form 데이터 바인딩
51 */
52function fn_FormBindData() {
53	var args = arguments; //Parameters
54	var data = args[0];
55	var frm = args[1];
56	var msg = args[2];
57	
58	var elems = fn_FormClear(frm);
59
60	if (data == null) {
61		if (msg == null) {
62			alert("조회된 데이터가 없습니다.");
63		} else if (msg != "") {
64			alert(msg); //사용자 메시지 처리
65		}
66		return;
67	}else{
68		$("#STATUS", frm).val("U");
69	}
70	
71	$.each(elems, function() {
72		var name = this.name;
73		for(key in data) {
74			if (name == key) {
75				if (this.type == "checkbox") {
76					if (data[key] == "Y") {
77						this.checked = true;
78						this.value = data[key];
79					} else {
80						this.checked = false;
81						this.value = 'N';
82					}
83				} else if (this.type == "radio") {
84					if (this.value == data[key]) {
85						this.checked = true;
86					} else {
87						this.checked = false;
88					}
89				} else {
90					if(this.type == "text" && $(this).attr("bindType") == "amount")
91						this.value = fn_FormatNumberComma(data[key]);
92					else
93					{
94						if($(this).attr("linkedSelect") != undefined)
95							$(this).attr("selectedValue", data[key]);
96						else
97							if(data[key] == null){
98								this.value = "";
99							}else{
100								this.value = data[key];
101							}
102					}
103												
104				}
105			}
106		}
107	});
108	
109}
110
111
112/**
113 * 3. form 데이터 조회
114 */
115function fn_FormSearch() {	
116	var args = arguments; // Parameters
117	var searchUrl = args[0];
118	var searchfrm = args[1];
119	var bindfrm = args[2];
120	var callbackFunction = args[3];
121
122	if(searchfrm == null)
123		return;
124	
125	var elems = $(searchfrm).find('input, select, textarea, hidden');
126
127	var searchObj = new Object();
128	
129	$.each(elems, function() {
130		searchObj[this.name] = this.value;
131	});
132
133	$.ajax({
134		method: "POST"
135		, dataType : "json"
136		, url: searchUrl
137		, data: searchObj
138		, success: function(data) {
139			if(fnFworkErrorCheck(data))
140			{
141				fn_FormBindData(data, bindfrm, "");
142				fn_setLinkedSelectValue();
143	            if (callbackFunction != null
144						&& callbackFunction != undefined) {
145					callbackFunction(data);
146				}
147			}
148        }
149		,error: function() {
150            alert('통신장애로 데이터가 처리 되지않았습니다.');
151        }
152	});
153}
154
155/**
156 * 4. form 데이터 수정/저장
157 */
158function fn_FormSave() {	
159	var args = arguments; // Parameters
160	var saveUrl = args[0];
161	var savefrm = args[1];
162	var callbackFunction = args[2];
163
164	if(savefrm == null)
165		return;
166	
167	var elems = $(savefrm).find('input, select, textarea, hidden');
168
169	// 필수값 체크 후 데이터가 없는 경우 true, 있는경우 false
170	var essntlFlag = false;
171	
172	var saveObj = new Object();
173	var saveData = new Array();
174	
175	$.each(elems, function() {
176		
177		if($(this).attr("essntl") == "true"){
178			if($(this).val() == "" || $(this).val() == null || $(this).val() == undefined)
179			{
180				essntlFlag = true;
181				$(this).addClass("essntl_failr");
182				return;
183			}
184			else
185			{
186				$(this).removeClass("essntl_failr");
187			}
188		}
189
190	    if(this.type == 'radio'){
191	    	$(this).each(function(){
192	    	     if($(this).prop('checked')){
193	    	    	 saveObj[this.name] = $(this).val();
194	    	      }
195	    	 });
196		}
197	    else if(this.type == 'checkbox'){
198			if($(this).is(":checked")){ 
199				this.value = 'Y'; 
200			}else{
201				this.value = 'N';
202			}
203			saveObj[this.name] = this.value;
204		}
205	    else if(this.type == "text"){
206			if($(this).attr("bindType") == "amount"){	
207				this.value = fn_FormatNumberUnComma(this.value);
208				saveObj[this.name] = this.value;				
209			}else{
210				saveObj[this.name] = this.value;
211			}
212		}
213	    else if(this.type == "textarea"){
214			var editor = CKEDITOR.instances[this.name];
215			if(editor != undefined){
216				this.value = editor.getData();
217				saveObj[this.name] = this.value;
218			}else{
219				saveObj[this.name] = this.value;
220			}			
221		}
222	    else{
223	    	saveObj[this.name] = this.value;
224	    }
225
226	});
227
228	// 필수값 체크 후 데이터가 없는 엘리먼트가 있는 경우 return
229	if(essntlFlag){
230		alert("필수입력 값을 모두 입력하여 주십시오");
231		return;
232	}
233	
234	saveData[0] = saveObj;
235	var json = JSON.stringify(saveData);
236
237	$.ajax({
238		method: "POST"
239		, dataType : "json"
240		, url: saveUrl
241		, data: {"data": json}
242		, success: function(data) {
243			if(fnFworkErrorCheck(data))
244			{
245	            alert(data.message);
246	            if (callbackFunction != null
247						&& callbackFunction != undefined) {
248					callbackFunction(data);
249				}
250			}
251        }
252		,error: function() {
253            alert('통신장애로 데이터가 처리 되지않았습니다.');
254        }
255	});
256}
257
258
259/**
260 * 5. form data 삭제
261 */
262function fn_FormDel() {
263	var args = arguments; //Parameters
264	var delurl = args[0];
265	var delfrm = args[1];
266	var callbackFunction = args[2];
267	var confirmMsg = args[3];
268	
269	if($(delfrm).find("#STATUS") != null && $(delfrm).find("#STATUS").val() == "I"){
270		return;
271	}
272	
273	if(confirmMsg == null || confirmMsg == ""){
274		confirmMsg = "정말로 삭제하시겠습니까?";
275	}
276		
277	if(confirm(confirmMsg)) {
278		$(delfrm).find("#STATUS").val('D');
279		var elems = $(delfrm).find('input, select, textarea, hidden');
280
281		var saveObj = new Object();
282		var saveData = new Array();
283		
284		$.each(elems, function() {
285			if(this.type == 'checkbox'){
286				if($(this).is(":checked")){ this.value = 'Y'; }
287			}
288			if(this.type == "text" && $(this).attr("bindType") == "amount"){
289				this.value = fn_FormatNumberUnComma(this.value);
290			}			
291			saveObj[this.name] = this.value;
292		});
293
294		saveData[0] = saveObj;
295
296		var json = JSON.stringify(saveData);
297		
298		$.ajax({
299			dataType: 'json'
300			, url: delurl
301			, data: {"data": json}
302			, success: function(data){
303				if(fnFworkErrorCheck(data))
304				{
305					alert(data.message);							
306					if (callbackFunction != null && callbackFunction != undefined) {
307						callbackFunction(data); //User Function Call
308					}
309				}
310			}
311			, error: function(xhr, status, err) {
312				alert('통신장애로 데이터가 처리 되지않았습니다.');
313			}
314		});
315	}
316}
317
318/**
319 * 6. Enter Key TabIndex 이동
320 */
321function fnMoveTab(txtObj,event){ 
322	var KeyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode; 
323
324	if(KeyCode == 13){ 
325		tmp = GetObjectByTabIndex(txtObj.form,txtObj.tabIndex+1); 
326		if (tmp == null) tmp = GetObjectByTabIndex(1); 
327		if (tmp != null) tmp.focus(); 
328	} 
329} 
330
331/**
332 * 7.입력한 tabIndex로 객체리턴 
333 */
334function GetObjectByTabIndex(formObj,index){ 
335
336	for (i = 0; i < formObj.length; i++){ 
337		tmp = formObj.elements[i]; 
338		if (tmp.tabIndex == index){ 
339			return tmp; 
340		} 
341	} 
342	return null; 
343}
344
345/**
346 * 8.Enter Key 함수 호출 Search 용 
347 */
348function fnEnterSearch(searchFuncName, event){
349	var KeyCode = event.keyCode ? event.keyCode : event.which ? event.which : event.charCode; 
350	
351	if(KeyCode == 13){ 
352		searchFuncName();
353	}
354}
355
356/**
357 * 9.Form Disabled
358 */
359function fn_FormDisabled(frm) {	
360	var input = $(frm).find('input');
361	$.each(input, function() {
362		$(this).attr("disabled", "disabled");
363	});
364	var textarea = $(frm).find('textarea');
365	$.each(textarea, function() {
366		$(this).attr("disabled", "disabled");
367	});
368	var select = $(frm).find('select');
369	$.each(select, function() {
370		$(this).attr("disabled", "disabled");
371	});
372}
373
374/**
375 * 10.Form Readonly
376 */
377function fn_FormReadonly(frm, arr) {
378	var input = $(frm).find('input');
379	var textarea = $(frm).find('textarea');
380	var select = $(frm).find('select');
381	
382	if(arr != null){
383		$.each(input, function() {
384			if($.inArray(this.name, arr) === -1){
385				if(this.type == "checkbox"  || $(this).attr("bindType") == "date"){
386					$(this).attr("disabled", "disabled");
387				}
388				else{
389					$(this).attr("readonly", "readonly");
390				}				
391			}else{
392				if(this.type == "checkbox"  || $(this).attr("bindType") == "date"){
393					$(this).attr("disabled", false);
394				}
395				else{
396					$(this).attr("readonly", false);
397				}
398			}
399		});
400		
401		$.each(textarea, function() {
402			if($.inArray(this.name, arr) === -1){
403				$(this).attr("readonly", "readonly");
404			}else{
405				$(this).attr("readonly", false);
406			}
407		});
408		
409		$.each(select, function() {
410			if($.inArray(this.name, arr) === -1){
411				$(this).attr("disabled", "disabled");
412			}else{
413				$(this).attr("disabled", false);
414			}	
415		});		
416	}else{
417		$.each(input, function() {
418			if(this.type == "checkbox"  || $(this).attr("bindType") == "date"){
419				$(this).attr("disabled", "disabled");
420			}
421			else{
422				$(this).attr("readonly", "readonly");
423			}
424		});
425		
426		$.each(textarea, function() {
427			$(this).attr("readonly", "readonly");
428		});
429		
430		$.each(select, function() {
431			$(this).attr("disabled", "disabled");
432		});
433	}
434	
435	
436
437}
438
439/**
440 * 11. 해당 div 내에 input element keyup 이벤트 적용
441 */
442function inputElementNextStep(divName){
443	
444	$('input, select', $('#'+divName)).each(function () {
445	    $(this).keyup(function (event){
446	    	
447	    	var value = $(this).val();
448	    	
449	    	
450	    	
451	    	if(!isEmptyString(value)){
452	    		
453	    		enterKeyNext(event, this);
454	    	}else{
455	    		if(!isEmptyString($(this).attr("popup"))){
456		    		var popupBtn = $(this).attr("popup");
457		    		
458		    		$("#"+popupBtn).click();
459		    	}
460	    	}
461	    	
462	    });
463	});
464	
465	$(document).keyup(function(e){
466		if(event.keyCode == "13" && isEmpty(document.activeElement.name))
467		{
468			$('[tabindex="1"]').focus();
469		}
470	});
471}
472
473/**
474 * 12. 해당 엘리먼트에서 Enter Key 입력 시 포커스 이동
475 * 
476 */
477function enterKeyNext(event, element){
478	if(event.keyCode == "13")
479	{
480		var nextElement = $('[tabindex="' + (Number(element.tabIndex) + 1) + '"]');
481		
482		if (nextElement.length)
483		{
484			
485			if($(nextElement).attr("disabled") == "disabled"){
486				var nextToElemnet = $('[tabindex="' + (Number(element.tabIndex) + 2) + '"]');
487				
488				nextToElemnet.focus();
489			}else{
490				nextElement.focus()
491			}
492			
493			
494		}else
495		{
496			$('[tabindex="1"]').focus();
497		}    
498	}
499}
500
501/**
502 * F2 번 키 함수 적용
503 */
504function f2Function(funcNm){
505	$(document).keyup(function(e){
506	    if(e.keyCode == 113){
507	    	var func = eval(funcNm);
508			func(this);
509	    }
510	});
511}
512
513/**
514 * F8 번 키 함수 적용
515 */
516function f8Function(funcNm){
517	$(document).keyup(function(e){
518	    if(e.keyCode == 119){
519	    	var func = eval(funcNm);
520			func(this);
521	    }
522	});
523}
524
525/**
526 * F9 번 키 함수 적용
527 */
528function f9Function(funcNm){
529	$(document).keyup(function(e){
530	    if(e.keyCode == 120){
531	    	var func = eval(funcNm);
532			func(this);
533	    }
534	});
535}
536
537/**
538 * F10 번 키 함수 적용
539 */
540function f10Function(funcNm){
541	$(document).keyup(function(e){
542	    if(e.keyCode == 121){
543	    	var func = eval(funcNm);
544			func(this);
545	    }
546	});
547}
548
549/**
550 * Label 에러 메시지 작성
551 */
552function isError(elementId, errorMessage){
553	var element = $("#"+elementId);
554	
555	element.text(errorMessage);
556	element.removeClass("isVaild").addClass("isError");	
557}
558
559/**
560 * Label 유효 메시지 작성
561 */
562function isVaild(elementId, errorMessage){
563	var element = $("#"+elementId);
564	
565	element.text(errorMessage);
566	element.removeClass("isError").addClass("isVaild");
567	
568}
569
570function fnGetAjaxData(){
571	var args = arguments;
572	var ajaxUrl = args[0];
573	var ajaxParam = args[1];
574	var callbackFunction = args[2];
575	$.ajax({
576		dataType: 'json'
577		, url: ajaxUrl
578		, data: ajaxParam
579		, type : "POST"
580		, contentType: "application/x-www-form-urlencoded; charset=UTF-8"
581		, success: function(data){
582			if(fnFworkErrorCheck(data))
583			{
584				if (callbackFunction != null
585						&& callbackFunction != undefined) {
586					callbackFunction(data);
587				}
588			}
589		}
590		, error: function(xhr, status, err) {
591			alert('통신장애로 데이터가 처리 되지않았습니다.');
592		}
593	});
594}
595
596function fnJsonAjaxData(){
597	var args = arguments;
598	var ajaxUrl = args[0];
599	var ajaxParam = args[1];
600	var callbackFunction = args[2];
601	
602	var saveData = new Array();
603	saveData[0] = ajaxParam
604	var json = JSON.stringify(saveData);
605
606	$.ajax({
607		dataType: 'json'
608		, url: ajaxUrl
609		, data: {"data":json}
610		, success: function(data){
611			if(fnFworkErrorCheck(data))
612			{
613				alert(data.message);
614				if (callbackFunction != null
615						&& callbackFunction != undefined) {
616					callbackFunction(data);
617				}
618			}
619		}
620		, error: function(xhr, status, err) {
621			alert('통신장애로 데이터가 처리 되지않았습니다.');
622		}
623	});
624}
625
626function fn_FormUnReadonly(frm, arr) {
627	var input = $(frm).find('input');
628	var textarea = $(frm).find('textarea');
629	var select = $(frm).find('select');
630	
631	if(arr != null){
632		$.each(input, function(i, el) {
633			if($.inArray(this.name, arr) === -1){
634				if(this.type == "checkbox"  || $(this).attr("bindType") == "date"){
635					$(this).attr("disabled", false);
636				}
637				else{
638					$(this).attr("readonly", false);
639				}
640			}else{
641				if(this.type == "checkbox"  || $(this).attr("bindType") == "date"){
642					$(this).attr("disabled", true);
643				}
644				else{
645					$(this).attr("readonly", true);
646				}
647			}
648		});
649
650		$.each(textarea, function() {
651			if($.inArray(this.name, arr) === -1){
652				$(this).attr("readonly", false);
653			}else{
654				$(this).attr("readonly", true);
655			}
656		});
657		
658		$.each(select, function() {
659			if($.inArray(this.name, arr) === -1){
660				$(this).attr("disabled", false);
661			}else{
662				$(this).attr("disabled", true);
663			}
664		});		
665	}else{
666		$.each(input, function() {
667			if(this.type == "checkbox"  || $(this).attr("bindType") == "date"){
668				$(this).attr("disabled", false);
669			}
670			else{
671				$(this).attr("readonly", false);
672			}
673		});
674		$.each(textarea, function() {
675			$(this).attr("readonly", false);
676		});
677		$.each(select, function() {
678			$(this).attr("disabled", false);
679		});
680	}
681}
682
683function fnFormData(){
684	var args = arguments; // Parameters
685	var frmId = args[0];	
686	var status = args[1];
687	
688	var elems = $(frmId).find('input, select, textarea, hidden');
689
690	var frmObj = new Object();
691	var frmData = new Array();
692	
693	$.each(elems, function() {
694		if(this.type == 'checkbox'){
695			if($(this).is(":checked")){ 
696				this.value = 'Y'; 
697			}else{
698				this.value = 'N';
699			}
700		}
701		if(this.name == "STATUS" && status != null) this.value = status;
702		if(this.type == "text" && $(this).attr("bindType") == "amount"){
703			this.value = fn_FormatNumberUnComma(this.value);
704		}
705				
706		frmObj[this.name] = this.value;
707	});
708		
709	frmData[0] = frmObj;
710	
711	return frmData;
712}

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.