2009年7月14日火曜日

JavaScriptでGoogleCalendar修正版

修正版を作成してみた.

<html>
<head>
<img style="position:absolute; top: -1000px;" src="./dummy.gif">
<script type="text/javascript" src="http://www.google.com/jsapi?key=<i>YOURKEY</i>"></script>
<script type="text/javascript" src="./js/jquery"></script>
<script type="text/javascript">
<!--
google.load("gdata", "1");


function PRINT(src){
$("#message").html($("#message").html()+"<br>"+src);
}


function logMeIn() {
scope = "http://www.google.com/calendar/feeds/";
var chk = google.accounts.user.checkLogin(scope);
start();
}


function setupService(){
calendarService = new google.gdata.calendar.CalendarService('<i>APPLICATION-NAME</i>');
}

var calendarService;

function start(){
/*
* Retrieve all calendars
*/
setupService();
var feedUrl = 'http://www.google.com/calendar/feeds/default/allcalendars/full';

var handleError = function(error) {
PRINT(error);
}

calendarService.getAllCalendarsFeed(feedUrl, callback, handleError);
}


// The callback method that will be called when getAllCalendarsFeed() returns feed data
function callback(result) {
var entries = result.feed.entry;

for (var i = 0; i < entries.length; i++) {
var calendarEntry = entries[i];
var calendarTitle = calendarEntry.getTitle().getText();
PRINT('Calendar title = ' + calendarTitle);
}
}


//-->
</script>
</head>
<body>
<div id="message">
</div>
</body>

<input type="submit" value="login" onclick="logMeIn()">
</html>

Loginボタンを押すと,Loginしてカレンダーをすべて取得してくれます.

0 件のコメント: