Last active
April 11, 2016 19:34
-
-
Save luanrm/3a0b5744e6fc8b6d5dc1ee53cf4849df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var CLIENT_ID = web.client_id; | |
var SCOPES = ["https://www.googleapis.com/auth/calendar"]; | |
function checkAuth() { | |
gapi.auth.authorize( | |
{ | |
'client_id': CLIENT_ID, | |
'scope': SCOPES.join(' '), | |
'immediate': true | |
}, handleAuthResult); | |
} | |
function handleAuthResult(authResult) { | |
var authorizeDiv = document.getElementById('authorize-div'); | |
if (authResult && !authResult.error) { | |
authorizeDiv.style.display = 'none'; | |
loadCalendarApi(); | |
} else { | |
authorizeDiv.style.display = 'inline'; | |
} | |
} | |
function handleAuthClick(event) { | |
gapi.auth.authorize( | |
{client_id: CLIENT_ID, scope: SCOPES, immediate: false}, | |
handleAuthResult); | |
return false; | |
} | |
function loadCalendarApi() { | |
gapi.client.load('calendar', 'v3', listUpcomingEvents); | |
} | |
function listUpcomingEvents() { | |
var event = { | |
'summary': 'ocupado', | |
'start': { | |
'dateTime': '2016-04-16T09:00:00-07:00', | |
'timeZone': 'America/Los_Angeles' | |
}, | |
'end': { | |
'dateTime': '2016-04-16T17:00:00-07:00', | |
'timeZone': 'America/Los_Angeles' | |
} | |
}; | |
var request = gapi.client.calendar.events.update({ | |
'calendarId': 'primary', | |
'eventId' : '91omdjkqse514b05uubben1npc', | |
'resource': event | |
}); | |
request.execute(function(event) { | |
appendPre('Event created: ' + event.htmlLink); | |
}); | |
} | |
function appendPre(message) { | |
var pre = document.getElementById('output'); | |
var textContent = document.createTextNode(message + '\n'); | |
pre.appendChild(textContent); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment