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
+16
View File
@@ -0,0 +1,16 @@
var mapsFrame = document.getElementById('map');
var searchBar = document.getElementById('search-cont');
function directionsURL(inCommand) {
var startOfTo = inCommand.indexOf("to");
var origin = inCommand.substring(0, startOfTo - 1).replace(" ", "+");
var dest = inCommand.substring(startOfTo+3).replace(" ", "+"); // "14872 Waverly Lane, Irvine, CA" to "14872 Waverly Lane+Irvine+CA"
var link = "https://www.google.com/maps/embed/v1/directions?key=AIzaSyCZCgZY7ZlSMk1DW0NEEoHZ9qwdSL4AR1k&origin="+origin+"&destination="+dest
mapsFrame.src = link;
mapsFrame.style.display = "block";
}
$(function() {
$('#search-cont').css({"-webkit-transform":"translate(100px,100px)"});
});
+8
View File
@@ -28,8 +28,16 @@
</div>
</div>
</div>
<iframe
height="100%"
width="100%"
id="map"
frameborder="0" style="border:0; display: none;"
src="https://www.google.com/maps/embed/v1/place?key=AIzaSyCZCgZY7ZlSMk1DW0NEEoHZ9qwdSL4AR1k&q=Eiffel+Tower,Paris+France" allowfullscreen>
</iframe>
</div>
<script type="text/javascript" src="google/maps.js"></script>
<script type="text/javascript" src="google/calendar.js"></script>
<script type="text/javascript" src="main.js"></script>
<script type="text/javascript" src="google/gauth.js"></script>
+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");
}
}