Browser Detect patch for Safari support
Scoodi’s picture uploading function is known to cause issues in Safari 2 when Keep-Alive connections are turned on. For performance reasons we want to enable Keep-Alives, however don’t need to inform older Safari users (though I don’t believe we have any current Safari 2 users) of the known issues.
We use Browser Detect within Scoodi for browser specific functions, which means IE at present, to do things such as correctly alpha blend images, etc. Unfortunately the current version of Browser Detect has limited support for Safari versioning, and especially doesn’t like the latest Safari versions (3+) which have slightly changed the user agent string.
Luckily, the details are documented so a patch is easy:
...
else if (this.isSafari) {
// Correctly identify version, see: http://developer.apple.com/internet/safari/faq.html#anchor2
if (ua.lastIndexOf('version/') != -1) {
this.versionMinor = parseFloat(ua.substring(ua.lastIndexOf('version/') + 8));
} else {
this.versionMinor = parseFloat(ua.substring(ua.lastIndexOf('safari/') + 7));
}
}
...
Which makes for some nice Safari detection:
...
this.isSafari1x = (this.isSafari && this.versionMajor >= 125 && this.versionMajor < = 312);
this.isSafari124 = (this.isSafari && this.versionMajor == 125);
this.isSafari132 = (this.isSafari && this.versionMajor == 312);
this.isSafari1up = (this.isSafari && (ua.lastIndexOf('version/') != -1 || this.versionMajor >= 125));
this.isSafari2x = (this.isSafari && this.versionMajor >= 419);
this.isSafari204 = (this.isSafari && this.versionMajor == 419);
this.isSafari2up = (this.isSafari && (ua.lastIndexOf('version/') != -1 || this.versionMajor >= 419));
this.isSafari3x = (this.isSafari && this.versionMajor == 3);
this.isSafari30 = (this.isSafari && this.versionMinor == 3.0);
this.isSafari31 = (this.isSafari && this.versionMinor == 3.1);
this.isSafari3up = (this.isSafari && ua.lastIndexOf('version/') != -1);
...
Here’s the complete file: browser_detect.js.
Hopefully something like this can get added back into the main distribution.