Commit 26ce5df5 authored by Renfred Harper's avatar Renfred Harper
Browse files

Add grid info functionality to grid.js

parent 4dee6365
......@@ -126,3 +126,39 @@ $.ajax({
}
}, 1000);
});
$(document).ready(function() {
var lastClicked = null;
$('#info-body').click(function() {
$(this).slideUp(350);
});
$(document).on('click', '.grid-box', function() {
// If the user clicks on the same box twice it will close the info menu
grid_id = $(this).attr('id');
if (lastClicked == grid_id){
$('#info-body').slideToggle(300)
}
else {
$('#info-body').slideDown(300);
lastClicked = grid_id;
}
// Search though the restaurnts object to find the selected restaurant's info
var restaurant;
$.each(restaurants, function(idx, restaurant_i) {
if (restaurant_i.id == grid_id) {
restaurant = restaurant_i;
return false;
}
});
// Display restaurant info in the info-body
$('#info-name').text(restaurant.name);
if (restaurant.open){
$('#info-status').html('<b>Status:</b> Open');
var closing = Date.parse(restaurant.current.end_time);
$('#info-next').html('<b>Open Till:</b> ' + closing.toLocaleTimeString().replace(/:\d+ /, ' '));
}
else {
$('#info-status').html('<b>Status:</b> Closed');
$('#info-next').html("");
}
});
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment