1/* 2* 2011.11.13 make by beans9([email protected]) 3* http://beans9.tistory.com 4*/ 5 6var cssAddFlag = true; 7function CalAddCss(){ 8 var cssHtml = "<style type='text/css'>"; 9 cssHtml += ".calLayout{ border:1px solid #DDDDDD; background-color:#ECEADF; position:absolute;padding:2px;display:none;z-index:9999 }"; 10 cssHtml += ".calTitle{ border:1px solid #D4D1BF; background-color: #ffffff; width:99%; font-size:9pt;}"; 11 cssHtml += ".calHeader{ padding:2px; padding-bottom:0px;text-align:center;}"; 12 cssHtml += ".calBody{padding:2px;padding-top:0px;text-align:center; }"; 13 cssHtml += ".calDay{background-color: #FBFBFB;border:1px solid #CBC7BD; width:20px;float:left;font-size:8pt;padding-top:3px;padding-bottom:2px;cursor:pointer;}"; 14 cssHtml += ".calSunDay{ background-color: #FBFBFB;border:1px solid #CBC7BD; width:20px;float:left;font-size:8pt;padding-top:3px;padding-bottom:2px;cursor:pointer;color:red;}"; 15 cssHtml += ".calSatDay{ background-color: #FBFBFB;border:1px solid #CBC7BD; width:20px;float:left;font-size:8pt;padding-top:3px;padding-bottom:2px;cursor:pointer; color:blue;}"; 16 cssHtml += ".calOtherDay{background-color: #FBFBFB; border:1px solid #CBC7BD;width:20px;float:left;font-size:8pt;padding-top:3px;padding-bottom:2px;cursor:pointer;color:#CBC7BD;}"; 17 cssHtml += ".dayToday{background-color: #368CFE;border:1px solid #CBC7BD;font-weight:bold;font-weight:bold;width:20px;float:left;font-size:8pt;padding-top:3px;padding-bottom:2px;cursor:pointer;color:white; }"; 18 cssHtml += ".calSelDay{ background-color: #CF4040;border:1px solid #CBC7BD;font-weight:bold;width:20px;float:left;font-size:8pt;padding-top:3px;padding-bottom:2px;cursor:pointer;text-decoration:underline;color:white;}"; 19 cssHtml += ".dayEvMon{font-size:8pt;width:25px; height:15px;background-color: #FBFBFB;border:1px solid #CBC7BD; padding:4px 4px 0px 3px;float:left;cursor:pointer;}"; 20 cssHtml += ".MonToday{font-size:8pt;width:25px; height:15px;background-color: #368CFE;border:1px solid #CBC7BD; font-weight:bold;padding:4px 4px 0px 3px;color:white;cursor:pointer;}"; 21 cssHtml += ".selMon{font-size:8pt;width:25px;height:15px;background-color: #CF4040;border:1px solid #CBC7BD;font-weight:bold;padding:4px 4px 0px 3px;text-decoration:underline;color:white;}"; 22 cssHtml += ".calOnDay{background-color: #006060;border:1px solid #4B22C0;float:left;cursor:pointer;color:white;}"; 23 cssHtml += ".calDaySpace{padding:1px;float:left;}"; 24 cssHtml += ".calDayBr{clear:both;height:2px;}"; 25 cssHtml += ".calDayTitle{padding-top:2px;width:22px;float:left; font-size:8pt;}"; 26 cssHtml += ".divHeadOnRigth{color:#18CCA8;cursor:pointer;}"; 27 cssHtml += ".todayBtn{clear:both;text-align: center;font-size:8pt;cursor:pointer;background-color: #FBFBFB;border:1px solid #CBC7BD;padding:4px 4px 0px 3px;height:15px;}"; 28 cssHtml += ".todayLay{padding-left:2px;}</style>"; 29 jQuery("head").append(cssHtml); 30} 31 32// ì´ê¸°í 33function initCal(obj){ 34 if( cssAddFlag == true ){ 35 CalAddCss(); 36 cssAddFlag = false; 37 } 38 39 // id ì ì 40 var calId = "Cal" + obj.id; 41 42 // calendar type (day,mon) 43 var calType = obj.type == null ? "day" : obj.type; 44 if( calType.toLowerCase() != "day" && calType.toLowerCase() != "mon"){ 45 calType = "day"; 46 } 47 48 // ìµìë ë, ìµëë ë 49 var minYear = obj.min == null ? "2000" : obj.min; 50 // maxYear ìµë ë ë ì¤ì 51 var maxYear = obj.max == null ? new Date().getFullYear() + 2: obj.max; 52 var splitKey = obj.splitKey == null ? "-" : obj.splitKey; 53 var todayYN = obj.today == null ? "n" : "y"; 54 var iconYN = obj.icon == null ? "n" : "y"; 55 var iconUrl = obj.iconUrl == null ? "/manage/img/calendar_btn.gif" : obj.iconUrl ; 56 var timeYN = obj.timeYN == null ? "n" : "y"; 57 58 // ë¬ë ¥ ë ì´ìì(ì ì²´í+ìì í)그리기 59 drawCalForm(calId,obj.id,calType,minYear,maxYear,todayYN,iconYN,iconUrl); 60 61 if( calType == "day"){ 62 jQuery("#"+obj.id).attr("maxlength",timeYN == "y" ? 21 : 8); 63 jQuery("#"+calId).css("width","170px"); 64 jQuery("#"+calId +"btn.todayBtn").css("width","157px"); 65 }else{ 66 jQuery("#"+obj.id).attr("maxlength",7); 67 jQuery("#"+calId).css("width","146px"); 68 jQuery("#"+calId +"btn.todayBtn").css("width","133px"); 69 } 70 71
72 // input boxì click event 73 jQuery("#"+ calId + "Icon").click(function(event){ 74 var datesVal = jQuery("#"+obj.id).val(); 75 if( calType == "mon") datesVal += splitKey + '1'; 76 77 var dates = isValidCheck(datesVal ,splitKey, timeYN); 78 if( calType == "day"){ 79 makeCal(calId,dates,splitKey,timeYN); 80 }else{ 81 makeCalMon(calId,dates,splitKey); 82 } 83 calPosition(obj.id,calId); 84 jQuery("#"+calId).show(); 85 86 }); 87 88 // ì¸ë¶ íë©´ í´ë¦ì ë¬ë ¥ê°ì¶ê¸° 89 jQuery(document).click(function(event){ 90 var parentEls = jQuery( event.target).parents().map(function () { return this.id; }).get().join(", "); 91 if(parentEls.indexOf(calId+",") == -1 && event.target.id != obj.id && parentEls.indexOf(calId+"Icon,")){ 92 jQuery("#"+calId).hide(); 93 } 94 }); 95 96 jQuery(window).resize(function(event){ 97 calPosition(obj.id,calId); 98 }); 99 100 // ë¬ë ¥ìë¨ ì´ì /ë¤ì ë²í¼ ì²ë¦¬ 101 jQuery("#"+calId+"before,#"+calId+"next").click(function(event){ 102 var plus = -1; 103 if(this.id.indexOf("next") > -1){ var plus = 1; } 104 105 if( calType == "day"){ 106 var dates = calDate(jQuery("#"+ calId + "selYear").val(),jQuery("#"+calId + "selMon").val(),plus,isValidCheck(jQuery("#"+obj.id).val(),splitKey, timeYN)); 107 if((dates[0] >= minYear && plus == -1) || (dates[0] <= maxYear && plus == 1)){ 108 makeCal(calId,dates,splitKey,timeYN); 109 } 110 }else{ 111 var dates = calDate(jQuery("#"+ calId + "selYear").val(),'1',plus*12,isValidCheck(jQuery("#"+obj.id).val()+splitKey+'1',splitKey, timeYN)); 112 if((dates[0] >= minYear && plus == -1) || (dates[0] <= maxYear && plus == 1)){ 113 makeCalMon(calId,dates,splitKey); 114 } 115 } 116 }).mouseover(function(){ 117 jQuery(this).addClass("divHeadOnRigth"); 118 }).mouseout(function(){ 119 jQuery(this).removeClass("divHeadOnRigth"); 120 });; 121 122 // ìë³ì íì íììì 123 if( calType == "day"){ 124 // ë ë,ì selectbox ì íì ì´ë²¤í¸ 125 jQuery("#"+calId+"selYear,#"+calId+"selMon").change(function(event){ 126 var dates = calDate(jQuery("#"+ calId + "selYear").val(),jQuery("#"+calId + "selMon").val(),0,isValidCheck(jQuery("#"+obj.id).val(),splitKey, timeYN)); 127 makeCal(calId,dates,splitKey, timeYN); 128 }); 129 }else{ 130 jQuery("#"+calId+"selYear").change(function(event){ 131 var dates = calDate(jQuery("#"+ calId + "selYear").val(),1,0,isValidCheck(jQuery("#"+obj.id).val()+splitKey+'1',splitKey, timeYN)); 132 makeCalMon(calId,dates,splitKey); 133 }); 134 } 135 136 jQuery("#"+calId+"btn").click(function(){ 137 jQuery("#"+obj.id).val(""); 138 var dates = isValidCheck('',splitKey, timeYN); 139 if( calType == 'day'){ 140 makeCal(calId,dates,splitKey,timeYN); 141 }else{ 142 makeCalMon(calId,dates,splitKey); 143 } 144 }); 145 146 calPosition(obj.id,calId); 147} 148 149//í´ë¦ ì´ë²¤í¸ 150function calClickEvent(id){ 151 jQuery("#" + id + " .calOtherDay,.calDay,.calSunDay,.calSatDay,.MonToday,.selMon,.dayEvMon").click(function(event) { 152 jQuery("#" + id.substring(3)).val(this.id.replace(id,"")); 153 jQuery("#" + id).hide(); 154 }).mouseover(function(){ 155 jQuery(this).addClass("calOnDay"); 156 }).mouseout(function(){ 157 jQuery(this).removeClass("calOnDay"); 158 }); 159} 160 161// ë¬ë ¥ í¼ ê·¸ë¦¬ê¸° 162function drawCalForm(id,tId,calType,min,max,todayYN,iconYN,imageUrl){ // tId = ì ë ¥ì°½ID 163 164 if(iconYN == "y"){ 165 jQuery(document.body).append("<div id='"+ id +"Icon' style='position:absolute; cursor:pointer; z-index:10000;'><img id='"+ id +"IconImg' src='"+ imageUrl +"'><div>"); 166 } 167 168 // layout 169 jQuery(document.body).append("<div id='"+ id +"' onselectstart='return false' class='calLayout'><div>"); 170 171 // ìë¨ ë ,ë¬ ì´ë 172 var html = "<div class='calTitle'><table width='100%'><tr><td id='"+ id +"before' width='10%' style='font-size: 10px'>â</td><td width='80%' align='center'>"; 173 174 // ë ì í 175 html += "<select id='"+ id +"selYear'>"; 176 for(var i=min;i<=max;i++){ html += "<option value=" + i + ">" + i + "</option>"; } 177 html += "</select>" 178 179 // ìì í (ì¼ë³ë¬ë ¥ì¼ ê²½ì°ìë§) 180 if( calType == "day"){ 181 html += "<select id='"+ id +"selMon'>";
182 for(var i=1;i<=12;i++){ html += "<option value=" + i + ">" + i + "ì</option>"; } 183 html += "</select>" 184 } 185 186 html += "</td><td id='"+ id +"next' width='10%' style='font-size: 10px'>â¶</td></tr></table></div>"; 187 if( calType == "day" )html += "<div id='" + id + "Header' class='calHeader'></div>"; 188 html += "<div id='" + id + "Content' class='calBody'></div>"; 189 190 if( todayYN == "y"){ 191 html += "<div class='todayLay'><div id='" + id + "btn' class='todayBtn'>Today</div></div>"; 192 } 193 194 jQuery("#"+id).html(html); 195 196 // ìì í (ì¼ë³ë¬ë ¥ì¼ ê²½ì°ìë§) 197 if (calType == "day") { 198 var tempHtml = ""; 199 var yoil = ["ì¼", "ì", "í", "ì", "목", "ê¸", "í "]; 200 for (i = 0; i < 7; i++) { 201 tempHtml += "<div class='calDayTitle'>" + yoil[i] + "</div>"; 202 if (i == 6) { tempHtml += "<div class='calDayBr'></div>"; } 203 else { tempHtml += "<div class='calDaySpace'></div>"; } 204 } 205 jQuery("#" + id + "Header").append(tempHtml); 206 } 207 208 209} 210 211// ë ì§ë³ê²½(ë¬ë³ê²½) ë¬ë ¥ë´ì© 그리기 212function makeCal(id,dates,splitKey,timeYN){ 213 var timeTF = timeYN == "y" ? true : false; 214 215 // ì´ë²ë¬ ììë ì§,ë§ì§ë§ë ì§ 216 var firstDay = new Date(dates[0],eval(dates[1]-1),1).getDay(); 217 218 // ì´ë²ë¬ ë§ì§ë§ë ì§ 219 var lastDate = new Date(dates[0],eval(dates[1]),0); 220 var lastDateNum = lastDate.getDate(); 221 var lastDay = lastDate.getDay(); 222 223 // ì´ì ë¬ ë§ì§ë§ë ì§ 224 var beforeMonDate = new Date(dates[0],eval(dates[1]-1),0); 225 var beforeMonLastDay = beforeMonDate.getDate(); 226 var beforeYearMonText = beforeMonDate.getFullYear() + splitKey + strFormat(beforeMonDate.getMonth()+1) + splitKey; 227 228 var nextMonDate = new Date(dates[0],eval(dates[1]),1); 229 var nextYearMonText = nextMonDate.getFullYear() + splitKey + strFormat(nextMonDate.getMonth()+1) + splitKey; 230 231 var nowYearMonText = dates[0] + splitKey + strFormat(dates[1]) + splitKey; 232 233 var ndate = new Date(); 234 var today; 235 if(timeTF){ 236 today = ndate.getFullYear() + splitKey + strFormat(ndate.getMonth()+1) + splitKey + strFormat(ndate.getDate()) + " " + strFormat(ndate.getHours()) + ":" + strFormat(ndate.getMinutes()) + ":" + strFormat(ndate.getSeconds()) + ".0"; 237 } else { 238 today = ndate.getFullYear() + splitKey + strFormat(ndate.getMonth()+1) + splitKey + strFormat(ndate.getDate()); 239 } 240 241 //----------------------------------------------------- 242 var html = ""; 243 var brCount = 1; // ì¤ëê¹ count 244 245 // before month 246 for( i = 1; i<=firstDay; i++){ 247 html += "<div class='calOtherDay' id='"+ id + beforeYearMonText + (beforeMonLastDay-(firstDay-i)) +"'>"+ (beforeMonLastDay-(firstDay-i)) + "</div><div class='calDaySpace'></div>"; 248 brCount ++; 249 } 250 251 // now month 252 for (i = 1; i <= lastDateNum; i++) { 253 var dayCss = "calDay"; 254 if (brCount % 7 == 1) { dayCss = "calSunDay" ; } 255 else if(brCount % 7 == 0){ dayCss = "calSatDay" ; } 256 257 if(timeTF){ 258 html += "<div class='"+ dayCss +"' id='"+ id + nowYearMonText + strFormat(i) + " " + strFormat(ndate.getHours()) + ":" + strFormat(ndate.getMinutes()) + ":" + strFormat(ndate.getSeconds()) + ".0" +"'>" + i + "</div>"; 259 }else{ 260 html += "<div class='"+ dayCss +"' id='"+ id + nowYearMonText + strFormat(i) +"'>" + i + "</div>"; 261 } 262 263 if( brCount %7 == 0 && i != lastDateNum ){ html += "<div class='calDayBr'></div>"; } 264 else{ html += "<div class='calDaySpace'></div>"; } 265 brCount ++; 266 } 267 268 // next month 269 var nexyStartDay = 1; 270 for( i = lastDay; i<6; i++){ 271 html += "<div class='calOtherDay' id='" +id + nextYearMonText + strFormat(nexyStartDay) +"'>"+ nexyStartDay++ + "</div><div class='calDaySpace'></div>"; 272 } 273 274 // ë´ì© ì½ì 275 jQuery("#" + id + "Content").html(html); 276 277 // ë ë select ì¤ì 278 jQuery("#" + id + "selYear").val(dates[0]); 279 280 // ì¼ë³ë¬ë ¥ì¼ ê²½ì° ì select ì ì 281 jQuery("#" + id + "selMon").val(eval(dates[1])); 282 283 // ì¤ëë ì§ ì²´í¬ 284 jQuery("#" + id+ today).addClass("dayToday"); 285 286 // ì ë ¥ë ì§ ì²´í¬ 287 if(dates[4] == true){ 288 jQuery("#" +id + dates[3]).addClass("calSelDay");
289 // ì ë ¥ë ì§ê° ì í¨í ë ì§ë©´ input쪽 ë°ì´í°ë¥¼ íìì ë§ê² ë³ê²½ 290 jQuery("#" + id.substring(3)).val(dates[3]); 291 } 292 293 calClickEvent(id); 294} 295 296function makeCalMon(id,dates,splitKey){ 297 var nowYeaText = dates[0] + splitKey; 298 299 var ndate = new Date(); 300 var today = ndate.getFullYear() + splitKey + strFormat(ndate.getMonth()+1); 301 302 var html = "<div class='calDayBr'></div><div class='calDayBr'></div>"; 303 for(var i=1;i<13;i++){ 304 html += "<div class='dayEvMon' id='"+ id + nowYeaText + strFormat(i) +"'>" + i + "</div>"; 305 if( i %4 == 0 && i != 12){ html += "<div class='calDayBr'></div>"; } 306 else{ 307 html += "<div class='calDaySpace'></div>"; 308 } 309 } 310 // ë´ì© ì½ì 311 jQuery("#" + id + "Content").html(html); 312 // ë ë select ì¤ì 313 jQuery("#" + id + "selYear").val(dates[0]); 314 315 // ì¤ëë ì§ ì²´í¬ 316 jQuery("#" + id + today).addClass("MonToday"); 317 318 // ì ë ¥ë ì§ ì²´í¬ 319 if(dates[4] == true){ 320 jQuery("#" +id + dates[3].substring(0,7)).addClass("selMon"); 321 322 // ì ë ¥ë ì§ê° ì í¨í ë ì§ë©´ input쪽 ë°ì´í°ë¥¼ íìì ë§ê² ë³ê²½ 323 jQuery("#" + id.substring(3)).val( dates[3].substring(0,7)); 324 } 325 326 calClickEvent(id); 327} 328 329// ë ì§ ì í¨ì± ì²´í¬ 330function isValidCheck(strDate,splitKey,timeYN,todayCheck){ 331 var timeTF = timeYN == "y" ? true : false; 332 333 var date = strDate; 334 335 var dates; 336 var times; 337 if(timeTF){ 338 times = date.substr(date.indexOf(" ")+1,8).split(":"); 339 dates = date.substr(0,date.indexOf(" ")).split(splitKey); 340 } else { 341 dates = date.split(splitKey); 342 } 343 344 var idate; 345 if(timeTF){ 346 idate = new Date(dates[0],eval(dates[1])-1,eval(dates[2]),times[0],times[1],times[2],0); 347 } else { 348 idate = new Date(dates[0],eval(dates[1])-1,eval(dates[2])); 349 } 350 var ndate = new Date(); 351 352 var isValid = true; 353 if( dates[0] != idate.getFullYear()) isValid = false; 354 else if( eval(dates[1])-1 != idate.getMonth()) isValid = false; 355 else if( eval(dates[2]) != idate.getDate()) isValid = false; 356 if(timeTF){ 357 if( times[0] != idate.getHours()) isValid = false; 358 else if( times[1] != idate.getMinutes()) isValid = false; 359 else if( times[2] != idate.getSeconds()) isValid = false; 360 } 361 362 if( isValid == false ){ 363 dates[0] = ndate.getFullYear(); 364 dates[1] = strFormat(ndate.getMonth()+1); 365 dates[2] = strFormat(ndate.getDate()); 366 if(timeTF){ 367 times[0] = strFormat(ndate.getHours()); 368 times[1] = strFormat(ndate.getMinutes()); 369 times[2] = strFormat(ndate.getSeconds()); 370 } 371 } 372 373 if(timeTF){ 374 dates[3] = dates[0] +splitKey + strFormat(dates[1]) + splitKey + strFormat(dates[2]) + " " + strFormat(times[0]) + ":" + strFormat(times[1]) + ":" + strFormat(times[2]) + ".0"; 375 }else{ 376 dates[3] = dates[0] +splitKey + strFormat(dates[1]) + splitKey + strFormat(dates[2]); 377 } 378 dates[4] = isValid; 379 return dates; 380} 381 382function calDate(year,month,adjust,isValidDate){ 383 var date = new Date(year,(month-1)+adjust,1); 384 var dates = [date.getFullYear(),date.getMonth()+1,date.getDate(),isValidDate[3],isValidDate[4]]; 385 return dates; 386} 387 388// ë ì§ format ë§ì¶ê¸° 389function strFormat(str){ 390 if((str+"").length == 1) str = "0" + str; 391 return str; 392} 393 394// ë¬ë ¥ìì¹ë³ê²½ 395function calPosition(target,id){ 396 var tInput = jQuery("#" + target).offset(); 397 var tHeight = jQuery("#" + target).outerHeight(); 398 var tWidth = jQuery("#" + target).outerWidth(); 399 400 var calHeight = jQuery("#" + id).outerHeight(); 401 402 if( tInput != null){ 403 jQuery("#" + id).css({"top":tInput.top+tHeight , "left":tInput.left}); 404 jQuery("#" + id + "Icon").css({"top":tInput.top+1,"left":tInput.left+tWidth+2}); 405 } 406}
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.