Calendar events from XHTML

·
Inspired by Jon Udell's attempt at embedding calendar events and lifting data from XHTML pages, I made the little thingummy below which should work in most browsers. I think the idea is that if you add lots of metadata/markup to your XHTML, people can come along with their bookmarklets and gather it up for their own uses.

Click on an event to generate an ics file (bear in mind that the timezone is UTC):

Red Sox vs Fenway Park
Fenway Park
1800 - 2100
Blu Sox vs Fenway Drive
Blu Park
1700 - 1900

Is it easier than just making a link with the data in the URL? I don't know, but it certainly seems juicier... Here's the code:


<script type="text/javascript">
function getCal(node){
node.style.background = "#999999";
var calStartDate = node.getAttribute("cal:startDate");
var calEndDate = node.getAttribute("cal:endDate");
for (var i = 0; i < node.childNodes.length; i++){
	var t = node.childNodes[i];
	if ( t.hasAttributes("class") ){
		var c = t.getAttribute("class");
		var v = t.firstChild.nodeValue;
		if ( c == "cal:name" ){ var calName = v };
		if ( c == "cal:location" ){ var calLocation = v };
		if ( c == "cal:startTime" ){ var calStartTime = v };
		if ( c == "cal:endTime" ){ var calEndTime = v };
	}
}
document.location.href= "http://event.openam.com?timezone=UTC&summary=" + calName + "&start_date=" + calStartDate + "&start_time=" + calStartTime + "&stop_date=" + calEndDate + "&stop_time=" + calEndTime + "&format=.ics";
}
</script>