PageRenderTime 38ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/AITA_appserver_v220100411/src/main/webapp/script/AnyChart.js

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