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,15 +20,11 @@ $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.abort();
apply_xhr.get('<%=luci.dispatcher.build_url("servicectl", "status")%>', null, apply_xhr.get('<%=luci.dispatcher.build_url("servicectl", "status")%>', null,
function(x) { function(x) {
if( x.responseText == 'finish' ) if( x.responseText == 'finish' )
{ {
window.clearInterval(intv);
var e = document.getElementById('cbi-apply-<%=id%>-status'); var e = document.getElementById('cbi-apply-<%=id%>-status');
if( e ) if( e )
{ {
@ -44,11 +40,13 @@ $Id$
var e = document.getElementById('cbi-apply-<%=id%>-status'); var e = document.getElementById('cbi-apply-<%=id%>-status');
if( e && x.responseText ) e.innerHTML = x.responseText; if( e && x.responseText ) e.innerHTML = x.responseText;
window.setTimeout(checkfinish, 1000);
} }
} }
); );
}, 1000 }
)
window.setTimeout(checkfinish, 1000);
} }
); );
]]></script> ]]></script>