Commit 20d5b2c9101a7705b03e1e32f430166ba99a9b85

Authored by Paul Wallace
1 parent 4947b376f0
Exists in master

Update the log in feature

Showing 3 changed files with 9 additions and 4 deletions Inline Diff

var express = require('express'); 1 1 var express = require('express');
2 2
var crime = require('./routes/crime'); 3 3 var crime = require('./routes/crime');
4 4
var app = express(); 5 5 var app = express();
6 6
app.set('port', (process.env.PORT || 5000)); 7 7 app.set('port', (process.env.PORT || 5000));
8 8
app.use(express.static(__dirname + '/public')); 9 9 app.use(express.static(__dirname + '/public'));
10 10
// views is directory for all template files 11 11 // views is directory for all template files
app.set('views', __dirname + '/views'); 12 12 app.set('views', __dirname + '/views');
app.set('view engine', 'ejs'); 13 13 app.set('view engine', 'ejs');
14 14
app.get('/', function(request, response) { 15 15 app.get('/', function(request, response) {
response.render('pages/index'); 16 16 response.render('pages/index', request.query);
}); 17 17 });
18 18
app.get('/landing', function(request, response) { 19 19 app.get('/landing', function(request, response) {
response.render('pages/landing'); 20 20 response.render('pages/landing');
}); 21 21 });
22 22
views/pages/index.ejs View file @ 20d5b2c
<!DOCTYPE html> 1 1 <!DOCTYPE html>
<html lang="en"> 2 2 <html lang="en">
<head> 3 3 <head>
<% include ../partials/header %> 4 4 <% include ../partials/header %>
</head> 5 5 </head>
6 6
<!-- Homepage --> 7 7 <!-- Homepage -->
8 8
<body> 9 9 <body>
<div class="container-fluid"> 10 10 <div class="container-fluid">
<div class="jumbotron text-center"> 11 11 <div class="jumbotron text-center">
<h1>Safe Routes</h1> 12 12 <h1>Safe Routes</h1>
<p>The best way to find the safest routes.</p> 13 13 <p>The best way to find the safest routes.</p>
</div> 14 14 </div>
15 15
<form action="/login"> 16 16 <% if(!locals.loggedin || (locals.loggedin != "true")){ %>
17 17
18 <%console.log(locals.loggedin)%>
19 <form action="/login">
20
<button type="submit" class="btn btn-primary">Log In</button> 18 21 <button type="submit" class="btn btn-primary">Log In</button>
<!-- <input type="submit" value="Submit"> --> 19 22 <!-- <input type="submit" value="Submit"> -->
</form> 20 23 </form>
24 <% } %>
21 25
22 26
23 27
<!--What are for and type for?--> 24 28 <!--What are for and type for?-->
<!-- current submit button takes you to the landing page --> 25 29 <!-- current submit button takes you to the landing page -->
<form action="/landing"> 26 30 <form action="/landing">
<!-- First text field and label above the text field for current location --> 27 31 <!-- First text field and label above the text field for current location -->
<div class="form-group text-center"> 28 32 <div class="form-group text-center">
<label for="currentLocation">From</label> 29 33 <label for="currentLocation">From</label>
<input type="currentLocation" class="form-control" id="origin" placeholder="Enter Current Location" onchange="saveFrom()"> 30 34 <input type="currentLocation" class="form-control" id="origin" placeholder="Enter Current Location" onchange="saveFrom()">
</div> 31 35 </div>
<!-- Second text field and label above the text field for destination --> 32 36 <!-- Second text field and label above the text field for destination -->
<div class="form-group text-center"> 33 37 <div class="form-group text-center">
<label for="destination">To</label> 34 38 <label for="destination">To</label>
<input type="destination" class="form-control" id="dest" placeholder="Enter Destination" onchange="saveTo()"> 35 39 <input type="destination" class="form-control" id="dest" placeholder="Enter Destination" onchange="saveTo()">
</div> 36 40 </div>
<!-- First travel option button, walking 37 41 <!-- First travel option button, walking
This contains a row that holds buttons of type button. Buttons are highlighted upon selection. 38 42 This contains a row that holds buttons of type button. Buttons are highlighted upon selection.
--> 39 43 -->
<div class="row"> 40 44 <div class="row">
<button type="button" class="btn-default img-thumbnail col-xs-4" onclick="walk();"> 41 45 <button type="button" class="btn-default img-thumbnail col-xs-4" onclick="walk();">
<img class="img-responsive" src="images/pedestrian-walking.svg" alt="Walking Option" width="40" height="40"> 42 46 <img class="img-responsive" src="images/pedestrian-walking.svg" alt="Walking Option" width="40" height="40">
</button> 43 47 </button>
44 48
<!-- Second travel button, driving --> 45 49 <!-- Second travel button, driving -->
<button type="button" class="btn-default img-thumbnail col-xs-4" onclick="drive();"> 46 50 <button type="button" class="btn-default img-thumbnail col-xs-4" onclick="drive();">
<img class="img-responsive" src="images/car-compact.svg" alt="Walking Option" width="40" height="40"> 47 51 <img class="img-responsive" src="images/car-compact.svg" alt="Walking Option" width="40" height="40">
</button> 48 52 </button>
49 53
<!-- Third travel button, bus --> 50 54 <!-- Third travel button, bus -->
<button type="button" class="btn-default img-thumbnail col-xs-4" onclick="bus();"> 51 55 <button type="button" class="btn-default img-thumbnail col-xs-4" onclick="bus();">
<img class="img-responsive" src="images/bus.svg" alt="Walking Option" width="40" height="40"> 52 56 <img class="img-responsive" src="images/bus.svg" alt="Walking Option" width="40" height="40">
</button> 53 57 </button>
</div> 54 58 </div>
55 59
<div class="text-center"> 56 60 <div class="text-center">
<button type="submit" class="btn btn-primary btn-space">Go</button> 57 61 <button type="submit" class="btn btn-primary btn-space">Go</button>
</div> 58 62 </div>
</form> 59 63 </form>
</div> 60 64 </div>
61 65
<!-- Google Map functionality. --> 62 66 <!-- Google Map functionality. -->
<script> 63 67 <script>
function saveFrom() { 64 68 function saveFrom() {
var fromInput = document.getElementById("origin").value; 65 69 var fromInput = document.getElementById("origin").value;
localStorage.setItem("from", fromInput); 66 70 localStorage.setItem("from", fromInput);
} 67 71 }
function saveTo() { 68 72 function saveTo() {
var toInput = document.getElementById("dest").value; 69 73 var toInput = document.getElementById("dest").value;
localStorage.setItem("to", toInput); 70 74 localStorage.setItem("to", toInput);
} 71 75 }
function walk() { 72 76 function walk() {
localStorage.setItem("mode", "WALKING"); 73 77 localStorage.setItem("mode", "WALKING");
} 74 78 }
function drive() { 75 79 function drive() {
localStorage.setItem("mode", "DRIVING"); 76 80 localStorage.setItem("mode", "DRIVING");
} 77 81 }
views/pages/login.ejs View file @ 20d5b2c
<!DOCTYPE html> 1 1 <!DOCTYPE html>
<html lang="en"> 2 2 <html lang="en">
<head> 3 3 <head>
<% include ../partials/header %> 4 4 <% include ../partials/header %>
</head> 5 5 </head>
6 6
<!-- Homepage --> 7 7 <!-- Homepage -->
8 8
<body> 9 9 <body>
<div class="container-fluid"> 10 10 <div class="container-fluid">
<form action="/"> 11 11 <form action="/">
<div class="form-group"> 12 12 <div class="form-group">
13 <input type="hidden" name="loggedin" value="true"/>
<input type="currentLocation" class="form-control" id="origin" placeholder="Username" onchange="saveFrom()"> 13 14 <input type="currentLocation" class="form-control" id="origin" placeholder="Username" onchange="saveFrom()">
<input type="currentLocation" class="form-control" id="origin" placeholder="Password" onchange="saveFrom()"> 14 15 <input type="currentLocation" class="form-control" id="origin" placeholder="Password" onchange="saveFrom()">
</div> 15 16 </div>
<button class="btn btn-primary">Log In</button> 16 17 <button class="btn btn-primary">Log In</button>
</form> 17 18 </form>
</div> 18 19 </div>
19 20
<!-- Google Map functionality. --> 20 21 <!-- Google Map functionality. -->
<script> 21 22 <script>