libs/web: make apply_xhr less aggressive, only rerequest status if previous response returned

This commit is contained in:
Jo-Philipp Wich 2010-11-17 15:09:18 +00:00
parent e077f36436
commit 4121f34ac0

View file

@ -20,35 +20,33 @@ $Id$
apply_xhr.get('<%=luci.dispatcher.build_url("servicectl", "restart", table.concat(configs, ","))%>', null, apply_xhr.get('<%=luci.dispatcher.build_url("servicectl", "restart", table.concat(configs, ","))%>', null,
function() { function() {
var intv = window.setInterval( var checkfinish = function() {
function() { apply_xhr.get('<%=luci.dispatcher.build_url("servicectl", "status")%>', null,
apply_xhr.abort(); function(x) {
apply_xhr.get('<%=luci.dispatcher.build_url("servicectl", "status")%>', null, if( x.responseText == 'finish' )
function(x) { {
if( x.responseText == 'finish' ) var e = document.getElementById('cbi-apply-<%=id%>-status');
if( e )
{ {
window.clearInterval(intv); e.innerHTML = '<%:Configuration applied.%>';
window.setTimeout(function() {
var e = document.getElementById('cbi-apply-<%=id%>-status'); e.parentNode.style.display = 'none';
if( e ) <% if redirect then %>location.href='<%=redirect%>';<% end %>
{ }, 1000);
e.innerHTML = '<%:Configuration applied.%>';
window.setTimeout(function() {
e.parentNode.style.display = 'none';
<% if redirect then %>location.href='<%=redirect%>';<% end %>
}, 1000);
}
}
else
{
var e = document.getElementById('cbi-apply-<%=id%>-status');
if( e && x.responseText ) e.innerHTML = x.responseText;
} }
} }
); else
}, 1000 {
) var e = document.getElementById('cbi-apply-<%=id%>-status');
if( e && x.responseText ) e.innerHTML = x.responseText;
window.setTimeout(checkfinish, 1000);
}
}
);
}
window.setTimeout(checkfinish, 1000);
} }
); );
]]></script> ]]></script>