Commit 3399856a authored by Renfred Harper's avatar Renfred Harper

Add support for special schedules to be displayed in info container

parent 18670825
...@@ -76,6 +76,7 @@ function update_grid(restaurants) { ...@@ -76,6 +76,7 @@ function update_grid(restaurants) {
if (schedule === undefined) { if (schedule === undefined) {
schedule = restaurant.main_schedule; schedule = restaurant.main_schedule;
} }
restaurant.current_schedule = schedule;
// Open the restaurants that are open, leave the rest closed. // Open the restaurants that are open, leave the rest closed.
$.each(schedule.open_times, function (idx, time) { $.each(schedule.open_times, function (idx, time) {
var start_day = time.start_day; var start_day = time.start_day;
......
...@@ -12,38 +12,7 @@ function compareTimes(time1, time2){ ...@@ -12,38 +12,7 @@ function compareTimes(time1, time2){
return true; return true;
} }
days = { function dispalyInfo(restaurant) {
0:"Mon",
1:"Tues",
2:"Wed",
3:"Thu",
4:"Fri",
5:"Sat",
6:"Sun"
}
$(document).ready(function() {
var lastClicked = null;
$('#info-body').click(function() {
// Only allow closing the info pane via click on larger screens
if ($(window).width() >= 992) {
$(this).slideUp(350);
}
});
// Displays more info about a restaurant on-click
$(document).on('click', '.grid-box', function() {
grid_id = $(this).attr('id');
// Keep track of the users vertical position so it can be scolled back
//to when the window is closed
position = $(window).scrollTop();
// 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 without bracketed locations // Display restaurant info in the info-body without bracketed locations
$('#info-name').text(restaurant.name.replace(/ ?\[(.+)\]/, '')); $('#info-name').text(restaurant.name.replace(/ ?\[(.+)\]/, ''));
if (restaurant.location !== null){ if (restaurant.location !== null){
...@@ -54,7 +23,7 @@ $(document).ready(function() { ...@@ -54,7 +23,7 @@ $(document).ready(function() {
} }
if (restaurant.open){ if (restaurant.open){
$('#info-status').html('<b>Status:</b> Open'); $('#info-status').html('<b>Status:</b> Open');
var closing = Date.parse(restaurant.current.end_time); var closing = Date.parse(restaurant.current_time.end_time);
// Print the time the restaurant closes in local format with the seconds removed via regex // Print the time the restaurant closes in local format with the seconds removed via regex
$('#info-next').html('<b>Open Till:</b> ' + closing.toLocaleTimeString().replace(/(\d+:\d{2})(:\d+ )/, "$1 ")).show(); $('#info-next').html('<b>Open Till:</b> ' + closing.toLocaleTimeString().replace(/(\d+:\d{2})(:\d+ )/, "$1 ")).show();
} }
...@@ -63,7 +32,7 @@ $(document).ready(function() { ...@@ -63,7 +32,7 @@ $(document).ready(function() {
$('#info-next').empty().hide() $('#info-next').empty().hide()
} }
// Display all open times for the main schedule // Display all open times for the main schedule
var open_times = restaurant.main_schedule.open_times; var open_times = restaurant.current_schedule.open_times;
var element = ''; var element = '';
$('#info-schedule').empty(); $('#info-schedule').empty();
for(var i = 0; i < open_times.length; i++){ for(var i = 0; i < open_times.length; i++){
...@@ -86,6 +55,41 @@ $(document).ready(function() { ...@@ -86,6 +55,41 @@ $(document).ready(function() {
element = ''; element = '';
} }
} }
}
days = {
0:"Mon",
1:"Tues",
2:"Wed",
3:"Thu",
4:"Fri",
5:"Sat",
6:"Sun"
}
$(document).ready(function() {
var lastClicked = null;
$('#info-body').click(function() {
// Only allow closing the info pane via click on larger screens
if ($(window).width() >= 992) {
$(this).slideUp(350);
}
});
// Displays more info about a restaurant on-click
$(document).on('click', '.grid-box', function() {
grid_id = $(this).attr('id');
// Keep track of the users vertical position so it can be scolled back
//to when the window is closed
position = $(window).scrollTop();
// 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;
}
});
dispalyInfo(restaurant);
// If the user clicks on the same box twice it will close the info menu // If the user clicks on the same box twice it will close the info menu
if (lastClicked == grid_id){ if (lastClicked == grid_id){
$('#info-body').slideToggle(300) $('#info-body').slideToggle(300)
......
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