Commit 32c0ead5 authored by Daniel Bond's avatar Daniel Bond
Browse files

Merge branch 'master' of github.com:thallada/whats-open

parents 5db2114b 105f9dc5
......@@ -120,10 +120,21 @@ we do I will have instructions on how to deploy the code here.
* Get all restaurants displaying correct open times on the page. AKA. make
extensive tests.
* Sort by location view
* Get a decent UI
* Get a usable admin interface UI, currently it is very confusing to add a
restaurant and schedule.
* Get a decent UI (make sure everything is pretty and usable)
* Add times until opening/closing for restaurants that are close, and exact
times for those that aren't.
* Add yellow close-to-closing condition.
* Possible: Make an API?
* Make page refresh, or more preferably have the data refresh. For
example, with AJAX calls.
* Create more useful API calls. Document them.
* Allow switching between campuses. In the database, mark which campus each
restauraunt is on, include this information in the JSON object returned at
`ajax/schedule` and store the campus choice in the user's cookies
so that when they come back the page will already be set to their campus.
Default would be Fairfax of course.
[jquery-cookie](https://github.com/carhartl/jquery-cookie) would be useful
fo[jquery-cookie](https://github.com/carhartl/jquery-cookie) would be useful
for this.
* Create a more user-friendly way of creating restaurants and updating
schedules on the admin site. This could be done by modifying the admin site
or creating our own Django forms and doing it outside the admin site.
......@@ -22,6 +22,7 @@ body {
font-size: 50px;
font-weight: 900;
margin-top:30px;
line-height: 50px;
}
#grid div[class*='span']{
......@@ -50,6 +51,7 @@ body {
.search-row{
text-align: center;
padding-top: 15px;
}
ul.ui-autocomplete {
list-style: none;
......
function sort_restaurants(restaurants) {
var open = $.grep(restaurants,
var restaurants = [];
function sort_restaurants(filtered_restaurants) {
var open = $.grep(filtered_restaurants,
function (r, idx) { return (r.open === true) });
var closed = $.grep(restaurants,
var closed = $.grep(filtered_restaurants,
function (r, idx) { return (r.open === false) });
return $.merge(open, closed);
}
function construct_grid(restaurants) {
restaurants = sort_restaurants(restaurants);
$.each(restaurants, function (idx, restaurant) {
function construct_grid(filtered_restaurants) {
// Hide footer while generating grid to prevent it flying across the screen
$('#footer').hide();
$('#grid').empty();
$('#grid').html('<div class="row"></div>');
if (filtered_restaurants.length == 0) {
$('#grid').append('<span class="span2 offset5">No results found.</span>');
return;
}
sorted_restaurants = sort_restaurants(filtered_restaurants);
$.each(sorted_restaurants, function (idx, restaurant) {
var open_class = 'closed';
if (restaurant.open) {
open_class = 'opened';
......@@ -25,16 +35,13 @@ function construct_grid(restaurants) {
);
}
});
$('#footer').show();
}
$.ajax({
url: '/ajax/schedule/',
}).done(function (data) {
// Hide footer while generating grid to prevent it flying across the screen
$('#footer').hide();
$('#grid').empty();
$('#grid').html('<div class="row"></div>');
var restaurants = data.data;
restaurants = data.data;
$.each(restaurants, function (idx, restaurant) {
var now = new Date();
var date = new Date().setHours(0,0,0,0);
......@@ -101,5 +108,4 @@ $.ajax({
});
});
construct_grid(restaurants);
$('#footer').show();
});
......@@ -2,38 +2,27 @@ $.ajax({
url: '/ajax/schedule/',
}).done(function (data) {
//collecting list of restaurant names from server data
var restaurants = [];
var rest_names = [];
for (var i = 0; i < data.data.length; i++) {
restaurants.push(data.data[i].name);
rest_names.push(data.data[i].name);
};
//Monitors for keyboard activity to detect when the input field is empty
$('#searchBar').keyup(function() {
var value = $('#searchBar').val();
if (value == 0){
//resets all backgrounds to white if the search bar is empty
$('.open').css('background-color','white');
$('.closed').css('background-color','white');
}
});
// For doumentation on jQuery's autocomplete: (api.jqueryui.com/autocomplete)
$("#searchBar").autocomplete({
source: restaurants,
source: rest_names,
//making it so the search result list doesn't physically appear
messages: {
noResults: '',
results: function(){}
},
minLength: 0,
response: function(event, ui) {
//resets all backgrounds to white if the search bar is edited
$('.open').css('background-color','white');
$('.closed').css('background-color','white');
//ui.content array contains all names that are returned from the search
for (var result in ui.content){
//Highlights all search results
$('.open:contains("'+ui.content[result].value+'")').css('background-color','#FDFFBF');
$('.closed:contains("'+ui.content[result].value+'")').css('background-color','#FDFFBF');
}
results = $.map(ui.content, function(r) { return r.value; });
filtered = $.grep(restaurants, function (r, idx) {
return ($.inArray(r.name, results) != -1);
});
construct_grid(filtered);
// To prevent the page width from extending
$('.ui-autocomplete').remove();
}
......
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