This commit is contained in:
PenguinRobert1 committed 2024-02-09 17:59:02 +00:00
1 parent 1d1487be96
commit e39bc2c559
8 files changed
+264

No files matched your search

Binary file not shown.
@@ -0,0 +1,5 @@
{
"projects": {
"default": "nyevents-77bd9"
}
}
@@ -0,0 +1,10 @@
{
"hosting": {
"public": "public",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
]
}
}
@@ -0,0 +1,33 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Page Not Found</title>
<style media="screen">
body { background: #ECEFF1; color: rgba(0,0,0,0.87); font-family: Roboto, Helvetica, Arial, sans-serif; margin: 0; padding: 0; }
#message { background: white; max-width: 360px; margin: 100px auto 16px; padding: 32px 24px 16px; border-radius: 3px; }
#message h3 { color: #888; font-weight: normal; font-size: 16px; margin: 16px 0 12px; }
#message h2 { color: #ffa100; font-weight: bold; font-size: 16px; margin: 0 0 8px; }
#message h1 { font-size: 22px; font-weight: 300; color: rgba(0,0,0,0.6); margin: 0 0 16px;}
#message p { line-height: 140%; margin: 16px 0 24px; font-size: 14px; }
#message a { display: block; text-align: center; background: #039be5; text-transform: uppercase; text-decoration: none; color: white; padding: 16px; border-radius: 4px; }
#message, #message a { box-shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24); }
#load { color: rgba(0,0,0,0.4); text-align: center; font-size: 13px; }
@media (max-width: 600px) {
body, #message { margin-top: 0; background: white; box-shadow: none; }
body { border-top: 16px solid #ffa100; }
}
</style>
</head>
<body>
<div id="message">
<h2>404</h2>
<h1>Page Not Found</h1>
<p>The specified file was not found on this website. Please check the URL for mistakes and try again.</p>
<h3>Why am I seeing this?</h3>
<p>This page was generated by the Firebase Command-Line Interface. To modify it, edit the <code>404.html</code> file in your project's configured <code>public</code> directory.</p>
</div>
</body>
</html>
@@ -0,0 +1,2 @@
# ClusterTruckProject
Single page web app created as part of the ClusterTruck interview process
@@ -0,0 +1,46 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="https://www.gstatic.com/firebasejs/4.6.2/firebase.js"></script>
<script>
// Initialize Firebase
var config = {
apiKey: "AIzaSyCooDk0ln_ccwCuCUX9LtHC019vdYCSxWc",
authDomain: "nyevents-77bd9.firebaseapp.com",
databaseURL: "https://nyevents-77bd9.firebaseio.com",
projectId: "nyevents-77bd9",
storageBucket: "",
messagingSenderId: "73094720751"
};
firebase.initializeApp(config);
</script>
<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDAfDnbONaf2dEAsFIR4JEb2WolXTqsdgc&callback=initMap"
async defer>
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="markers.js"></script>
<link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="styles.css"/>
</head>
<body>
<div id="title">
<div id="titleWords">
<h1>ClusterTruck Take Home Problem</h1>
<h2>Created by: Logan Schiessle</h2>
</div>
<div class="facetDrop">
<button class="facetButton">Facet Category Options</button>
<div class="facetDrop-content">
<input type="radio" name="facet" value="none" onchange="changeFacet(-1)" checked> None <br>
<input type="radio" name="facet" value="0" onchange="changeFacet(0)"> 0 <br>
<input type="radio" name="facet" value="1" onchange="changeFacet(1)"> 1 <br>
</div>
</div>
</div>
<div id="map"></div>
</body>
</html>
@@ -0,0 +1,91 @@
var map;
var facetChoice;
var facetChosen = 0;
var sw;
var ne;
//Runs when the page is loaded, in order to create a google map with the center in New York City.
function initMap() {
var newYorkCityLatLong = new google.maps.LatLng(40.7128, -74.0059);
map = new google.maps.Map(document.getElementById('map'), {
center: newYorkCityLatLong,
zoom: 9,
});
//this listener works, but I am having a very hard time getting the NY Times api to work the way it is supposed to when using the sw,
//and ne parameters. When those are supplied it is supposed to keep the results to those within the box created by those two points,
//but it doesn't work, not here or in their console. A different way to do this would be to manually check if every point is within the
//parameters.
google.maps.event.addListener(map, 'bounds_changed', function() {
var bounds = map.getBounds();
sw = bounds.getSouthWest();
ne = bounds.getNorthEast();
swLat = sw.lat().toFixed(5);
swLng = sw.lng().toFixed(5);
neLat = ne.lat().toFixed(5);
neLng = ne.lng().toFixed(5);
loadMarkers();
});
}
//Queries the NY Times Geographic API and takes the results and creates markers out of them.
function loadMarkers() {
var url = "https://api.nytimes.com/svc/semantic/v2/geocodes/query.json";
if(facetChosen) {
url += '?' + $.param({
'sw': swLat + ',' + swLng,
'ne': neLat + ',' + neLng,
'facet': facetChoice,
'country_code': "US",
'api-key': "af9bf1c31430421ab0ab8f940e8b987f"
});
facetChosen = 0;
} else {
url += '?' + $.param({
'sw': swLat + ',' + swLng,
'ne': neLat + ',' + neLng,
'country_code': "US",
'api-key': "af9bf1c31430421ab0ab8f940e8b987f"
});
}
var things;
//This proxyurl was used to overcome a Access-Control-Allow-Origin error with CORS.
const proxyurl = "https://cors-anywhere.herokuapp.com/";
//could use this fetch method, or a GET ajax call.
fetch(proxyurl + url)
.then(response => response.text())
.then(contents => JSON.parse(contents))
.then(function(data){
console.log(url);
for (var i = 0; i < data.results.length; i++) {
var latLon = new google.maps.LatLng(data.results[i].latitude,data.results[i].longitude);
var marker = new google.maps.Marker({
position: latLon,
});
marker.addListener('click', addInfoWindow(data, marker, i));
marker.setMap(map);
}
});
}
//Creates an info window to be opened when a marker is clicked.
function addInfoWindow(data, marker, index) {
return function() {
var infowindow = new google.maps.InfoWindow({
content: '<h1>' + data.results[index].name + '</h1>' +
'<p>' + data.results[index].name + ' has a lat/lng of (' + data.results[index].latitude + ', ' + data.results[index].longitude + '). ' +
'It also has an elevation of ' + data.results[index].elevation + ' feet.</p>'
});
infowindow.open(map, marker);
}
}
//Takes radio button input and reloads markers based on the change in facets.
function changeFacet(val) {
if (val > 0) {
facetChoice = val;
facetChosen = 1;
}
loadMarkers();
}
@@ -0,0 +1,77 @@
#title {
background-color: orange;
height: 100px;
width: 100%;
display: inline-block;
}
#titleWords {
float: left;
width: 90%;
height: 100px;
margin: 0px;
}
#map {
height: 100%;
width: 100%;
}
html, body {
height: 100%;
margin: 0;
padding: 0;
font-family: 'Ubuntu', sans-serif;
background-color: #eee;
}
h1, h2 {
margin-top: 0;
text-align: center;
}
.facetButton {
background-color: black;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}
.facetDrop {
float: right;
width: 10%;
height: 50px;
margin-top: 15px;
}
.facetDrop-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
width: 100%;
}
.facetDrop-content a {
color: black;
padding: 12px 16px;
display: block;
}
.facetDrop-content a:hover {
background-color: #f1f1f1
}
.facetDrop:hover .facetDrop-content {
display: block;
}
.facetDrop:hover .facetButton {
background-color: white;
color: black;
}