//http://lvchen.blogspot.com/feeds/posts/summary?published-min=2008-05-01T00%3A00%3A00-05%3A00&published-max=2008-06-01T00%3A00%3A00-05%3A00&max-results=90
//http://lvchen.blogspot.com/search?updated-min=2008-05-18T00%3A00%3A00-05%3A00&updated-max=2008-05-19T00%3A00%3A00-05%3A00&max-results=50
//this will get one post only
//http://bartstalk.blogspot.com/2006/07/blogger-calendar-ie.html
// How do I know I have load enough post of that month? Do a check and run the json-in-script again.
/* ========================================================
Defined all methods and variables --> parameters, and setting
=========================================================== */
function ArchiveCalendar()
{
this.PrevMonth=PrevMonth; //function, go to previous month
this.NextMonth=NextMonth; //funciton, go to next month
this.refreshTable=refreshTable; //function, refresh table
this.drawTable=drawTable; // function, draw a new table when first load
this.Calendar=Calendar; // function, return a new month, based on user's behavior
this.fetchposts=fetchposts; // function, get Google API JSON feed
this.addLink=addLink; // function, callback for Google API
this.monthTable= monthTable; // function, go to specific month (selected table)
this.yearTable=yearTable; // function, go to specific year (input)
this.week_label = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");
this.month_label_real = new Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
this.month_label = new Array("01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12");
this.month_days = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
this.today = new Date(); // Today's date, shouldn't be change
this.cur_day = new Date(); // Specific date, change accordingly
this.startDay = 0; // The first day of the month, indicate the index of calendar table(td element)
this.base='lvchen.blogspot.com';// The weblog's URL, preset itis better than auto detection.
this.timeZone = '+08:00'; // Timezone is always a problem, this is the true timezone, without daylight saving. If one blog had changed the location, the calendar may fail for some past month. Let's cross our fingures.
this.timeZoneCheck = false; // Special setting for daylight saving country. Might work well for the previously described situation. Set it to "true" for timezone auto detection for each article.
this.alignFooter = true;
this.loading = '
'; // loading info, HTML format.
}
/*============================================
Return a new month, based on user's behavior
==============================================*/
function Calendar(date_obj) {
var year = date_obj.getFullYear(); // This year
var thisMonth = Calendar.month_label[date_obj.getMonth()]+''; //get month label
var nDays = Calendar.month_days[date_obj.getMonth()]; // how many days in the month
var thisDay = Calendar.today.getDate(); // today's date
if (date_obj.getMonth() == 1 &&(((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0))) {//determine Leap Day.
nDays = 29;
Calendar.month_days[1] = '29';
}
else
Calendar.month_days[1] = '28'; // this is necessary if we want to access Calendar.month_days[] from other function
var dymDate = date_obj; //make a backup date obj
dymDate.setDate(1); // set to the first day to look for its location of this month
Calendar.startDay = dymDate.getDay();// set to the first day to look for its location of this month
var out=''; // starting making calendar table
out+='
| '+ Calendar.week_label[index]+' | '; } out+=''; tab_col++; } for (index=1;index<=nDays;index++) { // now filling other day into table if (tab_col==0) out+=' |
|---|---|
| '+ index + ' | '; else out+='' + index +' | '; if (tab_col==6) { out+=''; } out+=''; } out+=' |
| << | '; link += ''; link += ' | >> |
Add this Calendar to your blog
'; footer.innerHTML = msg; // Now put the whole table into "blogCalendar" container var calendarDiv = document.getElementById('blogCalendar'); calendarDiv.style.textAlign = 'center'; calendarDiv.appendChild(tableCaption); calendarDiv.appendChild(cell); calendarDiv.appendChild(footer); // Parameter need to be correct http://www.fileformat.info/info/unicode/char/search.htm?q=-&preview=entity if (Calendar.timeZone.length < 4 && Calendar.timeZone!='Z') Calendar.timeZone = Calendar.timeZone+ ':00'; Calendar.timeZone = encodeURIComponent(Calendar.timeZone); Calendar.timeZone = Calendar.timeZone.replace(/\-/,'%2D'); Calendar.refreshTable(); // Now flesh Table } /* ========================================== Reflesh table, putting information into table ============================================= */ function refreshTable() { var loading = document.getElementById('CalLoading'); loading.style.display = 'inline'; var theMonth = Calendar.cur_day.getMonth(); var theYear = Calendar.cur_day.getFullYear(); document.getElementById('CalendarMonth').innerHTML = ''+Calendar.month_label_real[theMonth] +' ' + ''+theYear+''; document.getElementById('CalendarTable').innerHTML = Calendar.Calendar(Calendar.cur_day); var setyearInput = document.getElementById('yearSelect'); var setmonthTable = document.getElementById('monthTable'); if (Calendar.today >= Calendar.cur_day) { var cellArray = document.getElementById('CalendarCaption').getElementsByTagName('a'); // cancal link cellArray[0].setAttribute('href', 'javascript:void(0)'); cellArray[1].setAttribute('href', 'javascript:void(0)'); var cellArray = document.getElementById('CalendarFooter').getElementsByTagName('a'); // cancal link cellArray[0].setAttribute('href', 'javascript:void(0)'); setmonthTable.style.display = 'none'; setyearInput.style.display = 'none'; Calendar.fetchposts(theYear,theMonth,1); } else { loading.style.display = 'none'; setmonthTable.style.display = 'inline'; setyearInput.style.display = 'inline'; } at_attach("monthTable_parent", "monthTable", "click", "y", "pointer"); at_attach("yearSelect_parent", "yearSelect", "click", "y", "pointer"); } /* ==================================== Go to specific month (selected table) ======================================= */ function monthTable(month){ Calendar.cur_day.setMonth(month); Calendar.refreshTable(); } /* ============================== Go to specific year (input) ================================= */ function yearTable(year){ Calendar.cur_day.setYear(year); Calendar.refreshTable(); } // Adding new object Calendar = new ArchiveCalendar(); // The following code are used for dropdown menu. I found it here: //http://www.dynamicdrive.com/dynamicindex1/dropdowncontrol.htm // Copyright (C) 2005-2008 Ilya S. Lyubinskiy. All rights reserved. // Technical support: http://www.php-development.ru/ // // YOU MAY NOT // (1) Remove or modify this copyright notice. // (2) Re-distribute this code or any part of it. // Instead, you may link to the homepage of this code: // http://www.php-development.ru/javascripts/dropdown.php // // YOU MAY // (1) Use this code on your website. // (2) Use this code as part of another product. // // NO WARRANTY // This code is provided "as is" without warranty of any kind. // You expressly acknowledge and agree that use of this code is at your own risk. // ***** Popup Control ********************************************************* // ***** at_show_aux ***** function at_show_aux(parent, child) { var p = document.getElementById(parent); var c = document.getElementById(child ); var top = (c["at_position"] == "y") ? p.offsetHeight+2 : 0; var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0; for (; p; p = p.offsetParent) { top += p.offsetTop; left += p.offsetLeft; } c.style.position = "absolute"; c.style.top = top +'px'; c.style.left = left+'px'; c.style.visibility = "visible"; } // ***** at_show ***** function at_show() { var p = document.getElementById(this["at_parent"]); var c = document.getElementById(this["at_child" ]); at_show_aux(p.id, c.id); clearTimeout(c["at_timeout"]); } // ***** at_hide ***** function at_hide() { var p = document.getElementById(this["at_parent"]); var c = document.getElementById(this["at_child" ]); c["at_timeout"] = setTimeout("document.getElementById('"+c.id+"').style.visibility = 'hidden'", 333); } // ***** at_click ***** function at_click() { var p = document.getElementById(this["at_parent"]); var c = document.getElementById(this["at_child" ]); if (c.style.visibility != "visible") at_show_aux(p.id, c.id); else c.style.visibility = "hidden"; return false; } // ***** at_attach ***** // PARAMETERS: // parent - id of the parent html element // child - id of the child html element that should be droped down // showtype - "click" = drop down child html element on mouse click // "hover" = drop down child html element on mouse over // position - "x" = display the child html element to the right // "y" = display the child html element below // cursor - omit to use default cursor or specify CSS cursor name function at_attach(parent, child, showtype, position, cursor) { var p = document.getElementById(parent); var c = document.getElementById(child); p["at_parent"] = p.id; c["at_parent"] = p.id; p["at_child"] = c.id; c["at_child"] = c.id; p["at_position"] = position; c["at_position"] = position; c.style.position = "absolute"; c.style.visibility = "hidden"; var formtest = c.childNodes; for (var i = 0 ; i < formtest.length ; i++){ if (formtest[i].nodeName=='FORM') break; } if (cursor != undefined) p.style.cursor = cursor; switch (showtype) { case "click": p.onclick = at_click; p.onmouseout = at_hide; c.onmouseover = at_show; if (i == formtest.length) c.onmouseout = at_hide; break; case "hover": p.onmouseover = at_show; p.onmouseout = at_hide; c.onmouseover = at_show; if (i == formtest.length) c.onmouseout = at_hide; break; } }