webif/var/mongoose/html/js/iajax.js
hummypkg 9b2f138fd9 update
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@420 2a923420-c742-0410-a762-8d5b09965624
2011-09-25 18:25:09 +00:00

52 lines
1.3 KiB
JavaScript

jQuery.ajaxPrefilter(function(options, _, jqXHR) {
if (jQuery.isFunction(options.progress)) {
var xhrFactory = options.xhr,
interval;
options.xhr = function() {
var xhr = xhrFactory.apply(this, arguments),
partial = "",
prevcount = 1;
interval = setInterval(function() {
var responseText,
jQueryPartial;
try {
responseText = xhr.responseText;
if (responseText && (responseText.length > partial.length))
{
partial = responseText;
jQueryPartial = $(partial).filter("*")
if (jQueryPartial.length > prevcount) {
prevcount = jQueryPartial.length;
options.progress(jQueryPartial.filter("*:not(:last)"));
}
}
} catch(e) {
if (window.console)
console.log(e);
}
}, options.progressInterval);
return xhr;
};
function stop()
{
if (interval)
clearInterval(interval);
}
jqXHR.then(stop, stop);
}
});