/**
* FusionCharts: Flash Player detection and Chart embedding.
* Version: 1.2.4 (16th February, 2009) - Added fix for chart with % width/height.
* Version: 1.2.3 (15th September, 2008) - Added fix for % and & characters. Additional fixes to properly handle double quotes and single quotes in setDataXML() function.
* Version: 1.2.2 (10th July, 2008) - Added fix for % scaled dimensions, fixes in setDataXML() and setDataURL() functions
* Version: 1.2.1 (21st December, 2007) - Added setting up transparent/opaque mode: setTransparent() function
* Version: 1.2 (1st November, 2007) - Added FORM fixes for IE
* Version: 1.1 (29th June, 2007) - Added Player detection, New conditional fixes for IE
*
* Morphed from SWFObject (http://blog.deconcept.com/swfobject/) under MIT License:
* http://www.opensource.org/licenses/mit-license.php
*
*/if(typeof infosoftglobal == "undefined") var infosoftglobal = new Object();
if(typeof infosoftglobal.FusionChartsUtil == "undefined") infosoftglobal.FusionChartsUtil = new Object();
infosoftglobal.FusionCharts = function(swf, id, w, h, debugMode, registerWithJS, c, scaleMode, lang, detectFlashVersion, autoInstallRedirect){
if (!document.getElementById) { return; }
//Flag to see whether data has been set initially
this.initialDataSet = false;
//Create container objects
this.params = new Object();
this.variables = new Object();
this.attributes = new Array();
//Set attributes for the SWF
if(swf) { this.setAttribute('swf', swf); }
if(id) { this.setAttribute('id', id); }
debugMode = debugMode ? debugMode : 0;
this.addVariable('debugMode', debugMode);
w=w.toString().replace(/\%$/,"%25");
if(w) { this.setAttribute('width', w); }
h=h.toString().replace(/\%$/,"%25");
if(h) { this.setAttribute('height', h); }
//Set background color
if(c) { this.addParam('bgcolor', c); }
//Set Quality
this.addParam('quality', 'high');
//Add scripting access parameter
this.addParam('allowScriptAccess', 'always');
//Pass width and height to be appended as chartWidth and chartHeight
this.addVariable('chartWidth', w);
this.addVariable('chartHeight', h);
//Whether in debug mode
//Pass DOM ID to Chart
this.addVariable('DOMId', id);
//Whether to registed with JavaScript
registerWithJS = registerWithJS ? registerWithJS : 0;
this.addVariable('registerWithJS', registerWithJS);
//Scale Mode of chart
scaleMode = scaleMode ? scaleMode : 'noScale';
this.addVariable('scaleMode', scaleMode);
//Application Message Language
lang = lang ? lang : 'EN';
this.addVariable('lang', lang);
//Whether to auto detect and re-direct to Flash Player installation
this.detectFlashVersion = detectFlashVersion?detectFlashVersion:1;
this.autoInstallRedirect = autoInstallRedirect?autoInstallRedirect:1;
//Ger Flash Player version
this.installedVer = infosoftglobal.FusionChartsUtil.getPlayerVersion();
if (!window.opera && document.all && this.installedVer.major > 7) {
// Only add the onunload cleanup if the Flash Player version supports External Interface and we are in IE
infosoftglobal.FusionCharts.doPrepUnload = true;
}
}
infosoftglobal.FusionCharts.prototype = {
setAttribute: function(name, value){
this.attributes[name] = value;
},
getAttribute: function(name){
return this.attributes[name];
},
addParam: function(name, value){
this.params[name] = value;
},
getParams: function(){
return this.params;
},
addVariable: function(name, value){
this.variables[name] = value;
},
getVariable: function(name){
return this.variables[name];
},
getVariables: function(){
return this.variables;
},
getVariablePairs: function(){
var variablePairs = new Array();
var key;
var variables = this.getVariables();
for(key in variables){
variablePairs.push(key +"="+ variables[key]);
}
return variablePairs;
},
getSWFHTML: function() {
var swfNode = "";
if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) {
// netscape plugin architecture
swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'" ';
swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" ';
var params = this.getParams();
for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; }
var pairs = this.getVariablePairs().join("&");
if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; }
swfNode += '/>';
} else { // PC IE
swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">';
swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />';
var params = this.getParams();
for(var key in params) {
swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />';
}
var pairs = this.getVariablePairs().join("&");
if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';}
swfNode += "</object>";
}
return swfNode;
},
setDataURL: function(strDataURL){
//This method sets the data URL for the chart.
//If being set initially
if (this.initialDataSet==false){
this.addVariable('dataURL',strDataURL);
//Update flag
this.initialDataSet = true;
}else{
//Else, we update the chart data using External Interface
//Get reference to chart object
var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id'));
if (!chartObj.setDataURL)
{
__flash__addCallback(chartObj, "setDataURL");
}
chartObj.setDataURL(strDataURL);
}
},
//This function :
//fixes the double quoted attributes to single quotes
//Encodes all quotes inside attribute values
//Encodes % to %25 and & to %26;
encodeDataXML: function(strDataXML){
var regExpReservedCharacters=["\\$","\\+"];
var arrDQAtt=strDataXML.match(/=\s*\".*?\"/g);
if (arrDQAtt){
for(var i=0;i<arrDQAtt.length;i++){
var repStr=arrDQAtt[i].replace(/^=\s*\"|\"$/g,"");
repStr=repStr.replace(/\'/g,"%26apos;");
var strTo=strDataXML.indexOf(arrDQAtt[i]);
var repStrr="='"+repStr+"'";
var strStart=strDataXML.substring(0,strTo);
var strEnd=strDataXML.substring(strTo+arrDQAtt[i].length);
var strDataXML=strStart+repStrr+strEnd;
}
}
strDataXML=strDataXML.replace(/\"/g,"%26quot;");
strDataXML=strDataXML.replace(/%(?![\da-f]{2}|[\da-f]{4})/ig,"%25");
strDataXML=strDataXML.replace(/\&/g,"%26");
return strDataXML;
},
setDataXML: function(strDataXML){
//If being set initially
if (this.initialDataSet==false){
//This method sets the data XML for the chart INITIALLY.
this.addVariable('dataXML',this.encodeDataXML(strDataXML));
//Update flag
this.initialDataSet = true;
}else{
//Else, we update the chart data using External Interface
//Get reference to chart object
var chartObj = infosoftglobal.FusionChartsUtil.getChartObject(this.getAttribute('id'));
chartObj.setDataXML(strDataXML);
}
},
setTransparent: function(isTransparent){
//Sets chart to transparent mode when isTransparent is true (default)
//When no parameter is passed, we assume transparent to be true.
if(typeof isTransparent=="undefined") {
isTransparent=true;
}
//Set the property
if(isTransparent)
this.addParam('WMode', 'transparent');
else
this.addParam('WMode', 'Opaque');
},
render: function(elementId){
//First check for installed version of Flash Player - we need a minimum of 8
if((this.detectFlashVersion==1) && (this.installedVer.major < 8)){
if (this.autoInstallRedirect==1){
//If we can auto redirect to install th
- 1
- 2
- 3
前往页