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
Christopher M Reffett
whats-open
Commits
eca0bb65
Commit
eca0bb65
authored
Sep 19, 2013
by
Renfred Harper
Browse files
Add auto grid updating functionality
parent
6a49da9f
Changes
1
Hide whitespace changes
Inline
Side-by-side
website/static/js/grid.js
View file @
eca0bb65
...
...
@@ -106,4 +106,22 @@ $.ajax({
restaurants
=
data
.
data
;
update_grid
(
restaurants
);
construct_grid
(
restaurants
);
// Update the grid on the hour and 30 minutes after the hour to reflect current hours without refreshing
var
now
=
new
Date
();
// Find out the time to wait till the next half hour period
if
(
now
.
getMinutes
()
<=
30
)
{
var
timeout
=
new
Date
(
now
.
getFullYear
(),
now
.
getMonth
(),
now
.
getDate
(),
now
.
getHours
(),
30
,
1
,
0
)
-
now
;
}
else
{
var
timeout
=
new
Date
(
now
.
getFullYear
(),
now
.
getMonth
(),
now
.
getDate
(),
now
.
getHours
()
+
1
,
0
,
1
,
0
)
-
now
;
}
// Update the grid on the next half hour, then keep updating every 30 minutes (1800000 milliseconds)
setTimeout
(
function
(){
update_grid
(
restaurants
);
construct_grid
(
restaurants
);
},
timeout
);
setInterval
(
function
(){
update_grid
(
restaurants
);
construct_grid
(
restaurants
);
},
1800000
);
});
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