reload only on selected pages
Doesn't refresh page when a form has been edited
This commit is contained in:
@@ -51,6 +51,11 @@
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
{% include "monitorjobs.html" %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,10 @@
|
||||
|
||||
{% block title %}Rowsandall Recent Graphs{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
{% include "monitorjobs.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1>Recent Graphs</h1>
|
||||
|
||||
|
||||
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>
|
||||
@@ -2,6 +2,10 @@
|
||||
{% load staticfiles %}
|
||||
{% load rowerfilters %}
|
||||
|
||||
{% block scripts %}
|
||||
{% include "monitorjobs.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}Workouts{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
{% load rowerfilters %}
|
||||
|
||||
{% block title %}Workouts{% endblock %}
|
||||
{% block scripts %}
|
||||
{% include "monitorjobs.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
|
||||
@@ -23,6 +23,11 @@
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
{% include "monitorjobs.html" %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
<div id="page" class="grid_12 alpha">
|
||||
<div class="grid_10 prefix_2 alpha">
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
{% load rowerfilters %}
|
||||
{% load tz %}
|
||||
|
||||
{% block scripts %}
|
||||
{% include "monitorjobs.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}Change Workout {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
||||
@@ -13,6 +13,13 @@
|
||||
{% block og_description %}{{ workout.name }}
|
||||
{{ workout.date }} - {{ workout.distance }}m - {{ workout.duration |durationprint:"%H:%M:%S.%f" }}{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
{% include "monitorjobs.html" %}
|
||||
<script type='text/javascript'
|
||||
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div id="workouts" class="grid_6 alpha">
|
||||
|
||||
@@ -89,8 +96,9 @@
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="grid_6 alpha">
|
||||
<form enctype="multipart/form-data" action="" method="post">
|
||||
<div id="form-div" class="grid_6 alpha">
|
||||
<form id="importantform"
|
||||
enctype="multipart/form-data" action="" method="post">
|
||||
<table width=100%>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
{% extends "base.html" %}
|
||||
{% load staticfiles %}
|
||||
{% load rowerfilters %}
|
||||
{% block scripts %}
|
||||
{% include "monitorjobs.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block title %}{{ workout.name }} {% endblock %}
|
||||
{% block og_title %}{{ workout.name }} {% endblock %}
|
||||
|
||||
@@ -9,32 +9,7 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<html lang="en">
|
||||
<head>
|
||||
<script type='text/javascript'
|
||||
src='https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js'>
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
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);
|
||||
if (previous && current && previous !== current) {
|
||||
console.log('refresh');
|
||||
location.reload();
|
||||
};
|
||||
previous = current;
|
||||
});
|
||||
setTimeout(checkJobs, 15000);
|
||||
}());
|
||||
|
||||
</script>
|
||||
{% block scripts %} {% endblock %}
|
||||
|
||||
<script src="/static/cookielaw/js/cookielaw.js"></script>
|
||||
{% analytical_head_top %}
|
||||
|
||||
Reference in New Issue
Block a user