webif/var/mongoose/html/lib/jquery.plugin/iajax/iajax.js
hummypkg 0f1bbed6b9 migrating
git-svn-id: file:///root/webif/svn/humax/pkg/src/webif/trunk@1789 2a923420-c742-0410-a762-8d5b09965624
2014-02-21 21:25:33 +00:00

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);
}
});