1// Product title: Gurt Calendar JavaScript 2// Product version details: 1.2.0, 03-01-2006 (mm-dd-yyyy) 3// Product URL: http://gurtom.com/products/calendars/js 4// Contact info: [email protected] (specify product title in the subject) 5// Notes: This script is free. Feel free to copy, use and change this script as 6// long as this head part remains unchanged. Visit official site for details. 7// Copyright: (c) 2006 by Gurtom.Com 8 9var agC= [],ogB,oD; 10function gCalendar(oSettings){ 11var _ = this; 12_.nCId = agC.length; 13agC[_.nCId] = _; 14if (!ogB) ogB = new _UserAgent(); 15if (!oD) oD = new _DManager(); 16_.sNameControl = oSettings.dataArea ? oSettings.dataArea :'dataArea'+_.nCId; 17_.sIcoName = 'icoCls'+_.nCId; 18_.sPosName = 'icoPos'+_.nCId; 19_.sDivName = 'clsDiv'+_.nCId; 20_.sBoxName = 'clsBox'+_.nCId; 21_.sTitleName = 'clsTitle'+_.nCId; 22_.sPmiName = 'clsPMI'+_.nCId; 23_.sNmiName = 'clsNMI'+_.nCId; 24_.sPyiName = 'clsPYI'+_.nCId; 25_.sNyiName = 'clsNYI'+_.nCId; 26_.sPmaName = 'clsPMA'+_.nCId; 27_.sNmaName = 'clsNMA'+_.nCId; 28_.sPyaName = 'clsPYA'+_.nCId; 29_.sNyaName = 'clsNYA'+_.nCId; 30_.oChiefDate = new Date(); 31 32_.sChiefFormat = !oSettings.dateFormat ? 'm/d/Y' : oSettings.dateFormat; 33_.oApp = oSettings['appearance']; 34gBuildControl(_); 35} 36function gBuildControl(_) { 37var oWbuf = new writer(); 38oWbuf.into ('<table cellpadding="0" cellspacing="0" border="0" ><tr><td><input type="Text" id="' , _.sNameControl , '" name="' , _.sNameControl , '" value="" class ="',_.oApp['DataArea'],'" ></td><td align="right" width="25"><a href="javascript:gDisplayCalendar(agC[' + _.nCId + ']);" ><img src="',_.oApp['IcoCalVis'],'" alt="" name="'+ _.sIcoName +'" id="'+ _.sIcoName +'" width="23" height="19" border="0"></a></td></tr></table>'); 39//<tr><td align="left" colspan="2"><img src="img/spacer.gif" alt="" name="'+ _.sPosName +'" id="'+ _.sPosName +'" width="1" height="1" border="0"></td></tr> 40document.write(oWbuf.out()); 41gBuildCalendar(_); 42gSetControl(_); 43gUpdateCalendarControl(_); 44} 45function gBuildCalendar(_){ 46var oWbuf = new writer(); 47oWbuf.into('<div id="',_.sDivName,'" name="',_.sDivName,'" style="position: absolute; background-color:beige; visibility:hidden; width:186; height:1; z-index: ',_.nCId+1,'"><table width="100%" cellpadding="0" cellspacing="1" border="0" class="',_.oApp['OuterFrame'],'"><tr><td ><table width="100%" cellpadding="0" cellspacing="0" border="0" class="',_.oApp['InnerFrame'],'" ><tr><td colspan="3" class="',_.oApp['TopPartNavpanel'],'"><img src="img/spacer.gif" width="1 px" height="1 px"></td></tr><tr><td width="100%" colspan="3" class="',_.oApp['Navpanel'],'"><table cellpadding="1" cellspacing="1" border="0" ><tr><td><a href="#" name="',_.sPyaName,'" id="',_.sPyaName,'"><img src="',_.oApp['PrevYear'],'" alt="',_.oApp['messages']['AltPrevYear'],'" name="',_.pyiName,'" id="',_.pyiName,'" width="18" height="21" border="0"></a></td><td><a href="#" name="',_.sPmaName,'" id="',_.sPmaName,'"><img src="',_.oApp['PrevMonth'],'" alt="',_.oApp['messages']['AltPrevMonth'],'" name="',_.sPmiName,'" id="',_.sPmiName,'" width="18" height="21" border="0"></a></td><td width="100%" class="',_.oApp['InfoTitle'],'" id="',_.sTitleName,'" name="',_.sTitleName,'">',_.oApp['longmonth'][_.oChiefDate.getMonth()],' ',_.oChiefDate.getFullYear(),'</td><td><a href="#" name="',_.sNmaName,'" id="',_.sNmaName,'"><img src="',_.oApp['NextMonth'],'" alt="',_.oApp['messages']['AltNextMonth'],'" name="',_.sNmiName,'" id="',_.sNmiName,'" width="18" height="21" border="0"></a></td><td><a href="#" name="',_.sNyaName,'" id="',_.sNyaName,'"><img src="',_.oApp['NextYear'],'" alt="',_.oApp['messages']['AltNextYear'],'" name="',_.sNyiName,'" id="',_.sNyiName,'" width="18" height="21" border="0"></a></td></tr></table></td></tr><tr><td colspan="3" class="',_.oApp['BottomPartNavpanel'],'"><img src="img/spacer.gif" width="1 px" height="1 px"></td></tr><tr class="',_.oApp['MidRow'],'"><td><img src="img/spacer.gif" width="4 px"height="1 px"></td><td align="center" id="',_.sBoxName,'" name="',_.sBoxName,'">',gUnitedGrid(_),'</td><td width="4 px"><img src="img/spacer.gif" width="4 px" height="1 px"></td></tr><tr><td colspan="3" class="',_.oApp['BottomPartNavpanel'],'"><img src="img/spacer.gif" width="1 px" height="1 px"></td></tr></table></td ></tr></table></div>'); 48if(ogB.ie6){
49oWbuf.into('<iframe id="IE6bug',_.sDivName,'" src="img/spacer.gif" name="IE6bug',_.sDivName,'" style="position: absolute; left:0; top:0; width:0; height:0; visibility:hidden; filter:alpha(opacity=0); z-index: ' ,_.nCId, '"></iframe>'); 50} 51document.write(oWbuf.out()); 52} 53function gDateReset(oInDate){ 54var oTmpDate = oInDate ? new Date(oInDate) : new Date(); 55oTmpDate.setHours(0);oTmpDate.setMinutes(0);oTmpDate.setSeconds(0);oTmpDate.setMilliseconds(0); 56return oTmpDate; 57} 58function gDateType(c,oInDate){ 59var nResType = 1,oTmpDate = new Date(oInDate); 60oTmpDate = gDateReset(oTmpDate); 61var oChiefDateTmp = c.oChiefDate; 62if (gDateReset(oChiefDateTmp).valueOf() == oTmpDate.valueOf()) nResType |= 2; 63if (oTmpDate.getMonth() != oChiefDateTmp.getMonth() || oTmpDate.getFullYear() != oChiefDateTmp.getFullYear()) nResType |= 8; 64if (oTmpDate.getDay() == 0 || oTmpDate.getDay() == 6) nResType |= 4; 65return nResType; 66} 67function gDisplayCalendar(_) { 68var sVis = String(_.oDiv.style.visibility).toLowerCase(); 69if (sVis == 'visible' || sVis == 'show') { 70_.oDiv.style.visibility = 'hidden'; 71if(ogB.ie6) {_.oDiv2.style.visibility = 'hidden';} 72_.oIco.src = _.oApp['IcoCalVis']; 73} 74else { 75gRePosition(_); 76if(gVerifyDataArea(_))gUpdateCalendarData(_); 77_.oDiv.style.visibility = 'visible'; 78if(ogB.ie6) { 79_.oDiv2.style.width = _.oDiv.offsetWidth; 80_.oDiv2.style.height = _.oDiv.offsetHeight; 81_.oDiv2.style.visibility = 'visible'; 82} 83_.oIco.src = _.oApp['IcoCalUnVis']; 84} 85} 86function gUserClickHandler(_,inDa,typeClick) { 87var tmpDa = inDa ? new Date(inDa) : new Date(_.oChiefDate); 88_.oChiefDate = new Date(tmpDa); 89if(!typeClick) {gDisplayCalendar(_);_.oDataArea.value = oD.GenerateDate(_.oChiefDate,_.sChiefFormat);} 90gUpdateCalendarData(_); 91} 92function gUpdateCalendarData(_){ 93gUpdateCalendarControl(_); 94_.oInfoTitle.innerHTML = _.oApp['longmonth'][_.oChiefDate.getMonth()]+' '+_.oChiefDate.getFullYear(); 95_.oUnitedGrid.innerHTML = ''; 96_.oUnitedGrid.innerHTML = gUnitedGrid(_); 97} 98function gSetControl(_){ 99var oTmpDate; 100_.oDiv = gObja(_,_.sDivName); 101if(ogB.ie6) _.oDiv2 = gObja(_,'IE6bug'+_.sDivName); 102_.oIco = gObja(_,_.sIcoName); 103_.oPos = gObja(_,_.sPosName); 104_.oDataArea = gObja(_,_.sNameControl); 105_.oUnitedGrid = gObja(_,_.sBoxName); 106_.oInfoTitle = gObja(_,_.sTitleName); 107_.oPMI = gObja(_,_.sPmiName); 108_.oNMI = gObja(_,_.sNmiName); 109_.oPYI = gObja(_,_.pyiName); 110_.oNYI = gObja(_,_.sNyiName); 111_.oPMA = gObja(_,_.sPmaName); 112_.oNMA = gObja(_,_.sNmaName); 113_.oPYA = gObja(_,_.sPyaName); 114_.oNYA = gObja(_,_.sNyaName); 115} 116function gShiftDate (oInDate, sShiftYear, sShiftMonth ,sShiftHour,sShiftMinute,sShiftSecond) { 117var oTmpDate = new Date(oInDate); 118if (sShiftYear) oTmpDate.setFullYear(oTmpDate.getFullYear() + sShiftYear); 119if (sShiftMonth) {oTmpDate.setMonth(oTmpDate.getMonth() + sShiftMonth);} 120if (sShiftHour) {oTmpDate.setHours(oTmpDate.getHours() + sShiftHour);} 121if (sShiftMinute) {oTmpDate.setMinutes(oTmpDate.getMinutes() + sShiftMinute);} 122if (sShiftSecond) {oTmpDate.setSeconds(oTmpDate.getSeconds() + sShiftSecond);} 123if(!(sShiftHour||sShiftMinute||sShiftSecond)) { 124if (oTmpDate.getDate() != oInDate.getDate()) {oTmpDate.setDate(0);} 125} 126return oTmpDate.valueOf(); 127} 128function gUpdateCalendarControl(_){ 129_.oPYA.href = "javascript: gUserClickHandler(agC["+_.nCId+"],"+gShiftDate (_.oChiefDate,-1)+",2);"; 130_.oNYA.href = "javascript: gUserClickHandler(agC["+_.nCId+"],"+gShiftDate (_.oChiefDate,1)+",2);"; 131_.oPMA.href = "javascript: gUserClickHandler(agC["+_.nCId+"],"+gShiftDate (_.oChiefDate,null,-1)+",1);"; 132_.oNMA.href = "javascript: gUserClickHandler(agC["+_.nCId+"],"+gShiftDate (_.oChiefDate,null,1)+",1);"; 133} 134function gVerifyDataArea(_){ 135if (_.oDataArea.value) { 136oTmpDate = oD.ParseDate(_.oDataArea.value+'',_.sChiefFormat); 137if(!oTmpDate) { 138//alert(_.oApp['messages']['Warning']); 139oTmpDate=new Date() 140}; 141if(oTmpDate.valueOf() != _.oChiefDate.valueOf()) { 142_.oChiefDate = new Date(oTmpDate); 143return true; 144} 145else { 146_.oDataArea.value = oD.GenerateDate(_.oChiefDate,_.sChiefFormat); 147return false; 148} 149} 150else return false; 151} 152function gDayTitle (o) { 153var oWbuf = new writer(); 154oWbuf.into('<tr class="',o.oApp['WeekDay'],'">'); 155for (var nWD = 0; nWD < 7; nWD++) oWbuf.into('<td>',o.oApp.weekdays[(nWD+1)%7],'</td>'); 156oWbuf.into('</tr>'); 157return(oWbuf.out()); 158} 159function gDayGrid(a){ 160var oWbuf = new writer(),oFDay = new Date(a.oChiefDate); 161oFDay.setDate(1); 162oFDay.setDate(1 - (6 + oFDay.getDay()) % 7); 163var oTDay = new Date(oFDay); 164while (oTDay.getMonth() == a.oChiefDate.getMonth() || oTDay.getMonth() == oFDay.getMonth()) { 165oWbuf.into('<tr>'); 166for (var nWD = 0; nWD < 7; nWD++) { 167oWbuf.into(gDayCell(a,oTDay)); 168oTDay.setDate(oTDay.getDate() + 1); 169} 170oWbuf.into('</tr>\n'); 171} 172return(oWbuf.out()); 173} 174function gUnitedGrid(_){ 175var oWbuf = new writer(); 176oWbuf.into('<table cellpadding="2" cellspacing="1" border="0" width="100%" class="',_.oApp['DateGrid'],'">'); 177oWbuf.into(gDayTitle(_));
178oWbuf.into(gDayGrid(_)); 179oWbuf.into('</table>'); 180return(oWbuf.out()); 181} 182function _UserAgent() { 183var _ = this,br = navigator.appName,v = _.version = navigator.appVersion,ua=_.uas = navigator.userAgent.toLowerCase(),re_num = /opera/; 184_.op = re_num.exec(ua)?true:false; 185_.ie = (br == "Microsoft Internet Explorer"); 186if(_.op) {_.ie = false;} 187_.v = parseInt(v); 188if (_.ie) { 189_.ie4 = _.ie5 = _.ie55 = _.ie6 = false; 190if (v.indexOf('MSIE 6') > 0) {_.ie6 = true; _.v = 6;} 191} 192_.win32 = ua.indexOf("win")>-1; 193_.mac = ua.indexOf("mac")>-1; 194} 195function dmMakeWorkTemplate(inFormat){ 196var _=this,sCh,nKey=0,aTmp=[],aDel=["\\\\","\\/","\\.","\\+","\\*","\\?","\\$","\\^","\\|"]; 197for(nI = 0; nI < inFormat.length; nI ++){ 198sCh = inFormat.substr(nI,1); 199if(_.dmFormatChar.indexOf(sCh) != -1 && sCh != ''){ 200aTmp[nKey]=sCh; 201_.dmTmpFormat[nKey++]=sCh; 202} 203} 204nKey=1; 205for(nI in aDel) { 206try{inFormat=inFormat.replace(eval("/"+aDel[nI]+"/g"),aDel[nI]);}catch (e){} 207} 208for(nI=0;nI<aTmp.length;nI++){ 209re=new RegExp(aTmp[nI]); 210inFormat=inFormat.replace(re,_.dmRegFormatChar[aTmp[nI]]) 211} 212return new RegExp("^"+inFormat.replace(/\s+/g,"\\s+")+"$"); 213} 214function dmGenerateDate(inData,inFormat){ 215var _=this,nKeyCh,nI=0,sTr='',sTo='',dt_d=new Date(inData); 216do{ 217nKeyCh = inFormat.substr(nI,1); 218if(_.dmFormatChar.indexOf(nKeyCh)!=-1&&nKeyCh!=''){ 219if(typeof(dt_d[_.dmCallChar[nKeyCh][1]])!='function') sTo=new String(_.dmCallChar[nKeyCh][1](dt_d)); 220else sTo=new String(dt_d[_.dmCallChar[nKeyCh][1]]()); 221sTr+=sTo 222} 223else sTr+=nKeyCh; 224nI++ 225} while (nI < inFormat.length) 226return sTr; 227} 228function dmParseDate(oInDate,inFormat){ 229/* 230var _=this,aOut = [], nI, nK = 1,workTemplate = _.MakeWorkTemplate(inFormat),tmpData= _.DateReset(),nI,flag_date = false,oDate=null,tmpData = new Date(0,0,1),chKey,oRe = workTemplate.exec(oInDate); 231if (!oRe || typeof(oRe) != 'object') { 232return null; 233} 234for (nI in _.dmTmpFormat) { 235aOut[nI] = [oRe[nK++], _.dmTmpFormat[nI]] 236} 237oAdate = aOut; 238for(nI in oAdate){ 239if(_.dmSignFormatChar.indexOf(oAdate[nI][1])!=-1){ 240 chKey=oAdate[nI][1]; 241 var oTmp=_.dmCallChar[oAdate[nI][1]][2](oAdate[nI][0]); 242 if(chKey == 'd') { chDate = chKey; oDate = oTmp;} 243 tmpData[_.dmCallChar[chKey][0]](oTmp); 244 if(oDate) tmpData[_.dmCallChar[chDate][0]](oDate); 245} 246} 247return tmpData; 248*/ 249 var o=new Date(); 250 o.setMonth(parseInt(oInDate.substr(3, 2), 10)-1); 251 o.setDate(parseInt(oInDate.substr(0, 2), 10)); 252 o.setFullYear(parseInt(oInDate.substr(6, 4), 10)); 253 return o; 254} 255 256function gDayCell(oB,oInDate){ 257var oTDay = new Date (oInDate),nTD = gDateType(oB,oTDay),stTName,sLink,sCell; 258if(nTD&2) stTName = 'SelectedDay'; 259else if(nTD&8) stTName = 'OtherMonthDay'; 260else stTName = 'CurrentMonthDay'; 261sLink = 'javascript: gUserClickHandler(agC['+oB.nCId+'],'+oInDate.valueOf()+');'; 262sCell = '<a href="'+sLink+'" class="'+oB.oApp[stTName]+'">' + oInDate.getDate() + '</a>'; 263if(nTD&2) stTName = 'SelectedDay'; 264else if(nTD&4) stTName = 'HoliDay'; 265else if(nTD&8) stTName = 'OtherMonthDay'; 266else stTName = 'WorkDay'; 267sCell = '<td class="'+oB.oApp[stTName+'Cell']+'" align="center">' + sCell + '</td>'; 268return sCell; 269} 270function _DManager(){ 271var _=this; 272_.dmFormatChar='dmY'; 273_.dmSignFormatChar='dmY'; 274_.dmRegFormatChar = {'d' : "([0-9]{0,2})",'m' : "([0-9]{0,2})",'Y' : "([0-9]{4})"}; 275_.dmCallChar={'d':['setDate',function(_v,_m){_v=_v.getDate();if(_v<10)return('0'+_v);else return _v},function(_v){return _v*1}],'m':['setMonth',function(_v){_v=_v.getMonth()+1;if(_v<10)return('0'+_v);else return _v},function(_v){return(_v*1-1)}],'Y':['setFullYear','getFullYear',function(_v){return _v*1}]}; 276_.dmTmpFormat =[]; 277_.DateReset = gDateReset; 278_.MakeWorkTemplate = dmMakeWorkTemplate; 279_.GenerateDate = dmGenerateDate; 280_.ParseDate = dmParseDate; 281} 282function gRePosition (_) { 283/* 284_.oDiv.style.left = gGlobalPosition(_,'Left')+'px'; 285_.oDiv.style.top = (gGlobalPosition(_,'Top')-272)+'px'; 286if(ogB.ie6){ 287_.oDiv2.style.left = _.oDiv.style.left; 288_.oDiv2.style.top = _.oDiv.style.top; 289} 290*/ 291_.oDiv.style.left="53px"; 292_.oDiv.style.top="102px"; 293if(ogB.ie6){ 294_.oDiv2.style.left = _.oDiv.style.left; 295_.oDiv2.style.top = _.oDiv.style.top; 296} 297} 298function gGlobalPosition (_,displace) { 299var nPos = 0, tPos = _.oPos; 300while (tPos) { 301nPos += tPos["offset" + displace]; 302tPos = tPos.offsetParent; 303} 304return nPos; 305} 306function gObja (_,_id) { 307if (document.images && document.images[_id]) return document.images[_id]; 308else if (_.formName && document.forms[_.formName].elements[_id]) return document.forms[_.formName].elements[_id]; 309else if (document.all && document.all[_id]) return document.all[_id]; 310else if (document.getElementById) return document.getElementById(_id); 311else return null; 312} 313function writer() { 314var _ = this; 315_.bufArray = []; 316_.into = function () { 317var n = arguments.length; 318for (var nI = 0; nI < n; nI++) 319_.bufArray[_.bufArray.length] = arguments[nI]; 320}; 321_.out = function () { 322return _.bufArray.join(''); 323};
324} 325
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.