js updater: add myip output to status, add timestamps

This commit is contained in:
Thomas Waldmann 2013-12-06 21:15:42 +01:00
parent 915d64b592
commit a58a957b28

View File

@ -5,7 +5,7 @@
<div class="jumbotron">
<h2>Browser-based Updater</h2>
<p>
Host {{ hostname }} (pw {{ secret }}) will get automatically updated as long as you keep this window open.
Host {{ hostname }} will get automatically updated as long as you keep this window open.
</p>
<noscript>
<p class="text-danger">
@ -14,7 +14,10 @@
</noscript>
<h2>Updater Status</h2>
<dl>
<dt>Last response:</dt><dd><span id="response"></span></dd>
<dt>My IP:</dt>
<dd><span id="myip"></span> (<span id="myip_timestamp"></span>)</dd>
<dt>Last update response:</dt>
<dd><span id="response"></span> (<span id="response_timestamp"></span>)</dd>
</dl>
</div>
<script type="text/javascript">
@ -25,6 +28,8 @@
$.get("{% url 'myip' %}")
.done(function( data ) {
ip = data;
$('#myip').text(ip);
$('#myip_timestamp').text(new Date().toISOString());
if(ip != last_ip) {
$.ajax({
url: "{% url 'nic_update' %}",
@ -33,10 +38,12 @@
})
.done(function( data ) {
$('#response').text(data);
$('#response_timestamp').text(new Date().toISOString());
last_ip = ip;
})
.fail(function (data) {
$('#response').text('update failed');
$('#response_timestamp').text(new Date().toISOString());
});
}
})