Skip to content

Instantly share code, notes, and snippets.

@gudmundurh
Created April 14, 2011 12:56
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 gudmundurh/919415 to your computer and use it in GitHub Desktop.
Save gudmundurh/919415 to your computer and use it in GitHub Desktop.
var Upload = {
getDefaultRuntimes: function () {
var runtimes = ['flash', 'html4'];
var platform = navigator.platform || '';
if (navigator.platform === 'Win32' && this.isSilverlightInstalled('4.0.0.0'))
runtimes.unshift('silverlight');
return runtimes.join(',');
},
isSilverlightInstalled: function (version) {
// taken from plupload.silverlight.js
var isVersionSupported = false, container = null, control = null, actualVer,
actualVerArray, reqVerArray, requiredVersionPart, actualVersionPart, index = 0;
try {
try {
control = new ActiveXObject('AgControl.AgControl');
if (control.IsVersionSupported(version)) {
isVersionSupported = true;
}
control = null;
} catch (e) {
var plugin = navigator.plugins["Silverlight Plug-In"];
if (plugin) {
actualVer = plugin.description;
if (actualVer === "1.0.30226.2") {
actualVer = "2.0.30226.2";
}
actualVerArray = actualVer.split(".");
while (actualVerArray.length > 3) {
actualVerArray.pop();
}
while (actualVerArray.length < 4) {
actualVerArray.push(0);
}
reqVerArray = version.split(".");
while (reqVerArray.length > 4) {
reqVerArray.pop();
}
do {
requiredVersionPart = parseInt(reqVerArray[index], 10);
actualVersionPart = parseInt(actualVerArray[index], 10);
index++;
} while (index < reqVerArray.length && requiredVersionPart === actualVersionPart);
if (requiredVersionPart <= actualVersionPart && !isNaN(requiredVersionPart)) {
isVersionSupported = true;
}
}
}
} catch (e2) {
isVersionSupported = false;
}
return isVersionSupported;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment