Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.
 
 
 
 
 
 

220 рядки
8.5 KiB

  1. /**
  2. * SWFObject v1.4.4: Flash Player detection and embed - http://blog.deconcept.com/swfobject/
  3. *
  4. * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License:
  5. * http://www.opensource.org/licenses/mit-license.php
  6. *
  7. * **SWFObject is the SWF embed script formerly known as FlashObject. The name was changed for
  8. * legal reasons.
  9. */
  10. if(typeof deconcept == "undefined") var deconcept = new Object();
  11. if(typeof deconcept.util == "undefined") deconcept.util = new Object();
  12. if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object();
  13. deconcept.SWFObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){
  14. if (!document.getElementById) { return; }
  15. this.DETECT_KEY = detectKey ? detectKey : 'detectflash';
  16. this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY);
  17. this.params = new Object();
  18. this.variables = new Object();
  19. this.attributes = new Array();
  20. if(swf) { this.setAttribute('swf', swf); }
  21. if(id) { this.setAttribute('id', id); }
  22. if(w) { this.setAttribute('width', w); }
  23. if(h) { this.setAttribute('height', h); }
  24. if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); }
  25. this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion();
  26. if(c) { this.addParam('bgcolor', c); }
  27. var q = quality ? quality : 'high';
  28. this.addParam('quality', q);
  29. this.setAttribute('useExpressInstall', useExpressInstall);
  30. this.setAttribute('doExpressInstall', false);
  31. var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location;
  32. this.setAttribute('xiRedirectUrl', xir);
  33. this.setAttribute('redirectUrl', '');
  34. if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); }
  35. }
  36. deconcept.SWFObject.prototype = {
  37. setAttribute: function(name, value){
  38. this.attributes[name] = value;
  39. },
  40. getAttribute: function(name){
  41. return this.attributes[name];
  42. },
  43. addParam: function(name, value){
  44. this.params[name] = value;
  45. },
  46. getParams: function(){
  47. return this.params;
  48. },
  49. addVariable: function(name, value){
  50. this.variables[name] = value;
  51. },
  52. getVariable: function(name){
  53. return this.variables[name];
  54. },
  55. getVariables: function(){
  56. return this.variables;
  57. },
  58. getVariablePairs: function(){
  59. var variablePairs = new Array();
  60. var key;
  61. var variables = this.getVariables();
  62. for(key in variables){
  63. variablePairs.push(key +"="+ variables[key]);
  64. }
  65. return variablePairs;
  66. },
  67. getSWFHTML: function() {
  68. var swfNode = "";
  69. if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture
  70. if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "PlugIn"); }
  71. swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"';
  72. swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
  73. var params = this.getParams();
  74. for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
  75. var pairs = this.getVariablePairs().join("&");
  76. if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
  77. swfNode += '/>';
  78. } else { // PC IE
  79. if (this.getAttribute("doExpressInstall")) { this.addVariable("MMplayerType", "ActiveX"); }
  80. swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
  81. swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
  82. var params = this.getParams();
  83. for(var key in params) {
  84. swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
  85. }
  86. var pairs = this.getVariablePairs().join("&");
  87. if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
  88. swfNode += "</object>";
  89. }
  90. return swfNode;
  91. },
  92. write: function(elementId){
  93. if(this.getAttribute('useExpressInstall')) {
  94. // check to see if we need to do an express install
  95. var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]);
  96. if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) {
  97. this.setAttribute('doExpressInstall', true);
  98. this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl')));
  99. document.title = document.title.slice(0, 47) + " - Flash Player Installation";
  100. this.addVariable("MMdoctitle", document.title);
  101. }
  102. }
  103. if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){
  104. var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
  105. n.innerHTML = this.getSWFHTML();
  106. return true;
  107. }else{
  108. if(this.getAttribute('redirectUrl') != "") {
  109. document.location.replace(this.getAttribute('redirectUrl'));
  110. }
  111. }
  112. return false;
  113. }
  114. }
  115. /* ---- detection functions ---- */
  116. deconcept.SWFObjectUtil.getPlayerVersion = function(){
  117. var PlayerVersion = new deconcept.PlayerVersion([0,0,0]);
  118. if(navigator.plugins && navigator.mimeTypes.length){
  119. var x = navigator.plugins["Shockwave Flash"];
  120. if(x && x.description) {
  121. PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."));
  122. }
  123. }else{
  124. // do minor version lookup in IE, but avoid fp6 crashing issues
  125. // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/
  126. try{
  127. var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
  128. }catch(e){
  129. try {
  130. var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
  131. PlayerVersion = new deconcept.PlayerVersion([6,0,21]);
  132. axo.AllowScriptAccess = "always"; // throws if player version < 6.0.47 (thanks to Michael Williams @ Adobe for this code)
  133. } catch(e) {
  134. if (PlayerVersion.major == 6) {
  135. return PlayerVersion;
  136. }
  137. }
  138. try {
  139. axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
  140. } catch(e) {}
  141. }
  142. if (axo != null) {
  143. PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(","));
  144. }
  145. }
  146. return PlayerVersion;
  147. }
  148. deconcept.PlayerVersion = function(arrVersion){
  149. this.major = arrVersion[0] != null ? parseInt(arrVersion[0]) : 0;
  150. this.minor = arrVersion[1] != null ? parseInt(arrVersion[1]) : 0;
  151. this.rev = arrVersion[2] != null ? parseInt(arrVersion[2]) : 0;
  152. }
  153. deconcept.PlayerVersion.prototype.versionIsValid = function(fv){
  154. if(this.major < fv.major) return false;
  155. if(this.major > fv.major) return true;
  156. if(this.minor < fv.minor) return false;
  157. if(this.minor > fv.minor) return true;
  158. if(this.rev < fv.rev) return false;
  159. return true;
  160. }
  161. /* ---- get value of query string param ---- */
  162. deconcept.util = {
  163. getRequestParameter: function(param) {
  164. var q = document.location.search || document.location.hash;
  165. if(q) {
  166. var pairs = q.substring(1).split("&");
  167. for (var i=0; i < pairs.length; i++) {
  168. if (pairs[i].substring(0, pairs[i].indexOf("=")) == param) {
  169. return pairs[i].substring((pairs[i].indexOf("=")+1));
  170. }
  171. }
  172. }
  173. return "";
  174. }
  175. }
  176. /* fix for video streaming bug */
  177. deconcept.SWFObjectUtil.cleanupSWFs = function() {
  178. if (window.opera || !document.all) return;
  179. var objects = document.getElementsByTagName("OBJECT");
  180. for (var i=0; i < objects.length; i++) {
  181. objects[i].style.display = 'none';
  182. for (var x in objects[i]) {
  183. if (typeof objects[i][x] == 'function') {
  184. objects[i][x] = function(){};
  185. }
  186. }
  187. }
  188. }
  189. // fixes bug in fp9 see http://blog.deconcept.com/2006/07/28/swfobject-143-released/
  190. deconcept.SWFObjectUtil.prepUnload = function() {
  191. __flash_unloadHandler = function(){};
  192. __flash_savedUnloadHandler = function(){};
  193. if (typeof window.onunload == 'function') {
  194. var oldUnload = window.onunload;
  195. window.onunload = function() {
  196. deconcept.SWFObjectUtil.cleanupSWFs();
  197. oldUnload();
  198. }
  199. } else {
  200. window.onunload = deconcept.SWFObjectUtil.cleanupSWFs;
  201. }
  202. }
  203. if (typeof window.onbeforeunload == 'function') {
  204. var oldBeforeUnload = window.onbeforeunload;
  205. window.onbeforeunload = function() {
  206. deconcept.SWFObjectUtil.prepUnload();
  207. oldBeforeUnload();
  208. }
  209. } else {
  210. window.onbeforeunload = deconcept.SWFObjectUtil.prepUnload;
  211. }
  212. /* add Array.push if needed (ie5) */
  213. if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }}
  214. /* add some aliases for ease of use/backwards compatibility */
  215. var getQueryParamValue = deconcept.util.getRequestParameter;
  216. var FlashObject = deconcept.SWFObject; // for legacy support
  217. var SWFObject = deconcept.SWFObject;