This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set up the basic functionality of adding and removing destinations
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Removes destination | ||
var removeDestination = function() { | ||
$(this).parents('.destination').remove(); | ||
}; | ||
|
||
// Adds an address to the data table | ||
var addDestination = function() { | ||
var addr = $('#address').val(); | ||
if (addr !== '') { | ||
$('#data').append('<tr class="destination"><td class="address"><a href="#" class="close">×</a>' + addr + '</td><td class="distance"></td><td class="map"></td></tr>'); | ||
$('.close').click(removeDestination); | ||
} | ||
}; | ||
// Sets up jQuery | ||
$(function() { | ||
// Set up add-address binding | ||
$('#add-destination').click(addDestination); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!DOCTYPE HTML> | ||
<html lang="en-US"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Distance Calculator</title> | ||
<link rel="stylesheet" href="../lib/css/bootstrap.min.css"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="span12"> | ||
<div class="page-header"> | ||
<h1>Distance Calculator</h1> | ||
</div> | ||
<form class="well form-inline"> | ||
<input type="text" class="input-xxlarge" id="address" placeholder="Address"> | ||
<a href="#" class="btn" id="add-destination"><i class="icon-plus"></i>Add Destination</a> | ||
<a href="#" class="btn btn-primary" id="calculate-distances"><i class="icon-map-marker icon-white"></i>Calculate</a> | ||
</form> | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th>Address</th> | ||
<th>Distance</th> | ||
<th>Map</th> | ||
</tr> | ||
</thead> | ||
<tbody id="data"> | ||
|
||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
</div> | ||
<script type="text/javascript" src="../lib/js/jquery.min.js"></script> | ||
<script type="text/javascript" src="app.js"></script> | ||
</body> | ||
</html> |