Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
SRCT
whats-open
Commits
3399856a
Commit
3399856a
authored
Nov 24, 2013
by
Renfred Harper
Browse files
Add support for special schedules to be displayed in info container
parent
18670825
Changes
2
Hide whitespace changes
Inline
Side-by-side
website/static/js/grid.js
View file @
3399856a
...
...
@@ -76,6 +76,7 @@ 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.
$
.
each
(
schedule
.
open_times
,
function
(
idx
,
time
)
{
var
start_day
=
time
.
start_day
;
...
...
website/static/js/info.js
View file @
3399856a
...
...
@@ -12,6 +12,51 @@ function compareTimes(time1, time2){
return
true
;
}
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
();
}
else
{
$
(
'
#info-location
'
).
hide
();
}
if
(
restaurant
.
open
){
$
(
'
#info-status
'
).
html
(
'
<b>Status:</b> Open
'
);
var
closing
=
Date
.
parse
(
restaurant
.
current_time
.
end_time
);
// 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
();
}
else
{
$
(
'
#info-status
'
).
html
(
'
<b>Status:</b> Closed
'
);
$
(
'
#info-next
'
).
empty
().
hide
()
}
// 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
=
''
;
}
}
}
days
=
{
0
:
"
Mon
"
,
1
:
"
Tues
"
,
...
...
@@ -44,48 +89,7 @@ $(document).ready(function() {
return
false
;
}
});
// 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
();
}
else
{
$
(
'
#info-location
'
).
hide
();
}
if
(
restaurant
.
open
){
$
(
'
#info-status
'
).
html
(
'
<b>Status:</b> Open
'
);
var
closing
=
Date
.
parse
(
restaurant
.
current
.
end_time
);
// 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
();
}
else
{
$
(
'
#info-status
'
).
html
(
'
<b>Status:</b> Closed
'
);
$
(
'
#info-next
'
).
empty
().
hide
()
}
// Display all open times for the main schedule
var
open_times
=
restaurant
.
main_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
=
''
;
}
}
dispalyInfo
(
restaurant
);
// If the user clicks on the same box twice it will close the info menu
if
(
lastClicked
==
grid_id
){
$
(
'
#info-body
'
).
slideToggle
(
300
)
...
...
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