Created
August 10, 2012 17:05
-
-
Save badrij/3315690 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var AjaxTracker = { | |
PENDING_REQUESTS: $A([]), | |
onCreate: function(request){ | |
if (!request.url.match(/gadgets\/js\//)) { | |
this.PENDING_REQUESTS.push(request.url); | |
} | |
}, | |
onComplete: function(request){ | |
this.PENDING_REQUESTS = this.PENDING_REQUESTS.without(request.url); | |
}, | |
onException: function(request, exception){ | |
try { | |
this.onComplete(request); | |
}catch(e){ | |
if (Prototype.isFireBugsEnabled) { | |
console.log("Got Exception on request: " + request.url); | |
console.log(e); | |
throw(e); | |
} | |
} | |
}, | |
allAjaxComplete: function(includeCardSummary){ | |
var requests = this.PENDING_REQUESTS.reject(function(url) { | |
return url.match(/cards\/card_summary/) || url.match(/also_viewing/); | |
}); | |
return requests.size() == 0; | |
} | |
}; | |
Ajax.Responders.register(AjaxTracker); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment