-=[ Mr. Bumblebee ]=-
_Indonesia_
<public:component>
<public:attach event="ondocumentready" handler="init"/>
<public:attach event="onchange" handler="calUpdate"/>
<script language="javascript">
var currDate, oDropBtn, ctrlFrame, ctrlLayer, objYear, objMonth, currCell, beforeColor,btnChoose=" ",btnCancel="";
var pth="/inc/htc/calendar/",bg_img = "calendar_bg.gif" , btn_img = "calendar.gif",btn_ml = "dal_bt_nnext.gif",btn_mr = "dal_bt_ppre.gif",btn_yl="dal_bt_next.gif",btn_yr="dal_bt_pre.gif";
var is_open = false;
var objDateCells = new Array();
function padZeros(num, size) {
var str = num.toString();
var numZeros = size - str.length;
for (var i=0; i<numZeros; i++) str="0"+str;
return str;
}
function getRealOffsetTop(o) {
return o ? o.offsetTop + getRealOffsetTop(o.offsetParent) : 0;
}
function getRealOffsetLeft(o) {
return o ? o.offsetLeft + getRealOffsetLeft(o.offsetParent) : 0;
}
function calAdjust() {
var year = currDate.getFullYear();
var month = currDate.getMonth();
objYear.innerText = year;objMonth.innerText = month+1;
var dateFirst = new Date(year, month, 1);
var startCellNum = dateFirst.getDay();
var dateLast = new Date(year, month+1, 0);
var endCellNum = startCellNum + dateLast.getDate() - 1;
for (var i=0; i<42; i++) {
objDateCells[i].innerText = (i>=startCellNum && i<=endCellNum) ? i-startCellNum+1 : "";
switch (i%7) {
case 0: objDateCells[i].style.color="red"; break;
case 6: objDateCells[i].style.color="blue"; break;
default: objDateCells[i].style.color="black";
}
}
if (currCell) { currCell.style.backgroundColor="white"; }
currCell = objDateCells[currDate.getDate() + startCellNum - 1];
currCell.style.backgroundColor="black";
currCell.style.color="white";
ctrlFrame.style.width = ctrlFrame.scrollWidth;
ctrlFrame.style.height = ctrlFrame.scrollHeight;
}
function setNextMonth() { currDate.setMonth(currDate.getMonth() + 1); calAdjust(); }
function setPrevMonth() { currDate.setMonth(currDate.getMonth() - 1); calAdjust(); }
function setNextYear() { currDate.setFullYear(currDate.getFullYear() + 1); calAdjust(); }
function setPrevYear() { currDate.setFullYear(currDate.getFullYear() - 1); calAdjust(); }
//********** Ãß°¡ µÈ ºÎºÐ *************************************************************
function hideFrame() { calHide(); }
function setOpenCalendar() {
currDate = (this.value != "") ?
new Date(this.value.substr(0,4),this.value.substr(5,2)-1,this.value.substr(8,2)) : new Date();
if (isNaN(currDate)) { this.value=""; currDate=new Date(); }
calAdjust();
}
//***************************************************************************************
function dateCellOnClick() {
var tempcolor = currCell.style.color;
if (this.innerText=="") return;
if (currCell) {
currCell.style.backgroundColor="white";
if ( beforeColor == undefined || beforeColor.length == 0 ) { // ´Ù¸¥ Cell·Î À̵¿ÈÄ¿¡ ÀÌÀü font Color °ª º¹¿ø
currCell.style.color="black";
} else {
currCell.style.color=beforeColor;
}
}
currDate.setDate(parseInt(this.innerText));
currCell=this;
beforeColor = currCell.style.color; // ¼±Åà ÀÌÀüÀÇ font color À» À¯Áö Çϱâ À§ÇØ...
currCell.style.backgroundColor="black";
currCell.style.color="white";
this.click(); value=getDateStr(); calToggle();
}
function dateCellOnDblClick() { this.click(); value=getDateStr(); calToggle(); }
function getDateStr() {
return currDate.getFullYear()+"-"+padZeros(currDate.getMonth()+1,2)+"-"+padZeros(currDate.getDate(),2);
}
function calHide() { ctrlFrame.style.visibility="hidden"; oDropBtn.value=btnChoose;}
function calShow() { ctrlFrame.style.visibility="visible"; setOpenCalendar();}
function calToggle() {
switch (oDropBtn.value) {
case btnChoose:calShow(); oDropBtn.value=btnCancel; break;
case btnCancel:calHide(); oDropBtn.value=btnChoose; break;
}
}
function calUpdate() {
currDate = (this.value != "") ?
new Date(this.value.substr(0,4),this.value.substr(5,2)-1,this.value.substr(8,2)) : new Date();
if (isNaN(currDate)) { this.value=""; currDate=new Date(); }
calAdjust();
}
function init() {
if (this.disabled) return;
currDate = (this.value != "") ?
new Date(this.value.substr(0,4),this.value.substr(5,2)-1,this.value.substr(8,2)) : new Date();
if (isNaN(currDate)) { this.value=""; currDate=new Date(); }
oDropBtn = document.createElement("<input type=button value='"+btnChoose+"' style='padding:0 0 0 0; margin:0 0 0 0 ;border:0; background-image:URL("+pth+btn_img+"); background-repeat:no-repeat; background-color:#FFFFFF; background-position:5px 0px;width:22px;height:18px' >");
oDropBtn.align = "absmiddle";
oDropBtn.onfocus = oDropBtn.blur;
oDropBtn.onclick = calToggle;
this.onclick = calToggle;
this.onfocus = this.blur;
insertAdjacentElement("afterEnd",oDropBtn);
var ifrmId = "htccalifrm" + Math.floor(Math.random() * 1000000);
ctrlFrame = document.createElement("<IFRAME id=" + ifrmId + " FRAMEBORDER=0></IFRAME>");
with (ctrlFrame.style) {
width="21px"; height="20px";
position="absolute";
zIndex="9";
visibility="hidden";
top=getRealOffsetTop(this); left=getRealOffsetLeft(this);
}
//********* Calander ¿¡¼ Mouse Out ½Ã Calander À» ¼û°ÜÁØ´Ù.. *************************
ctrlFrame.onmouseout = hideFrame;
//***********************************************************************************
insertAdjacentElement("afterEnd", ctrlFrame);
var ifrmDoc = ctrlFrame.document.frames(ifrmId).document;
ifrmDoc.open("text/html","replace");
ifrmDoc.writeln("<html><link href='/css/css.css' rel='stylesheet' type='text/css'><head><style>TH,TD{font-family:Dotum}</style><body style=margin:0px;background-color:white></body></html>");
ifrmDoc.close();
ctrlLayer = ifrmDoc.createElement("DIV");
with (ctrlLayer.style) {
width="130px"; backgroundColor="white"; color="black";
textAlign="center"; fontSize="12px";
}
var tTable = ifrmDoc.createElement("<table width='180' height='155' border='0' cellpadding='0' cellspacing='0'>");
ctrlLayer.appendChild(tTable);
var trow, tcell, tspan, tnbsp;
var tTbody = ifrmDoc.createElement("TBODY"); tTable.appendChild(tTbody);
tRow = ifrmDoc.createElement("TR") ; tTbody.appendChild(tRow) ;
tCell = ifrmDoc.createElement("<td valign='top' style='background-image:url(" + pth + bg_img + ");background-repeat:no-repeat;' style='padding:10px;'>"); tRow.appendChild(tCell);
tCell.style.backgroundColor="white"; tCell.style.color="#555555";
// <tr><td valign='top' style='background-image:url(" + pth + bg_img + ");background-repeat:no-repeat;' class='pd10'
var oTable = ifrmDoc.createElement("<table width='160' border='0' cellpadding='0' cellspacing='0'>");
tCell.appendChild(oTable);
var row, cell, span, nbsp;
var oTbody = ifrmDoc.createElement("TBODY"); oTable.appendChild(oTbody);
row = ifrmDoc.createElement("TR"); oTbody.appendChild(row);
cell = ifrmDoc.createElement("TD"); row.appendChild(cell);
cell.style.color="#555555";
cell.style.height = "20px" ;
cell.align = "center" ;
cell.style.fontWeight = 'bold' ;
// end all table
// begin move table
span = ifrmDoc.createElement("<img src="+pth+btn_yr+" alt='Previous Year' style='cursor:hand' align='absmiddle'>"); cell.appendChild(span);
span.onmouseup = setPrevYear; span.onselectstart = function(){return false;}
nbsp = ifrmDoc.createTextNode(" "); cell.appendChild(nbsp);
nbsp = ifrmDoc.createTextNode(" "); cell.appendChild(nbsp);
objYear = ifrmDoc.createElement("SPAN"); cell.appendChild(objYear);
nbsp = ifrmDoc.createTextNode(" "); cell.appendChild(nbsp);
nbsp = ifrmDoc.createTextNode(" "); cell.appendChild(nbsp);
span = ifrmDoc.createElement("<img src="+pth+btn_yl+" alt='Next Year' style='cursor:hand' align='absmiddle'>"); cell.appendChild(span);
span.onmouseup = setNextYear; span.onselectstart = function(){return false;}
nbsp = ifrmDoc.createTextNode(" "); cell.appendChild(nbsp);
nbsp = ifrmDoc.createTextNode(" "); cell.appendChild(nbsp);
span = ifrmDoc.createElement("<img src="+pth+btn_mr+" alt='Previous Month' style='cursor:hand' align='absmiddle'>"); cell.appendChild(span);
span.onmouseup = setPrevMonth; span.onselectstart = function(){return false;}
nbsp = ifrmDoc.createTextNode(" "); cell.appendChild(nbsp);
nbsp = ifrmDoc.createTextNode(" "); cell.appendChild(nbsp);
objMonth = ifrmDoc.createElement("SPAN"); cell.appendChild(objMonth);
nbsp = ifrmDoc.createTextNode(" "); cell.appendChild(nbsp);
nbsp = ifrmDoc.createTextNode(" "); cell.appendChild(nbsp);
span = ifrmDoc.createElement("<img src="+pth+btn_ml+" alt='Next Month' style='cursor:hand' align='absmiddle'>"); cell.appendChild(span);
span.onmouseup = setNextMonth; span.onselectstart = function(){return false;}
// end move table
// begin calendar table
row = ifrmDoc.createElement("TR");
oTbody.appendChild(row);
cell = ifrmDoc.createElement("TD"); row.appendChild(cell);
cell.style.color="#555555";
cell.align= "center" ;
var sTable = ifrmDoc.createElement("<table width='147' border='0' cellpadding='0' cellspacing='0'>") ;
cell.appendChild(sTable) ;
var sTbody = ifrmDoc.createElement("TBODY") ; sTable.appendChild(sTbody) ;
sRow = ifrmDoc.createElement("TR"); sTbody.appendChild(sRow);
var weekArray = ["<font color='red'>Su</font>","Mo","Tu","We","Th","Fi","<font color='blue'>Sa</font>"];
for (var i=0; i<7; i++) {
sCell=ifrmDoc.createElement("TD");
sCell.style.color="#555555";
sCell.style.width = '21px';
sCell.style.height = '18px' ;
sCell.align = 'center';
sCell.style.fontSize = '11px' ;
//sCell.innerText=weekArray[i];
sCell.innerHTML =weekArray[i];
sRow.appendChild(sCell);
}
sRow = ifrmDoc.createElement("TR"); sTbody.appendChild(sRow);
sCell=ifrmDoc.createElement("<TD colspan='7' height='1' background='/img/dot_line.gif'>");
sRow.appendChild(sCell);
ifrmDoc.appendChild(ctrlLayer);
for (var i=0; i<6; i++) {
sRow = ifrmDoc.createElement("TR"); sTbody.appendChild(sRow);
for (var j=0; j<7; j++) {
objDateCells[i*7+j] = sCell = ifrmDoc.createElement("<td align=center style='cursor:hand' >");
sRow.appendChild(sCell);
sCell.style.height = '16px' ;
sCell.style.fontSize = '11px' ;
sCell.onclick = dateCellOnClick;
//sCell.ondblclick = dateCellOnDblClick;
sCell.onselectstart = function(){return false;}
}
}
calAdjust();
}
</script>
</public:component>
Copyright © 2017 || Recoded By Mr.Bumblebee