Dashboard sipadu mbip
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

swfdetect.js 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. Copyright (c) 2010, Yahoo! Inc. All rights reserved.
  3. Code licensed under the BSD License:
  4. http://developer.yahoo.com/yui/license.html
  5. version: 3.4.0
  6. build: nightly
  7. */
  8. YUI.add('swfdetect', function(Y) {
  9. /**
  10. * Utility for Flash version detection
  11. * @module swfdetect
  12. */
  13. // shortcuts
  14. var version = 0,
  15. uA = Y.UA,
  16. lG = Y.Lang,
  17. sF = "ShockwaveFlash",
  18. mF, eP, vS, ax6, ax;
  19. function makeInt(n) {
  20. return parseInt(n, 10);
  21. }
  22. function parseFlashVersion (flashVer) {
  23. if (lG.isNumber(makeInt(flashVer[0]))) {
  24. uA.flashMajor = flashVer[0];
  25. }
  26. if (lG.isNumber(makeInt(flashVer[1]))) {
  27. uA.flashMinor = flashVer[1];
  28. }
  29. if (lG.isNumber(makeInt(flashVer[2]))) {
  30. uA.flashRev = flashVer[2];
  31. }
  32. }
  33. if (uA.gecko || uA.webkit || uA.opera) {
  34. if ((mF = navigator.mimeTypes['application/x-shockwave-flash'])) {
  35. if ((eP = mF.enabledPlugin)) {
  36. vS = eP.description.replace(/\s[rd]/g, '.').replace(/[A-Za-z\s]+/g, '').split('.');
  37. parseFlashVersion(vS);
  38. }
  39. }
  40. }
  41. else if(uA.ie) {
  42. try
  43. {
  44. ax6 = new ActiveXObject(sF + "." + sF + ".6");
  45. ax6.AllowScriptAccess = "always";
  46. }
  47. catch (e)
  48. {
  49. if(ax6 !== null)
  50. {
  51. version = 6.0;
  52. }
  53. }
  54. if (version === 0) {
  55. try
  56. {
  57. ax = new ActiveXObject(sF + "." + sF);
  58. vS = ax.GetVariable("$version").replace(/[A-Za-z\s]+/g, '').split(',');
  59. parseFlashVersion(vS);
  60. } catch (e2) {}
  61. }
  62. }
  63. Y.SWFDetect = {
  64. /**
  65. * Returns the version of either the Flash Player plugin (in Mozilla/WebKit/Opera browsers),
  66. * or the Flash Player ActiveX control (in IE), as a String of the form "MM.mm.rr", where
  67. * MM is the major version, mm is the minor version, and rr is the revision.
  68. * @method getFlashVersion
  69. */
  70. getFlashVersion : function () {
  71. return (String(uA.flashMajor) + "." + String(uA.flashMinor) + "." + String(uA.flashRev));
  72. },
  73. /**
  74. * Checks whether the version of the Flash player installed on the user's machine is greater
  75. * than or equal to the one specified. If it is, this method returns true; it is false otherwise.
  76. * @method isFlashVersionAtLeast
  77. * @return {Boolean} Whether the Flash player version is greater than or equal to the one specified.
  78. * @param flashMajor {int} The Major version of the Flash player to compare against.
  79. * @param flashMinor {int} The Minor version of the Flash player to compare against.
  80. * @param flashRev {int} The Revision version of the Flash player to compare against.
  81. */
  82. isFlashVersionAtLeast : function (flashMajor, flashMinor, flashRev) {
  83. var uaMajor = makeInt(uA.flashMajor),
  84. uaMinor = makeInt(uA.flashMinor),
  85. uaRev = makeInt(uA.flashRev);
  86. flashMajor = makeInt(flashMajor || 0);
  87. flashMinor = makeInt(flashMinor || 0);
  88. flashRev = makeInt(flashRev || 0);
  89. if (flashMajor === uaMajor) {
  90. if (flashMinor === uaMinor) {
  91. return flashRev <= uaRev;
  92. }
  93. return flashMinor < uaMinor;
  94. }
  95. return flashMajor < uaMajor;
  96. }
  97. };
  98. }, '3.4.0' ,{requires:['yui-base']});