PageSourceSearch

https://www.jbedu.or.kr/resources/js/script-date.js

js jbedu.or.kr collected 2026-10-08 12:46:33 UTC 7,403 bytes, 215 lines download raw bytes

1
2//var $ = jQuery.noConflict(); 
3
4$(document).ready(function(){
5    // defult
6     /*
7   $("#startValue").val(getCalculatedDate(0,0,0,'-'))
8   $("#endValue").val(getCalculatedDate(0,0,0,'-'))
9    /*
10   $("#startValue_group").val(getCalculatedDate(0,0,0,'-'))
11   $("#endValue_group").val(getCalculatedDate(0,0,0,'-'))
12   */
13    
14    setJqDate();
15    
16    $('.dateGroup')
17    .append('<span style="border:none;"><input type="button" value="1일" class="dayBt" id="1day"/></span>')
18    .append(' <span style="border:none;"><input type="button" value="1주일" class="dayBt" id="1week"/></span>')
19    .append(' <span style="border:none;"><input type="button" value="10일" class="dayBt" id="10days"/></span>')
20    .append(' <span style="border:none;"><input type="button" value="15일" class="dayBt" id="15days"/></span>')
21    .append(' <span style="border:none;"><input type="button" value="1개월" class="dayBt" id="1month"/></span>')
22    .append(' <span style="border:none;"><input type="button" value="3개월" class="dayBt" id="3month"/></span>')
23    //.append(' <span style="border:none;"><input type="button" value="6개월" class="dayBt" id="6month"/></span>');
24    
25    // date
26    $("#6month").click(function(){
27        $("#startValue").val(getCalculatedDate(0,-6,0,'-'))
28        $("#endValue").val(getCalculatedDate(0,0,0,'-'))
29    });
30
31    $("#3month").click(function(){
32        $("#startValue").val(getCalculatedDate(0,-3,0,'-'))
33        $("#endValue").val(getCalculatedDate(0,0,0,'-'))
34    });
35
36    $("#1month").click(function(){
37        $("#startValue").val(getCalculatedDate(0,-1,0,'-'))
38        $("#endValue").val(getCalculatedDate(0,0,0,'-'))
39    });
40
41    $("#15days").click(function(){
42        $("#startValue").val(getCalculatedDate(0,0,-15,'-'))
43        $("#endValue").val(getCalculatedDate(0,0,0,'-'))
44    });
45
46    $("#10days").click(function(){
47        $("#startValue").val(getCalculatedDate(0,0,-10,'-'))
48        $("#endValue").val(getCalculatedDate(0,0,0,'-'))
49    });
50
51    $("#1week").click(function(){
52        $("#startValue").val(getCalculatedDate(0,0,-7,'-'))
53        $("#endValue").val(getCalculatedDate(0,0,0,'-'))
54    });
55    
56    $("#1day").click(function(){
57        $("#startValue").val(getCalculatedDate(0,0,0,'-'))
58        $("#endValue").val(getCalculatedDate(0,0,0,'-'))
59    });
60    
61    // group
62
63    $("#6month_group").click(function(){
64        $("#startValue_group").val(getCalculatedDate(0,0,0,'-'))
65        $("#endValue_group").val(getCalculatedDate(0,-6,0,'-'))
66    });
67
68    $("#3month_group").click(function(){
69        $("#startValue_group").val(getCalculatedDate(0,0,0,'-'))
70        $("#endValue_group").val(getCalculatedDate(0,-3,0,'-'))
71    });
72
73    $("#1month_group").click(function(){
74        $("#startValue_group").val(getCalculatedDate(0,0,0,'-'))
75        $("#endValue_group").val(getCalculatedDate(0,-1,0,'-'))
76    });
77
78    $("#15days_group").click(function(){
79        $("#startValue_group").val(getCalculatedDate(0,0,0,'-'))
80        $("#endValue_group").val(getCalculatedDate(0,0,-15,'-'))
81    });
82
83    $("#10days_group").click(function(){
84        $("#startValue_group").val(getCalculatedDate(0,0,0,'-'))
85        $("#endValue_group").val(getCalculatedDate(0,0,-10,'-'))
86    });
87
88    $("#1week_group").click(function(){
89        $("#startValue_group").val(getCalculatedDate(0,0,0,'-'))
90        $("#endValue_group").val(getCalculatedDate(0,0,-7,'-'))
91    });
92    
93    $("#1day_group").click(function(){
94        $("#startValue_group").val(getCalculatedDate(0,0,0,'-'))
95        $("#endValue_group").val(getCalculatedDate(0,0,0,'-'))
96    });
97});
98
99function setJqDate() {
100	if($(".jqDate").datepicker){
101	    $(".jqDate").datepicker({
102	        altField: '20101122',
103	        altFormat: 'yy-mm-dd', 
104	        dateFormat: 'yy-mm-dd', 
105	        showOn: 'button', 
106	        buttonImage: CTX+'/resource/image/calender.gif', 
107	        buttonImageOnly: true, 
108	        changeMonth: true, 
109	        changeYear: true, 
110	        showMonthAfterYear:true,
111	        monthNamesShort:["1","2","3","4","5","6","7","8","9","10","11","12"],
112	        dayNamesMin:["일","월","화","수","목","금","토"],
113	        onSelect:function(dateText, inst) {
114	            validSearchDate($(this));
115	        }
116	
117	    })
118	    .attr("maxlength", 10)
119	    .blur(function(){
120	        if($(this).val() != "") {
121	            if(!validDate($(this).val())) {
122	                alert("날짜가 올바르지 않습니다.");
123	                $(this).val("").focus();
124	            }else {
125	                validSearchDate($(this));
126	                $(this).val(dateFormat($(this).val())); 
127	            }
128	        }
129	    });
130	}
131}
132
133
134function validSearchDate(obj) {
135	
136	if($("#startValue").is("input") && $("#endValue").is("input")){
137	    if($("#endValue").val()!="" && $("#startValue").val()!="") {
138	    	if($("#startValue").val().replace("-", "").replace("-", "") > $("#endValue").val().replace("-", "").replace("-", "")) {
139	            alert("시작일이 종료일보다 큼니다.");
140	            obj.val("").focus();
141	            return false;
142	        }
143	
144	    	if($("#endValue").val().replace("-", "").replace("-", "") < $("#startValue").val().replace("-", "").replace("-", "")) {
145	            alert("종료일이 시작일보다 작습니다.");
146	            obj.val("").focus();
147	            return false;
148	        }
149	    } 		
150	}
151}
152
153function getCalculatedDate(iYear, iMonth, iDay, seperator)
154{
155 //현재 날짜 객체를 얻어옴.
156 var gdCurDate = new Date();
157 //현재 날짜에 날짜 게산.
158 gdCurDate.setYear( gdCurDate.getFullYear() + iYear );
159 gdCurDate.setMonth( gdCurDate.getMonth() + iMonth );
160 gdCurDate.setDate( gdCurDate.getDate() + iDay );
161 
162 //실제 사용할 연, 월, 일 변수 받기.
163 var giYear = gdCurDate.getFullYear();
164 var giMonth = gdCurDate.getMonth()+1;
165 var giDay = gdCurDate.getDate();
166 //월, 일의 자릿수를 2자리로 맞춘다.
167 giMonth = "0" + giMonth;
168 giMonth = giMonth.substring(giMonth.length-2,giMonth.length);
169 giDay   = "0" + giDay;
170 giDay   = giDay.substring(giDay.length-2,giDay.length);
171 //display 형태 맞추기.
172 return giYear + seperator + giMonth + seperator +  giDay;
173}
174
175
176//날짜 유효성 검증
177function validDate(checkDate ) { 
178   iDate = replaceAll(checkDate, "-", "");
179   if(iDate.length != 8){
180       return false;   
181   }
182
183   year  = iDate.substring(0, 4);
184   month = iDate.substring(4, 6);
185   month = month - 1;               // javascript month range : 0- 11 
186   day   = iDate.substring(6);
187   var tempDate = new Date(year,month, day); 
188
189   if (  (tempDate.getFullYear() == year) && 
190         (month == tempDate.getMonth()) && 
191         (day == tempDate.getDate()) ){ 
192      return true; 
193   }else{  
194      return false
195   } 
196} 
197
198function dateFormat(date) {
199    if(date=="") {
200        return "";
201    }
202    
203    iDate = replaceAll(date, "-", "");
204    year  = iDate.substring(0, 4);
205    month = iDate.substring(4, 6);
206    day   = iDate.substring(6);
207    
208    giYear  = year;
209    giMonth = "0" + month;
210    giMonth = giMonth.substring(giMonth.length-2,giMonth.length);
211    giDay   = "0" + day;
212    giDay   = giDay.substring(giDay.length-2,giDay.length);
213    
214    return giYear + "-" + giMonth + "-" +  giDay;
215}

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.