reload uses timeout
This commit is contained in:
@@ -9,29 +9,31 @@
|
|||||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
|
<script type='text/javascript'
|
||||||
<script>
|
src='http://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
|
||||||
var previous = null;
|
</script>
|
||||||
var current = null;
|
|
||||||
$(document).ready(function() {
|
|
||||||
$.getJSON('http://localhost:8000/rowers/list-jobs/', function(json) {
|
|
||||||
current = JSON.stringify(json);
|
|
||||||
previous = current;
|
|
||||||
});
|
|
||||||
console.log('initial poll');
|
|
||||||
});
|
|
||||||
|
|
||||||
setInterval(function() {
|
<script type="text/javascript">
|
||||||
$.getJSON('http://localhost:8000/rowers/list-jobs/', function(json) {
|
window.jQuery || document.write('<script src="/static/js/jquery-3.1.0.js"><' + '/script>');
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
<script>
|
||||||
|
var previous = null;
|
||||||
|
var current = null;
|
||||||
|
(function checkJobs() {
|
||||||
|
console.log('polling');
|
||||||
|
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/list-jobs/', function(json) {
|
||||||
current = JSON.stringify(json);
|
current = JSON.stringify(json);
|
||||||
if (previous && current && previous !== current) {
|
if (previous && current && previous !== current) {
|
||||||
console.log('refresh');
|
console.log('refresh');
|
||||||
location.reload();
|
location.reload();
|
||||||
};
|
};
|
||||||
previous = current;
|
previous = current;
|
||||||
});
|
});
|
||||||
console.log('polling');
|
setTimeout(checkJobs, 15000);
|
||||||
}, 15000)
|
}());
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<script src="/static/cookielaw/js/cookielaw.js"></script>
|
<script src="/static/cookielaw/js/cookielaw.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user