1/* 2jquery.flash v1.3.1 - 02/01/10 3(c)2009 Stephen Belanger - MIT/GPL. 4http://docs.jquery.com/License 5*/ 6// IE uses a 5 year old version of Javascript, so let's add the missing indexOf method in manually. 7Array.prototype.indexOf = function(o,i){ 8 for(var j = this.length, i = i < 0 ? i + j < 0 ? 0 : i + j : i || 0; i < j && this[i] !== o; i++); 9 return j <= i ? - 1 : i; 10}; 11 12// Ok, enough fixing of IE's inadequacies, let's get on with it! 13jQuery.fn.extend({ 14 flash: function (opt) { 15 var has, cv, ie; 16 17 // Let's make some handy functions to minimize code repetition. 18 function attr(a, b) { 19 return ' ' + a + '="' + b + '"'; 20 } 21 function param(a, b) { 22 return '<param name="' + a + '" value="' + b + '" />'; 23 } 24 25 // Do some browser and flash version checking. 26 var p = navigator.plugins; 27 if (p && p.length) { 28 var f = p['Shockwave Flash']; 29 if (f) { 30 has = true; 31 if (f.description) cv = f.description.replace(/([a-zA-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split("."); 32 } 33 if (p['Shockwave Flash 2.0']) { 34 has = true; 35 cv = '2.0.0.11'; 36 } 37 } else { 38 try { 39 var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); 40 } catch(e) { 41 try { 42 var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); 43 cv = [6, 0, 21]; 44 has = true; 45 } catch(e) {}; 46 try { 47 axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); 48 } catch(e) {}; 49 } 50 if (axo != null) { 51 cv = axo.GetVariable("$version").split(" ")[1].split(","); 52 has = true; 53 ie = true; 54 } 55 } 56 57 // Finally, we're on to the REAL action. 58 $(this).each(function () { 59 // Don't even bother if we don't have Flash installed. 60 if (has) { 61 var e = $(this), 62 s = $.extend({ 63 'id': e.attr('id'), 64 'class': e.attr('class'), 65 'width': e.width(), 66 'height': e.height(), 67 'src': e.attr('href'), 68 'classid': 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000', 69 'pluginspace': 'http://get.adobe.com/flashplayer', 70 'availattrs': ['id', 'class', 'width', 'height', 'src'], 71 'availparams': ['src', 'bgcolor', 'quality', 'allowscriptaccess', 'allowfullscreen', 'flashvars', 'wmode'], 72 'version': '9.0.24' 73 }, opt), 74 a = s.availattrs, 75 b = s.availparams, 76 rv = s.version.split('.'), 77 o = '<object'; 78 79 // Set codebase, if not supplied in the settings. 80 if (!s.codebase) { 81 s.codebase = 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=' + rv.join(','); 82 } 83 84 // Use express install swf, if necessary. 85 if (s.express) { 86 for (var i in cv) { 87 if (parseInt(cv[i]) > parseInt(rv[i])) { 88 break; 89 } 90 if (parseInt(cv[i]) < parseInt(rv[i])) { 91 s.src = s.express; 92 } 93 } 94 } 95 96 // Convert flashvars to query string. 97 if (s.flashvars) { 98 s.flashvars = unescape($.param(s.flashvars)); 99 } 100 101 // Set browser-specific attributes 102 a = ie ? a.concat(['classid', 'codebase']) : a.concat(['pluginspage']); 103 104 // Add attributes to output buffer. 105 for (k in a) { 106 var n = (k == a.indexOf('src')) ? 'data' : a[k]; 107 o += s[a[k]] ? attr(n, s[a[k]]) : ''; 108 }; 109 o += '>'; 110 111 // Add parameters to output buffer. 112 for (k in b) { 113 var n = (k == b.indexOf('src')) ? 'movie' : b[k]; 114 o += s[b[k]] ? param(n, s[b[k]]) : ''; 115 }; 116 117 // Close and swap. 118 o += '</object>'; 119 e.replaceWith(o); 120 } 121 //no flash installed add "Flash not installed..." message 122 else { 123 $(this).append('<p class="flash_notice">This content requires the Flash Player. <a href="http://www.adobe.com/go/getflashplayer">Download Flash Player</a>.</p>'); 124 } 125 return this; 126 }); 127 } 128});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.