only do 1 ajax call to get ipv4 and v6 at the same time

This commit is contained in:
Thomas Waldmann 2013-11-03 04:58:28 +01:00
parent 9cc5bdf938
commit a515717125

View File

@ -114,34 +114,32 @@
<div id="ip_detection" style="display: none"> <div id="ip_detection" style="display: none">
{% if not request.session.ipv4 %} {% if not request.session.ipv4 %}
<script type="text/javascript"> <script type="text/javascript">
function insert_src_v4() { function insert_img_ipv4() {
$('#ip_detection').add( $('#ip_detection').add(
'<img src="//{{ WWW_IPV4_HOST }}/detectip/{{ request.session.session_key }}/" >'); '<img src="//{{ WWW_IPV4_HOST }}/detectip/{{ request.session.session_key }}/" >');
}; };
$(setTimeout("insert_src_v4()", 1000)); $(setTimeout("insert_img_ipv4()", 1000));
function insert_ip_v4() {
$.getJSON("{% url 'ajax_get_ips' %}")
.done(function(data) {
$('#ipv4').text(data['ipv4']);
});
};
$(setTimeout("insert_ip_v4()", 2000));
</script> </script>
{% endif %} {% endif %}
{% if not request.session.ipv6 %} {% if not request.session.ipv6 %}
<script type="text/javascript"> <script type="text/javascript">
function insert_src_v6() { function insert_img_ipv6() {
$('#ip_detection').add( $('#ip_detection').add(
'<img src="//{{ WWW_IPV6_HOST }}/detectip/{{ request.session.session_key }}/" >'); '<img src="//{{ WWW_IPV6_HOST }}/detectip/{{ request.session.session_key }}/" >');
}; };
$(setTimeout("insert_src_v6()", 1000)); $(setTimeout("insert_img_ipv6()", 1000));
function insert_ip_v6() { </script>
{% endif %}
{% if not request.session.ipv4 or not request.session.ipv6 %}
<script type="text/javascript">
function insert_ips() {
$.getJSON("{% url 'ajax_get_ips' %}") $.getJSON("{% url 'ajax_get_ips' %}")
.done(function(data) { .done(function(data) {
$('#ipv4').text(data['ipv4']);
$('#ipv6').text(data['ipv6']); $('#ipv6').text(data['ipv6']);
}); });
}; };
$(setTimeout("insert_ip_v6()", 2000)); $(setTimeout("insert_ips()", 2000));
</script> </script>
{% endif %} {% endif %}
</div> </div>