var week_begins = 1; var thismonth = 01; var thisyear = 2006; var siteurl = 'http://www.lucazappa.com/wp'; var dateDay = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'); var dateDayShort = new Array('S', 'M', 'T', 'W', 'T', 'F', 'S'); var dateDayAbbr = new Array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); var dateMon = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'); var dateMonShort = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); var archives = 'Archives:'; var viewpostsfor_= 'View posts for %1$s %2$s'; function viewpostsfor(year,month) { return viewpostsfor_.replace('%1\$s',dateMon[month]).replace('%2\$s',year); } var unixmonth = new Date(thisyear,thismonth-1,1); unixmonth.setYear(thisyear); // to be sure it's a 4 digit value. var entries_cache=new Array(); var tocall; function addEvent(el,ev,fn){ if(el.attachEvent)el.attachEvent('on'+ev,fn); else if(el.addEventListener)el.addEventListener(ev,fn,false); } if(typeof window.XMLHttpRequest!='undefined') { if(navigator.userAgent.indexOf('KHTML')>0){ setTimeout('kcalendar_refresh()',2000); }else{ addEvent(window,'load',kcalendar_refresh); } } function kcalendar_build(year,month,day){ var today=new Date; shownDate=new Date(year,month,day); cal=document.createElement('table'); cal.id='wp-calendar'; // caption caption=document.createElement('caption'); caption.appendChild(document.createTextNode(dateMon[shownDate.getMonth()]+' '+shownDate.getFullYear())); cal.appendChild(caption); caption.id='wp-calendar_caption'; // draw day headers // 'var wd' value sets weekday display style; currently set to dateDayAbbr (Sun) // swap commenting on 'var wd' entries for weekday displays of either dateDayShort (S) or dateDay (Sunday) cal_head = document.createElement('THEAD'); cal.appendChild(cal_head); cal_row=cal_head.insertRow(0); cal_row.id='calendar_daysRow'; for(i=0;i<7;i++){ cal_cell = document.createElement('TH'); cal_row.appendChild(cal_cell); var wd = dateDayShort[(i+week_begins)%7]; // var wd = dateDayAbbr[(i+week_begins)%7]; // var wd = dateDay[(i+week_begins)%7]; cal_cell.appendChild(document.createTextNode(wd)); cal_cell.abbr =wd; cal_cell.title=wd; cal_cell.scope='col'; } // draw navigation row month cal_foot = document.createElement('TFOOT'); cal.appendChild(cal_foot); cal_row=cal_foot.insertRow(0); cal_cell=cal_row.insertCell(0); link_year=shownDate.getFullYear(); link_month=shownDate.getMonth()-1; if(link_month==-1){link_month=11;link_year--;} link=document.createElement('a'); link.appendChild(document.createTextNode(String.fromCharCode(171)+' ' + dateMonShort[link_month])); link.href='javascript:kcalendar_refresh('+link_year+','+(link_month+1)+');'; link.title = viewpostsfor(link_year,link_month) cal_cell.appendChild(link); cal_cell.colSpan=3; cal_cell.abbr=dateMonShort[link_month]; cal_cell.id='prev' cal_cell=cal_row.insertCell(1); cal_cell.id='pad'; spinner = document.createElement('IMG'); spinner.id='calendar_spin'; spinner.src = siteurl + '/wp-content/livecalendar/wait.gif'; cal_cell.appendChild(spinner); cal_cell=cal_row.insertCell(2); cal_cell.colSpan=3; cal_cell.id='pad'; link_year=shownDate.getFullYear(); link_month=shownDate.getMonth()+1; if(link_month==12){link_month=0;link_year++;} if(link_year1)cellDate-=7; // draw rest of month days_in_last_month=kcalendar_daysInMonth(shownDate.getFullYear(),shownDate.getMonth()-1); for(i=0;i<6;i++){ cal_row=cal_body.insertRow(i); for(j=0;j<7;j++){ cal_cell=cal_row.insertCell(j); class_to_show='faded'; if(cellDate<1){ num_to_show='';//days_in_last_month+cellDate; }else if(cellDate>kcalendar_daysInMonth(shownDate.getFullYear(),shownDate.getMonth())){ num_to_show='';//cellDate-kcalendar_daysInMonth(shownDate.getFullYear(),shownDate.getMonth()); }else{ num_to_show=cellDate; class_to_show=''; if(shownDate.getFullYear()==today.getFullYear() && shownDate.getMonth()==today.getMonth() && cellDate==today.getDate()){ class_to_show+=' today' } } cal_cell.appendChild(document.createTextNode(num_to_show)); cal_cell.className=class_to_show; cal_cell.id='kcalendar_'+shownDate.getFullYear()+'_'+(shownDate.getMonth()+1)+'_'+cellDate; cellDate++; } } tocall='kcalendar_'+(shownDate.getFullYear())+'_'+(shownDate.getMonth()); return cal; } // 'el2.href' determines the calendar's address structure for permalinks, currently set as siteurl/index.php?m=YYYYMMDD // swap commenting on el2.href entries if permalink addresses are set as siteurl/archive/YYYY/MM/DD/ function kcalendar_create_links(arr){ if(arr.length==0) return; for(i=0;i1){ split=split[0].split(/-/); text=el.childNodes[0]; el2=document.createElement('a'); el2.title= archives+' '+dateMon[split[1]-1]+ ' ' +split[0]; el2.appendChild(text); el2.href= siteurl +'/index.php?m='+split[0]+split[1]; // el2.href= siteurl +'/archives/'+split[0]+'/'+split[1]+'/'; el.appendChild(el2); } } function kcalendar_daysInMonth(year,month){ while(month<0){month+=12;year--} if(month==3||month==5||month==8||month==10)return 30; if(month!=1)return 31; if(!(year%4))return 29; return 28; } function kcalendar_refresh(year,month){ if(isNaN(year)){ year=unixmonth.getFullYear(); month=unixmonth.getMonth(); } else { month--; } while(month<0 ){month+=12;year--} while(month>11){month-=12;year++} el=document.getElementById('calendar'); if(!el) { el2=document.getElementById('wp-calendar'); if(el2){ el=document.createElement('div'); el.id='calendar'; el3=el2.parentNode; el3.insertBefore(el,el2); el3.removeChild(el2); el.appendChild(el2); } } if(!el) return; els=el.childNodes; for(i=el.childNodes.length-1;i>-1;i--)el.removeChild(els[i]); cal=kcalendar_build(year,month,1); el.appendChild(cal); // get any applicable links for the dates if(entries_cache[tocall]){ kcalendar_create_links(entries_cache[tocall]); el=document.getElementById('calendar_spin'); if(el) el.parentNode.removeChild(el); }else{ var req = new XMLHttpRequest(); if (req) { req.onreadystatechange=function(){ if(req.readyState==4&&req.status==200) { entries_cache[tocall]=(req.responseText)? req.responseText.split(/\n/): []; kcalendar_create_links(entries_cache[tocall]); el=document.getElementById('calendar_spin'); if(el) el.parentNode.removeChild(el); } }; req.open('GET', siteurl + '/wp-content/livecalendar/kcalendar.php?year='+shownDate.getFullYear()+'&month='+(shownDate.getMonth()+1)); if(navigator.userAgent.indexOf('KHTML')==-1)req.send(null); else req.send(); } } }