This commit is contained in:
Arjun Patel
2017-10-07 17:40:52 -07:00
parent baa5a96070
commit 15e450d0e0
3 changed files with 37 additions and 9 deletions
+13 -9
View File
@@ -2,38 +2,42 @@ var enterBtn = document.getElementById("enter");
var authorizeButton = document.getElementById('authorize-button');
var signoutButton = document.getElementById('signout-button');
var createBtn = document.getElementById('create-event');
var runCommandBtn = document.getElementById('create-event');
enterBtn.addEventListener("click", captureInput);
var actualCommand = '';
var command = '';
function captureInput() {
var dict = {
"gcal": makeEvent,
"googlecalendar": makeEvent,
"mapsd": directionsURL,
"directions": directionsURL
};
var input = String(document.getElementById("input").value);
untilSpace = input.indexOf(' ');
var untilSpace = input.indexOf(' ');
command = input.substring(0, untilSpace);
console.log(command);
signoutButton.click();
if (command in dict) {
console.log('isAValidCommmand');
actualCommand = input.substring(untilSpace+1);
createBtn.addEventListener("click", function () {
console.log('successfully clicked createbtn');
makeEvent(actualCommand);
runCommandBtn.addEventListener("click", function () {
console.log('successfully ran command');
dict[command](actualCommand);
});
if (gapi.auth2.getAuthInstance().isSignedIn.get()) {
console.log('already signed in');
createBtn.click();
runCommandBtn.click();
}
else {
authorizeButton.click();
setTimeout(alert("Run Command again!"), 10000);
setTimeout(alert("Run Command again!"), 1000);
}
}
else {
console.log("not a valid command");
alert.log("Not a valid command");
}
}