1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180
| /*
* FlashObject embed
*
* by Geoff Stearns (geoff@choppingblock.com, http://www.choppingblock.com/)
*
* v1.0.7 - 11-17-2004
*
* Create and write a flash movie to the page, includes detection
*
* Usage:
*
* myFlash = new FlashObject("path/to/swf.swf", "swfid", "width", "height", flashversion, "backgroundcolor");
* myFlash.altTxt = "Upgrade your Flash Player!"; // optional
* myFlash.addParam("wmode", "transparent"); // optional
* myFlash.addVariable("varname1", "varvalue"); // optional
* myFlash.addVariable("varname2", getQueryParamValue("myvar")); // optional
* myFlash.write();
*
*/
FlashObject = function(swf, id, w, h, ver, c) {
this.swf = swf;
this.id = id;
this.width = w;
this.height = h;
this.version = ver || 6; // default to 6
this.align = "middle"; // default to middle
this.redirect = "";
this.sq = document.location.search.split("?")[1] || "";
this.bypassTxt ="<p>si la page ne s'affiche pas <a href='?detectflash=false&"+ this.sq +"'>Cliquer Ici</a>.</p>";
this.params = new Object();
this.variables = new Object();
if (c) this.color = this.addParam('bgcolor', c);
this.addParam('quality', 'high'); // default to high
this.doDetect = getQueryParamValue('detectflash');
}
FlashObject.prototype.addParam = function(name, value) {
this.params[name] = value;
}
FlashObject.prototype.getParams = function() {
return this.params;
}
FlashObject.prototype.getParam = function(name) {
return this.params[name];
}
FlashObject.prototype.addVariable = function(name, value) {
this.variables[name] = value;
}
FlashObject.prototype.getVariable = function(name) {
return this.variables[name];
}
FlashObject.prototype.getVariables = function() {
return this.variables;
}
FlashObject.prototype.getParamTags = function() {
var paramTags = "";
for (var param in this.getParams()) {
paramTags += '<param name="' + param + '" value="' + this.getParam(param) + '" />';
}
if (paramTags == "") {
paramTags = null;
}
return paramTags;
}
FlashObject.prototype.getHTML = function() {
var flashHTML = "";
if (window.ActiveXObject && navigator.userAgent.indexOf('Mac') == -1) { // PC IE
flashHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '">';
flashHTML += '<param name="movie" value="' + this.swf + '" />';
if (this.getParamTags() != null) {
flashHTML += this.getParamTags();
}
if (this.getVariablePairs() != null) {
flashHTML += '<param name="flashVars" value="' + this.getVariablePairs() + '" />';
}
flashHTML += '</object>';
}
else { // Everyone else
flashHTML += '<embed type="application/x-shockwave-flash" src="' + this.swf + '" width="' + this.width + '" height="' + this.height + '" id="' + this.id + '" align="' + this.align + '"';
for (var param in this.getParams()) {
flashHTML += ' ' + param + '="' + this.getParam(param) + '"';
}
if (this.getVariablePairs() != null) {
flashHTML += ' flashVars="' + this.getVariablePairs() + '"';
}
flashHTML += '></embed>';
}
return flashHTML;
}
FlashObject.prototype.getVariablePairs = function() {
var variablePairs = new Array();
for (var name in this.getVariables()) {
variablePairs.push(name + "=" + escape(this.getVariable(name)));
}
if (variablePairs.length > 0) {
return variablePairs.join("&");
}
else {
return null;
}
}
FlashObject.prototype.write = function(elementId) {
if(detectFlash(this.version) || this.doDetect=='false') {
if (elementId) {
document.getElementById(elementId).innerHTML = this.getHTML();
} else {
document.write(this.getHTML());
}
} else {
if (this.redirect != "") {
document.location.replace(this.redirect);
} else {
if (elementId) {
document.getElementById(elementId).innerHTML = this.bypassTxt;
} else {
document.write(this.bypassTxt);
}
}
}
}
function getFlashVersion() {
var flashversion = 0;
if (navigator.plugins && navigator.plugins.length) {
var x = navigator.plugins["Shockwave Flash"];
if(x){
if (x.description) {
var y = x.description;
flashversion = y.charAt(y.indexOf('.')-1);
}
}
} else {
result = false;
for(var i = 15; i >= 3 && result != true; i--){
execScript('on error resume next: result = IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.'+i+'"))','VBScript');
flashversion = i;
}
}
return flashversion;
}
function detectFlash(ver) {
if (getFlashVersion() >= ver) {
return true;
} else {
return false;
}
}
// get value of querystring param
function getQueryParamValue(param) {
var q = document.location.search;
var detectIndex = q.indexOf(param);
var endIndex = (q.indexOf("&", detectIndex) != -1) ? q.indexOf("&", detectIndex) : q.length;
if(q.length > 1 && detectIndex != -1) {
return q.substring(q.indexOf("=", detectIndex)+1, endIndex);
} else {
return "";
}
}
/* add Array.push if needed */
if(Array.prototype.push == null){
Array.prototype.push = function(item){
this[this.length] = item;
return this.length;
}
} |
Partager