diff --git a/data.json b/data.json new file mode 100644 index 0000000..3bb1042 --- /dev/null +++ b/data.json @@ -0,0 +1,6 @@ +{ + spots:[ + { "found" : "1", "score" : "60", "grade" : "C", "gradedetail" : "C+", "color" : "e5e209", "density" : "50", "location" : "Louisville, KY", "datasetid" : "174", "latitude" : "38.08809", "longitude" : "-85.679626", "message" : "OK" } + ] + +} diff --git a/index.js b/index.js index e43c48b..7c1c573 100644 --- a/index.js +++ b/index.js @@ -21,6 +21,11 @@ app.get('/landing', function(request, response) { }); +app.get('/login', function(request, response) { + response.render('pages/login'); +}); + + app.get('/api', crime.view); app.listen(app.get('port'), function() { diff --git a/public/stylesheets/main.css b/public/stylesheets/main.css index fcad9ec..6034655 100644 --- a/public/stylesheets/main.css +++ b/public/stylesheets/main.css @@ -33,4 +33,8 @@ .btn-space{ margin-top: 10px; width: 50%; +} + +.log-in-textfield{ + width: 30%; } \ No newline at end of file diff --git a/routes/crime.js b/routes/crime.js index 97decab..24d6469 100644 --- a/routes/crime.js +++ b/routes/crime.js @@ -2,22 +2,25 @@ var unirest = require('unirest'); exports.view = function(req, res){ - unirest.get("https://yourmapper2.p.mashape.com/datasetlist?format=json&maxlat=40&maxlon=-70&minlat=30&minlon=-90&num=5&sort=location") - .header("X-Mashape-Key", "gj4g6D3zxKmshys7yyf9KNbuywOxp1ueazFjsn6n2fK4sccIGA") - .header("Accept", "application/json") - .end(function (result) { - // console.log(result.status, result.headers, result.body); + // unirest.get("https://yourmapper2.p.mashape.com/datasetlist?format=json&maxlat=40&maxlon=-70&minlat=30&minlon=-90&num=5&sort=location") + // .header("X-Mashape-Key", "gj4g6D3zxKmshys7yyf9KNbuywOxp1ueazFjsn6n2fK4sccIGA") + // .header("Accept", "application/json") + // .end(function (result) { + // // console.log(result.status, result.headers, result.body); - }); - + // }); + //37.782551, -122.445368 // These code snippets use an open-source library. http://unirest.io/nodejs - unirest.get("https://crimescore.p.mashape.com/crimescore?f=json&id=174&lat=38.08809&lon=-85.679626") + //generate the json file here, for now just one call to demonstrate it works + + unirest.get("https://crimescore.p.mashape.com/crimescore?f=json&id=174&lat=37.782551&lon=-122.445368") .header("X-Mashape-Key", "gj4g6D3zxKmshys7yyf9KNbuywOxp1ueazFjsn6n2fK4sccIGA") .header("Accept", "application/json") .end(function (result) { res.render('pages/tempcrime', result); + console.log(result.status, result.headers, result.body); }); diff --git a/views/pages/index.ejs b/views/pages/index.ejs index 196a42b..4a102b3 100644 --- a/views/pages/index.ejs +++ b/views/pages/index.ejs @@ -13,6 +13,14 @@ <p>The best way to find the safest routes.</p> </div> + <form action="/login"> + + <button type="submit" class="btn btn-primary">Log In</button> + <!-- <input type="submit" value="Submit"> --> + </form> + + + <!--What are for and type for?--> <!-- current submit button takes you to the landing page --> <form action="/landing"> @@ -70,6 +78,10 @@ function bus() { localStorage.setItem("mode", "TRANSIT"); } + + function login(){ + + } </script> </body> diff --git a/views/pages/landing.ejs b/views/pages/landing.ejs index 141e61d..eebd31e 100644 --- a/views/pages/landing.ejs +++ b/views/pages/landing.ejs @@ -108,6 +108,21 @@ } function getPoints() { + //read json here from passed in parameters + //loop here that loops through the passed in json values for points along the route + //return the list of objects created from those longitudes and latitudes + + //THIS IS THE CODE TO READ JSON BUT IT'S NOT VIABLE TO CREATE ALL THESE POINTS MANUALLY IN A JSON FILE. + //So instead we copy pasted a sample set of points to demonstrate the functionality + + /*var toReturn = []; + for (i = 0; i < [insert ejs symbols here]spots.length[insert ejs symbols here]; i++) { + toReturn.push(new google.maps.LatLng(insert ejs symbols here spots[i].latutudeinsert ejs symbols here, insert ejs symbols here spots[i].longitudeinsert ejs symbols here)); + } + + return toReturn;*/ + + return [ new google.maps.LatLng(37.782551, -122.445368), new google.maps.LatLng(37.782745, -122.444586), diff --git a/views/pages/login.ejs b/views/pages/login.ejs new file mode 100644 index 0000000..415b53d --- /dev/null +++ b/views/pages/login.ejs @@ -0,0 +1,25 @@ +<!DOCTYPE html> +<html lang="en"> + <head> + <% include ../partials/header %> + </head> + +<!-- Homepage --> + + <body> + <div class="container-fluid"> + <form action="/"> + <div class="form-group"> + <input type="currentLocation" class="form-control" id="origin" placeholder="Username" onchange="saveFrom()"> + <input type="currentLocation" class="form-control" id="origin" placeholder="Password" onchange="saveFrom()"> + </div> + <button class="btn btn-primary">Log In</button> + </form> + </div> + + <!-- Google Map functionality. --> + <script> + </script> + + </body> +</html> \ No newline at end of file