Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.82 KB | None | 0 0
  1. /*
  2. __ _ ___ ___ ___ ___ ___ ____ _ __ ___ ___
  3. / _` |/ / / __/ _ \ / _ \ / / / __/| '_ ` _ \ / /
  4. | (_| |\ \| (_| (_) | (_) |\ \ | (__ | | | | | |\ \
  5. \__,_|/__/ \___\___/ \___/ /__/ \___\|_| |_| |_|/__/
  6.  
  7. */
  8.  
  9. (function($) {
  10.  
  11.  
  12. /**
  13. * START FUNCTION isFlashEnabled(options)
  14. *
  15. * FUNCTION: isFlashEnabled(options)
  16. *
  17. * options
  18. * --------
  19. * ret -- Return or Show Flash informations -- [Default = false]
  20. * id -- HTML Tag ID for show information -- [Default = 'info-flash']. Used only if ret = false.
  21. * textInstalled -- Text for message if installled on Windows Explorer -- [Default = 'Flash is installed.']
  22. * textNotInstalled -- Text for message if not installled -- [Default = 'Flash is not installed.']
  23. * isInstalled -- Text for message if installled -- [Default = 'The {0} {1} is installed.']
  24. * name -- [ONLY READ] - The Flash Name
  25. * version -- [ONLY READ] - The Flash Version
  26. * description -- [ONLY READ] - The Flash Description
  27. * result: -- [ONLY READ] - The flag installation -- 0 = No Installed, 1 = Installed -- [Default = 0]
  28. *
  29. * DESCRIPTION: Checks whether the flash is installed and enabled on the Browser
  30. *
  31. * USE:
  32. * -----
  33. * A) For print in HTML Tag ID
  34. * jQuery(window).isFlashEnabled({ret:false, id:'info-flash'});
  35. *
  36. * B) For return Array with Flash informations. For use with multilanguage info's and CSS id or classes.
  37. * var FlashResult = jQuery(window).isFlashEnabled({ret:true});
  38. * switch ( FlashResult[0] ) {
  39. * case 0:
  40. * jQuery('.info-flash').text('The Flash is not installed');
  41. * break;
  42. *
  43. * case 1:
  44. * jQuery('.info-flash').text( String.format(\"The {0} {1} is installed\", FlashResult[1], FlashResult[2]) );
  45. * break;
  46. * }
  47. *
  48. * EXPORT:
  49. * In English -> The Shockwave Flash 20.0.0.267 is installed.
  50. * In Greek -> Το Shockwave Flash 20.0.0.267 είναι εγκατεστημένο
  51. *
  52. **/
  53. $.fn.isFlashEnabled = function(options) {
  54. defaults = $.extend({
  55. ret: false,
  56. id: 'info-flash',
  57. textInstalled: 'Flash is installed.',
  58. textNotInstalled: 'Flash is not installed.',
  59. isInstalled: 'The {0} {1} is installed.',
  60. name: '',
  61. version: '',
  62. description: '',
  63. result: 0
  64. }, options);
  65.  
  66. /* Defaults Only Read */
  67. defaults.name = '';
  68. defaults.version = '';
  69. defaults.description = '';
  70. defaults.result = 0;
  71.  
  72. var opt = defaults;
  73.  
  74. if (navigator.mimeTypes && navigator.mimeTypes.length > 0) {
  75. // Firefox, Google Chrome, Safari, Opera
  76. var mime = navigator.mimeTypes['application/x-shockwave-flash'];
  77. if (mime && mime.enabledPlugin) {
  78. opt.result = 1;
  79. opt.name = mime.enabledPlugin.name;
  80. opt.version = mime.enabledPlugin.version;
  81. opt.decription = mime.enabledPlugin.description;
  82. }
  83. } else {
  84. if (typeof (ActiveXObject) != "undefined") {
  85. // Internet Explorer
  86. try {
  87. var flash = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.1");
  88. if (flash) {
  89. opt.result = 1;
  90. }
  91. } catch (e) {}
  92. }
  93. }
  94.  
  95.  
  96. switch (opt.ret) {
  97. case false:
  98. var info = document.getElementById(opt.id);
  99. switch (opt.result) {
  100. case 0:
  101. info.innerHTML = opt.textNotInstalled;
  102. return opt.result;
  103. break;
  104.  
  105. case 1:
  106. if (opt.version != '') info.innerHTML = String.format(opt.isInstalled, opt.name, opt.version);
  107. else info.innerHTML = opt.textInstalled;
  108. return opt.result;
  109. break;
  110.  
  111. default:
  112. info.innerHTML = opt.textNotInstalled;
  113. return opt.result;
  114. }
  115.  
  116. break;
  117.  
  118. case true:
  119. var res = [opt.result, opt.name, opt.version, opt.decription];
  120. return res;
  121. break;
  122.  
  123. default:
  124. return false;
  125. }
  126. };
  127. /* ---- END FUNCTION isFlashEnabled ---- */
  128.  
  129. // .......
  130. })(jQuery);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement