/** * Copyright (c) 2007 - 2009, James Auldridge * All rights reserved. * * Licensed under the BSD License: * http://www.opensource.org/licenses/bsd-license.php * */ var jaaulde = window.jaaulde || {}; jaaulde.utils = jaaulde.utils || {}; jaaulde.utils.flashsniffer = ( function() { var lastMajorRelease = 10; var installed = false; var version = null; ( function() { var fp, fpd, fAX; if( navigator.plugins && navigator.plugins.length ) { fp = navigator.plugins['Shockwave Flash']; if( fp ) { if( fp.description ) { fpd = fp.description; try { version = fpd.match(/(\d+)\./)[1]; } catch( e1 ) { } if( ! isNaN( version ) ) { installed = true; } } } else if( navigator.plugins['Shockwave Flash 2.0'] ) { installed = true; version = 2; } } else if( navigator.mimeTypes && navigator.mimeTypes.length ) { fp = navigator.mimeTypes['application/x-shockwave-flash']; if( fp && fp.enabledPlugin ) { installed = true; } } else { for( var i = lastMajorRelease; i >= 2; i-- ) { try { fAX = new ActiveXObject( 'ShockwaveFlash.ShockwaveFlash.' + i ); installed = true; version = i; break; } catch( e2 ) { } } if( ! installed ) { try { fAX = new ActiveXObject( 'ShockwaveFlash.ShockwaveFlash' ); installed = true; version = 2; } catch( e3 ) { } } //Clean up vars as some of the above could have led to istantiated ActiveXObjects fp = null; fpd = null; fAX = null; delete fp; delete fpd; delete fAX; } } )(); //Public Interface return { /* installed - Determine if Flash is installed * * @return BOOL true if Flash is installed, false if not */ installed: function() { return !! installed; }, /* version - Get version of installed Flash * * @return INT if Flash is installed and properly detected, else NULL */ version: function() { return version; }, /* isLatestVersion - Determine if Flash is installed the latest released version of Flash * (as configured in property 'lastMajorRelease' documented above) * * @return BOOL true if Flash is at latest version, false if not */ isLatestVersion: function() { return ( !! installed && version == lastMajorRelease ); }, /* isVersion - Determine if Flash is installed at a specified major version * * @parameter INT exactVersion the exact version for which to check * @return BOOL true if Flash is at specified version, false if not */ isVersion: function( exactVersion ) { return ( !! installed && version == exactVersion ); }, /* meetsMinVersion - Determine if Flash is installed at a specified minimum version * * @parameter INT minVersion the version number that installed Flash should be at OR above * @return BOOL true if Flash is at minimum version, false if not */ meetsMinVersion: function( minVersion ) { return ( !! installed && version !== null && version >= minVersion ); } }; } )();