reload only on selected pages
Doesn't refresh page when a form has been edited
This commit is contained in:
30
rowers/templates/monitorjobs.html
Normal file
30
rowers/templates/monitorjobs.html
Normal file
@@ -0,0 +1,30 @@
|
||||
<script type='text/javascript'
|
||||
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
|
||||
</script>
|
||||
|
||||
<script>
|
||||
var previous = null;
|
||||
var current = null;
|
||||
var formNotChanged = true;
|
||||
(function checkJobs() {
|
||||
console.log('polling');
|
||||
console.log(formNotChanged)
|
||||
$.getJSON(window.location.protocol + '//'+window.location.host + '/rowers/list-jobs/', function(json) {
|
||||
current = JSON.stringify(json);
|
||||
$('form').each(function() {
|
||||
$(this).change(function() {
|
||||
formNotChanged = false;
|
||||
console.log("Form Changed");
|
||||
console.log(formNotChanged)
|
||||
});
|
||||
});
|
||||
if (previous && current && previous !== current && formNotChanged) {
|
||||
console.log('refresh');
|
||||
location.reload();
|
||||
};
|
||||
previous = current;
|
||||
});
|
||||
setTimeout(checkJobs, 15000);
|
||||
}());
|
||||
|
||||
</script>
|
||||
Reference in New Issue
Block a user