This commit is contained in:
Arjun Patel
2017-10-07 03:56:20 -07:00
parent 2db68ba519
commit 078926bbd7
3 changed files with 10 additions and 50 deletions
+2 -5
View File
@@ -1,4 +1,4 @@
//console.log("hey"); console.log("hey");
function getInformation(information) function getInformation(information)
{ {
@@ -51,7 +51,7 @@ function getInformation(information)
timePortion2 = hour + elements[3].substring(2, 5); timePortion2 = hour + elements[3].substring(2, 5);
} }
} }
//console.log([elements[0], datePortion + "T" + timePortion1, datePortion + "T" + timePortion2]); console.log([elements[0], datePortion + "T" + timePortion1, datePortion + "T" + timePortion2]);
return [elements[0], datePortion + "T" + timePortion1, datePortion + "T" + timePortion2]; return [elements[0], datePortion + "T" + timePortion1, datePortion + "T" + timePortion2];
} }
@@ -92,7 +92,4 @@ function makeEvent(information)
'resource': event 'resource': event
}); });
request.execute(function(event) {
appendPre('Event created: ' + event.htmlLink);
});
} }
+1
View File
@@ -10,6 +10,7 @@
<body> <body>
<button id="authorize-button" style="opacity: 0;">asd</button> <button id="authorize-button" style="opacity: 0;">asd</button>
<button id="signout-button" style="opacity: 0;">Signout</button>
<div class="container main-bg" id="content"> <div class="container main-bg" id="content">
<div class="row"> <div class="row">
+7 -45
View File
@@ -1,6 +1,7 @@
var enterBtn = document.getElementById("enter"); var enterBtn = document.getElementById("enter");
var authorizeButton = document.getElementById('authorize-button'); var authorizeButton = document.getElementById('authorize-button');
var signoutButton = document.getElementById('signout-button');
enterBtn.addEventListener("click", captureInput); enterBtn.addEventListener("click", captureInput);
function captureInput() { function captureInput() {
@@ -17,6 +18,7 @@ function captureInput() {
if (command in dict) { if (command in dict) {
authorizeButton.click(); authorizeButton.click();
dict[command](input.substring(untilSpace+1)); dict[command](input.substring(untilSpace+1));
signoutButton.click();
} }
else { else {
console.log("not a valid command"); console.log("not a valid command");
@@ -24,7 +26,7 @@ function captureInput() {
} }
// Client ID and API key from the Developer Console // Client ID and API key from the Developer Console
var CLIENT_ID = '951578952608-igq1knaukc28hl3a7slj66l5lerijgue.apps.googleusercontent.com'; var CLIENT_ID = '951578952608-pnrc56tttl9dd2u67keg43hj5rhn6eid.apps.googleusercontent.com';
// Array of API discovery doc URLs for APIs used by the quickstart // Array of API discovery doc URLs for APIs used by the quickstart
var DISCOVERY_DOCS = ["https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest"]; var DISCOVERY_DOCS = ["https://www.googleapis.com/discovery/v1/apis/calendar/v3/rest"];
@@ -34,7 +36,7 @@ function captureInput() {
var SCOPES = "https://www.googleapis.com/auth/calendar"; var SCOPES = "https://www.googleapis.com/auth/calendar";
var authorizeButton = document.getElementById('authorize-button'); var authorizeButton = document.getElementById('authorize-button');
var signoutButton = document.getElementById('signout-button');
/** /**
* On load, called to load the auth2 library and API client library. * On load, called to load the auth2 library and API client library.
*/ */
@@ -58,6 +60,7 @@ function captureInput() {
// Handle the initial sign-in state. // Handle the initial sign-in state.
updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get()); updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
authorizeButton.onclick = handleAuthClick; authorizeButton.onclick = handleAuthClick;
signoutButton.onclick = handleSignoutClick;
}); });
} }
@@ -66,7 +69,6 @@ function captureInput() {
* appropriately. After a sign-in, the API is called. * appropriately. After a sign-in, the API is called.
*/ */
function updateSigninStatus(isSignedIn) { function updateSigninStatus(isSignedIn) {
console.log('hey');
} }
/** /**
@@ -76,46 +78,6 @@ function captureInput() {
gapi.auth2.getAuthInstance().signIn(); gapi.auth2.getAuthInstance().signIn();
} }
/** function handleSignoutClick(event) {
* Append a pre element to the body containing the given message gapi.auth2.getAuthInstance().signOut();
* as its text node. Used to display the results of the API call.
*
* @param {string} message Text to be placed in pre element.
*/
function appendPre(message) {
var pre = document.getElementById('content');
var textContent = document.createTextNode(message + '\n');
pre.appendChild(textContent);
}
/**
* Print the summary and start datetime/date of the next ten events in
* the authorized user's calendar. If no events are found an
* appropriate message is printed.
*/
function listUpcomingEvents() {
gapi.client.calendar.events.list({
'calendarId': 'primary',
'timeMin': (new Date()).toISOString(),
'showDeleted': false,
'singleEvents': true,
'maxResults': 10,
'orderBy': 'startTime'
}).then(function(response) {
var events = response.result.items;
appendPre('Upcoming events:');
if (events.length > 0) {
for (i = 0; i < events.length; i++) {
var event = events[i];
var when = event.start.dateTime;
if (!when) {
when = event.start.date;
}
appendPre(event.summary + ' (' + when + ')')
}
} else {
appendPre('No upcoming events found.');
}
});
} }