forked from hummypkg/webif
64b73ee14b
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@273 2a923420-c742-0410-a762-8d5b09965624
51 lines
1.3 KiB
JavaScript
51 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) {
|
|
alert(e);
|
|
}
|
|
}, options.progressInterval);
|
|
|
|
return xhr;
|
|
};
|
|
function stop()
|
|
{
|
|
if (interval)
|
|
clearInterval(interval);
|
|
}
|
|
jqXHR.then(stop, stop);
|
|
}
|
|
});
|
|
|