Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
whats-open
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Zoheb Lokhandwala
whats-open
Commits
c23a707f
Commit
c23a707f
authored
Dec 04, 2013
by
Daniel W Bond
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.gmu.edu:srct/whats-open
parents
74149a41
fe30667a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
64 additions
and
32 deletions
+64
-32
website/static/js/grid.js
website/static/js/grid.js
+12
-6
website/static/js/info.js
website/static/js/info.js
+51
-25
whats_open/templates/head.html
whats_open/templates/head.html
+1
-1
No files found.
website/static/js/grid.js
View file @
c23a707f
...
...
@@ -58,7 +58,7 @@ function construct_grid(filtered_restaurants) {
function
update_grid
(
restaurants
)
{
$
.
each
(
restaurants
,
function
(
idx
,
restaurant
)
{
var
now
=
new
Date
();
var
date
=
new
Date
().
setHours
(
0
,
0
,
0
,
0
);
var
endDate
=
new
Date
().
setHours
(
5
,
0
,
0
,
0
);
// JavaScript sets 0 to Sunday instead of Monday
var
day
=
now
.
getDay
()
-
1
;
if
(
day
===
-
1
)
{
...
...
@@ -67,10 +67,13 @@ function update_grid(restaurants) {
var
schedule
=
undefined
;
// If there exists a valid special schedule choose it.
$
.
each
(
restaurant
.
special_schedules
,
function
(
idx
,
special
)
{
console
.
log
(
Date
.
parse
(
special
.
start
))
console
.
log
(
date
)
if
(
date
>=
Date
.
parse
(
special
.
start
)
&&
date
<=
Date
.
parse
(
special
.
end
))
{
// Special schedules take effect after 5am on their start day
// to prevent collisions with the previous night's schedule,
// and they end at 5am the day after their end date.
special_start
=
Date
.
parse
(
special
.
start
+
'
05:00:00
'
);
special_end
=
Date
.
parse
(
special
.
end
+
'
05:00:00
'
);
special_end
.
setDate
(
special_end
.
getDate
()
+
1
);
if
(
now
>=
special_start
&&
now
<=
special_end
)
{
schedule
=
special
;
}
});
...
...
@@ -78,8 +81,11 @@ function update_grid(restaurants) {
if
(
schedule
===
undefined
)
{
schedule
=
restaurant
.
main_schedule
;
}
restaurant
.
current_schedule
=
schedule
;
// Open the restaurants that are open, leave the rest closed.
if
(
schedule
.
open_times
.
length
===
0
)
{
restaurant
.
open
=
false
;
}
restaurant
.
current_schedule
=
schedule
;
$
.
each
(
schedule
.
open_times
,
function
(
idx
,
time
)
{
var
start_day
=
time
.
start_day
;
var
end_day
=
time
.
end_day
;
...
...
website/static/js/info.js
View file @
c23a707f
...
...
@@ -12,14 +12,60 @@ function compareTimes(time1, time2) {
return
true
;
}
function
areConsecutiveDays
(
time1
,
time2
)
{
if
(
time1
===
undefined
||
time2
===
undefined
)
{
return
false
;
}
else
if
(
time1
.
start_day
!==
time2
.
start_day
-
1
)
{
return
false
;
}
return
true
;
}
$
.
fn
.
displaySchedule
=
function
(
open_times
){
/* Display each open time in a concise format. The following loop will
* determine if two consecutive days have the same open and closing times.
* If that is the case, the time will be shown as a range.
* (ie. Mon - Sat: 10:00 AM - 6:00 PM")
* Otherwise, each date is displayed for its individual day.
* (ie. Sun: "4:00 PM - 12:00 AM
*/
var
element
=
''
;
for
(
var
i
=
0
;
i
<
open_times
.
length
;
i
++
){
if
(
!
compareTimes
(
open_times
[
i
],
open_times
[
i
-
1
])
||
!
areConsecutiveDays
(
open_times
[
i
-
1
],
open_times
[
i
]))
{
element
+=
'
<div class="col-md-3"><b>
'
;
}
if
((
!
compareTimes
(
open_times
[
i
],
open_times
[
i
-
1
])
||
!
areConsecutiveDays
(
open_times
[
i
-
1
],
open_times
[
i
]))
&&
compareTimes
(
open_times
[
i
],
open_times
[
i
+
1
])
&&
areConsecutiveDays
(
open_times
[
i
],
open_times
[
i
+
1
]))
{
// Add: "StartDay - "
element
+=
days
[
open_times
[
i
].
start_day
]
+
'
-
'
;
}
if
(
!
compareTimes
(
open_times
[
i
],
open_times
[
i
+
1
])
||
open_times
[
i
].
start_day
!==
(
open_times
[
i
+
1
].
start_day
-
1
))
{
// Add "EndDay: OpenTime - CloseTime"
opening
=
Date
.
parse
(
open_times
[
i
].
start_time
);
closing
=
Date
.
parse
(
open_times
[
i
].
end_time
);
element
+=
days
[
open_times
[
i
].
start_day
]
+
'
</b>:
'
+
opening
.
toLocaleTimeString
().
replace
(
/
(\d
+:
\d{2})(
:
\d
+
)
/
,
"
$1
"
)
+
'
-
'
+
closing
.
toLocaleTimeString
().
replace
(
/
(\d
+:
\d{2})(
:
\d
+
)
/
,
"
$1
"
)
+
'
</div>
'
;
$
(
this
).
append
(
element
);
element
=
''
;
}
}
}
function
dispalyInfo
(
restaurant
)
{
// Display restaurant info in the info-body without bracketed locations
$
(
'
#info-name
'
).
text
(
restaurant
.
name
.
replace
(
/
?\[(
.+
)\]
/
,
''
));
if
(
restaurant
.
location
!==
null
)
{
$
(
'
#info-location
'
).
html
(
'
<b>Location:</b>
'
+
restaurant
.
location
).
show
();
if
(
restaurant
.
location
==
''
)
{
$
(
'
#info-location
'
).
hide
();
}
else
{
$
(
'
#info-location
'
).
hide
();
$
(
'
#info-location
'
).
html
(
'
<b>Location:</b>
'
+
restaurant
.
location
).
show
();
}
if
(
restaurant
.
open
){
$
(
'
#info-status
'
).
html
(
'
<b>Status:</b> Open
'
);
...
...
@@ -31,30 +77,10 @@ function dispalyInfo(restaurant) {
$
(
'
#info-status
'
).
html
(
'
<b>Status:</b> Closed
'
);
$
(
'
#info-next
'
).
empty
().
hide
()
}
$
(
'
#info-schedule
'
).
empty
();
// Display all open times for the main schedule
var
open_times
=
restaurant
.
current_schedule
.
open_times
;
var
element
=
''
;
$
(
'
#info-schedule
'
).
empty
();
for
(
var
i
=
0
;
i
<
open_times
.
length
;
i
++
){
if
(
!
compareTimes
(
open_times
[
i
],
open_times
[
i
-
1
])){
element
+=
'
<div class="col-md-3"><b>
'
;
}
if
(
!
compareTimes
(
open_times
[
i
],
open_times
[
i
-
1
])
&&
// Add: "StartDay - "
compareTimes
(
open_times
[
i
],
open_times
[
i
+
1
])){
element
+=
days
[
open_times
[
i
].
start_day
]
+
'
-
'
;
}
if
(
!
compareTimes
(
open_times
[
i
],
open_times
[
i
+
1
])){
// Add "EndDay: OpenTime - CloseTime"
opening
=
Date
.
parse
(
open_times
[
i
].
start_time
);
closing
=
Date
.
parse
(
open_times
[
i
].
end_time
);
element
+=
days
[
open_times
[
i
].
start_day
]
+
'
</b>:
'
+
opening
.
toLocaleTimeString
().
replace
(
/
(\d
+:
\d{2})(
:
\d
+
)
/
,
"
$1
"
)
+
'
-
'
+
closing
.
toLocaleTimeString
().
replace
(
/
(\d
+:
\d{2})(
:
\d
+
)
/
,
"
$1
"
)
+
'
</div>
'
;
$
(
"
#info-schedule
"
).
append
(
element
);
element
=
''
;
}
}
$
(
'
#info-schedule
'
).
displaySchedule
(
open_times
);
}
days
=
{
...
...
whats_open/templates/head.html
View file @
c23a707f
...
...
@@ -6,7 +6,7 @@
<link
href=
"{{ STATIC_URL }}css/style.css"
rel=
"stylesheet"
>
<script
src=
"//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"
></script>
<script
src=
"//ajax.googleapis.com/ajax/libs/jqueryui/1.10.2/jquery-ui.min.js"
></script>
<script
type=
"text/javascript"
src=
"http://www.datejs.com/build/date
.js"
></script>
<script
src=
"//cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min
.js"
></script>
<script
src=
"{{ STATIC_URL }}js/bootstrap.min.js"
></script>
<script
src=
"{{ STATIC_URL }}js/grid.js"
></script>
<script
src=
"{{ STATIC_URL }}js/typeAhead.js"
></script>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment