forked from hummypkg/webif
2ab6f7caa2
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1398 2a923420-c742-0410-a762-8d5b09965624
45 lines
859 B
JavaScript
45 lines
859 B
JavaScript
|
|
jQuery.ajaxPrefilter(function(options, _, jqXHR) {
|
|
if (jQuery.isFunction(options.progress))
|
|
{
|
|
var xhrFactory = options.xhr;
|
|
var interval;
|
|
|
|
options.xhr = function() {
|
|
var xhr = xhrFactory.apply(this, arguments);
|
|
var partial = "";
|
|
var prevcount = 1;
|
|
|
|
interval = setInterval(function() {
|
|
var responseText;
|
|
var jQueryPartial;
|
|
|
|
try {
|
|
responseText = xhr.responseText;
|
|
|
|
if (responseText &&
|
|
responseText.length > partial.length)
|
|
{
|
|
options.progress(
|
|
responseText.substring(
|
|
partial.length));
|
|
partial = responseText;
|
|
}
|
|
} catch(e) {
|
|
if (window.console)
|
|
console.log(e);
|
|
}
|
|
}, options.progressInterval);
|
|
|
|
return xhr;
|
|
};
|
|
function stop()
|
|
{
|
|
if (interval)
|
|
clearInterval(interval);
|
|
}
|
|
jqXHR.then(stop, stop);
|
|
}
|
|
});
|
|
|