Skip to content

Instantly share code, notes, and snippets.

@savetheclocktower
Created May 19, 2009 21:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save savetheclocktower/114444 to your computer and use it in GitHub Desktop.
Save savetheclocktower/114444 to your computer and use it in GitHub Desktop.
Object.extend(Ajax, {
registerURL: function(url, options) {
options = Object.extend({
instancePooling: true,
autoUpdatePlayer: true
}, options || {});
this._registry.set(url, options);
},
getOptionsForURL: function(url) {
return this._registry.detect( function(pair) {
return pair.key.include(url) ? pair.value : null;
});
},
_registry: $H()
});
Ajax.Request.addMethods({
initialize: function($super, url, options) {
$super(options);
// Use flXHR if we qualify for it; otherwise fall back to the default
// `Ajax.getTransport`.
var flXHRoptions = Ajax.getOptionsForURL(url);
if (this.options.asynchronous && $w('POST GET').include(
this.options.method) && flXHRoptions) {
this.transport = new flensed.flXHR(flXHRoptions);
} else {
this.transport = Ajax.getTransport();
}
this.request(url);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment