Skip to content

Commit

Permalink
update dinner search and movie search code
Browse files Browse the repository at this point in the history
  • Loading branch information
wardcj1 committed Mar 22, 2017
1 parent a25e153 commit 0efb9c9
Show file tree
Hide file tree
Showing 7 changed files with 373 additions and 115 deletions.
109 changes: 70 additions & 39 deletions assets/js/dinner.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,72 @@
// https://developers.google.com/places/javascript/
// google places API key
// AIzaSyBOvLvUWU-_rQ1MpLYVQCcZ1byL-Prp1po
<!DOCTYPE html>
<html>
<head>
<title>Dinner Search</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
#floating-panel {
position: absolute;
top: 10px;
left: 25%;
z-index: 5;
background-color: #fff;
padding: 5px;
border: 1px solid #999;
text-align: center;
font-family: 'Roboto','sans-serif';
line-height: 30px;
padding-left: 10px;
}
</style>
</head>
<body>
<div id="floating-panel">
<input id="address" type="textbox" value="Zipcode">
<input id="submit" type="button" value="Submit">
</div>
<div id="map"></div>
<script>
function initMap() {
var map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 34.0620, lng: -118.4455},
zoom: 18
});
var geocoder = new google.maps.Geocoder();

function initialize() {
var pyrmont = new google.maps.LatLng(-33.8665, 151.1956);
document.getElementById('submit').addEventListener('click', function() {
geocodeAddress(geocoder, map);
});
}

var map = new google.maps.Map(document.getElementById('map'), {
center: pyrmont,
zoom: 15,
scrollwheel: false
});

// Specify location, radius and place types for your Places API search.
var request = {
location: pyrmont,
radius: '500',
types: ['store']
};

// Create the PlaceService and send the request.
// Handle the callback with an anonymous function.
var service = new google.maps.places.PlacesService(map);
service.nearbySearch(request, function(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
var place = results[i];
// If the request succeeds, draw the place location on
// the map as a marker, and register an event to handle a
// click on the marker.
var marker = new google.maps.Marker({
map: map,
position: place.geometry.location
});
}
}
});
}

// Run the initialize function when the window has finished loading.
google.maps.event.addDomListener(window, 'load', initialize);
function geocodeAddress(geocoder, resultsMap) {
var address = document.getElementById('address').value;
geocoder.geocode({'address': address}, function(results, status) {
if (status === 'OK') {
resultsMap.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: resultsMap,
position: results[0].geometry.location
});
} else {
alert('Geocode was not successful for the following reason: ' + status);
}
});
}
</script>
<script async defer
src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBOvLvUWU-_rQ1MpLYVQCcZ1byL-Prp1po&callback=initMap">
</script>
</body>
</html>
58 changes: 50 additions & 8 deletions assets/js/movie.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,44 @@
var movies = ["The Matrix", "The Notebook", "Mr. Nobody", "The Lion King"];
<!DOCTYPE html>
<html lang="en">

<head>
<meta charset="utf-8">
<title>Favorite Movies</title>
<style type="text/css">
button,
div,
form,
input {
margin: 10px;
}
</style>
</head>

<body>

<div class="container">
<h1>Movie Search</h1>

<button id="movieGen">Click this to spin</button>

<div id="movies-view"></div>

<script src="http://code.jquery.com/jquery-2.1.3.min.js"></script>
<script type="text/javascript">

var count = 0;
// array of movies
var movies = ["Moonlight", "La La Land", "Arrival", "Fences", "Hacksaw Ridge", "Hell or High Water", "Hidden Figures", "Lion", "Manchester by the Sea", "Logan", "Kong Skull Island", "John Wick Chapter 2", "xXx Return of Xander Cage", "A Dog’s Purpose", "T2 Trainspotting", " The Lego Batman Movie", "Rings", "Fifty Shades Darker", "Bitter Harvest", "In Dubious Battle"];

$("#movieGen").on("click", function() {

if(count === movies.length - 1) {
count=0;
};

// displayMovieInfo function re-renders the HTML to display the appropriate content
function displayMovieInfo() {

var movie = $(this).attr("data-name");
var queryURL = "https://api.themoviedb.org/3/movie/550?api_key=c851eec6c9c2ba8782875cf67bf47e5a";
// var queryURL = "http://www.omdbapi.com/?t=" + movie + "&y=&plot=short&r=json";
var queryURL = "http://www.omdbapi.com/?t=" + movies[count] + "&y=&plot=short&r=json";

// Creating an AJAX call for the specific movie button being clicked
$.ajax({
Expand Down Expand Up @@ -53,9 +86,18 @@ var movies = ["The Matrix", "The Notebook", "Mr. Nobody", "The Lion King"];
movieDiv.append(image);

// Putting the entire movie above the previous movies
$("#movie").prepend(movieDiv);
$("#movies-view").empty().append(movieDiv);
count++;

});

}
});
// if count === movies.lenth {
// count = 0;
// };

</script>
</div>
</body>

$(document).on("click", ".movie", displayMovieInfo);
</html>
71 changes: 71 additions & 0 deletions dinnerSearch.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<!DOCTYPE html>
<html>
<head>
<title>Place searches</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
<script>
// This example requires the Places library. Include the libraries=places
// parameter when you first load the API. For example:
// <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBOvLvUWU-_rQ1MpLYVQCcZ1byL-Prp1po&libraries=places">

var map;
var infowindow;

function initMap() {
var pyrmont = {lat: -33.867, lng: 151.195};

map = new google.maps.Map(document.getElementById('map'), {
center: pyrmont,
zoom: 15
});

infowindow = new google.maps.InfoWindow();
var service = new google.maps.places.PlacesService(map);
service.nearbySearch({
location: pyrmont,
radius: 500,
type: ['store']
}, callback);
}

function callback(results, status) {
if (status === google.maps.places.PlacesServiceStatus.OK) {
for (var i = 0; i < results.length; i++) {
createMarker(results[i]);
}
}
}

function createMarker(place) {
var placeLoc = place.geometry.location;
var marker = new google.maps.Marker({
map: map,
position: place.geometry.location
});

google.maps.event.addListener(marker, 'click', function() {
infowindow.setContent(place.name);
infowindow.open(map, this);
});
}
</script>
</head>
<body>
<div id="map"></div>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBOvLvUWU-_rQ1MpLYVQCcZ1byL-Prp1po&libraries=places&callback=initMap" async defer></script>
</body>
</html>
17 changes: 8 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<div class="container">
<!-- Trigger the modal with a button -->
<button type="button" class="jumbotron col-md-12" data-toggle="modal" data-target="#myModal">
<h1>Dinner Movie Dessert</h1>
<h1>Dinner Movie Dash</h1>
<br>-Click Me to get started-</button>
<!-- Modal -->
<div class="modal fade" id="myModal" role="dialog">
Expand Down Expand Up @@ -50,25 +50,24 @@ <h4 class="modal-title">I need to know some information from you friend</h4>
</div>
</div>
</div>
<h2 class="primaryColor">Spin the wheel to chill...</h2>
<h2 class="primaryColor">Spin the wheel and chill...</h2>
<div class="container">
<div class="row">
<div class="col-md-4 btn btn-danger" id="dinner">
<div class="col-md-6 btn btn-danger" id="dinner">
Dinner
</div>
<div class="col-md-4 btn btn-info movie" id="movie">
<div class="col-md-6 btn btn-info movie" id="movie">
Movie
</div>
<div class="col-md-4 btn btn-success" id="dessert">
<!-- <div class="col-md-4 btn btn-success" id="dessert">
Dessert
</div>
</div> -->
</div>
</div>
<hr>
<h3 class="secondaryColor">Helpful Links</h3>
<h4><a href="">Menu Items</a></h4>
<h3 class="secondaryColor">What to wear?</h3>
<h4><a href="">Weather</a></h4>
<h4><a href="">Email me</a></h4>
<!-- <h4><a href="">Email me</a></h4> -->

<script src="https://www.gstatic.com/firebasejs/3.7.3/firebase.js"></script>
</body>
Expand Down
35 changes: 35 additions & 0 deletions mapSearch.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<!DOCTYPE html>
<html>
<head>
<title>Simple Map</title>
<meta name="viewport" content="initial-scale=1.0">
<meta charset="utf-8">
<style>
/* Always set the map height explicitly to define the size of the div
* element that contains the map. */
#map {
height: 100%;
}
/* Optional: Makes the sample page fill the window. */
html, body {
height: 100%;
margin: 0;
padding: 0;
}
</style>
</head>
<body>
<div id="map"></div>
<script>
var map;
function initMap() {
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 34.0620, lng: -118.4455},
zoom: 18
});
}
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyBOvLvUWU-_rQ1MpLYVQCcZ1byL-Prp1po&callback=initMap"
async defer></script>
</body>
</html>
Loading

0 comments on commit 0efb9c9

Please sign in to comment.