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