PageRenderTime 33ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/examples/CustomMapMars/bin-release/srcview/AC_OETags.js

http://gmaps-utility-library-flash.googlecode.com/
JavaScript | 276 lines | 228 code | 25 blank | 23 comment | 63 complexity | e14866c40860941ed2786bed742f0e24 MD5 | raw file
  1. // Flash Player Version Detection - Rev 1.6
  2. // Detect Client Browser type
  3. // Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
  4. var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
  5. var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
  6. var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
  7. function ControlVersion()
  8. {
  9. var version;
  10. var axo;
  11. var e;
  12. // NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
  13. try {
  14. // version will be set for 7.X or greater players
  15. axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
  16. version = axo.GetVariable("$version");
  17. } catch (e) {
  18. }
  19. if (!version)
  20. {
  21. try {
  22. // version will be set for 6.X players only
  23. axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
  24. // installed player is some revision of 6.0
  25. // GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
  26. // so we have to be careful.
  27. // default to the first public version
  28. version = "WIN 6,0,21,0";
  29. // throws if AllowScripAccess does not exist (introduced in 6.0r47)
  30. axo.AllowScriptAccess = "always";
  31. // safe to call for 6.0r47 or greater
  32. version = axo.GetVariable("$version");
  33. } catch (e) {
  34. }
  35. }
  36. if (!version)
  37. {
  38. try {
  39. // version will be set for 4.X or 5.X player
  40. axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
  41. version = axo.GetVariable("$version");
  42. } catch (e) {
  43. }
  44. }
  45. if (!version)
  46. {
  47. try {
  48. // version will be set for 3.X player
  49. axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
  50. version = "WIN 3,0,18,0";
  51. } catch (e) {
  52. }
  53. }
  54. if (!version)
  55. {
  56. try {
  57. // version will be set for 2.X player
  58. axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
  59. version = "WIN 2,0,0,11";
  60. } catch (e) {
  61. version = -1;
  62. }
  63. }
  64. return version;
  65. }
  66. // JavaScript helper required to detect Flash Player PlugIn version information
  67. function GetSwfVer(){
  68. // NS/Opera version >= 3 check for Flash plugin in plugin array
  69. var flashVer = -1;
  70. if (navigator.plugins != null && navigator.plugins.length > 0) {
  71. if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
  72. var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
  73. var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
  74. var descArray = flashDescription.split(" ");
  75. var tempArrayMajor = descArray[2].split(".");
  76. var versionMajor = tempArrayMajor[0];
  77. var versionMinor = tempArrayMajor[1];
  78. var versionRevision = descArray[3];
  79. if (versionRevision == "") {
  80. versionRevision = descArray[4];
  81. }
  82. if (versionRevision[0] == "d") {
  83. versionRevision = versionRevision.substring(1);
  84. } else if (versionRevision[0] == "r") {
  85. versionRevision = versionRevision.substring(1);
  86. if (versionRevision.indexOf("d") > 0) {
  87. versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
  88. }
  89. }
  90. var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
  91. }
  92. }
  93. // MSN/WebTV 2.6 supports Flash 4
  94. else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
  95. // WebTV 2.5 supports Flash 3
  96. else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
  97. // older WebTV supports Flash 2
  98. else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
  99. else if ( isIE && isWin && !isOpera ) {
  100. flashVer = ControlVersion();
  101. }
  102. return flashVer;
  103. }
  104. // When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
  105. function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
  106. {
  107. versionStr = GetSwfVer();
  108. if (versionStr == -1 ) {
  109. return false;
  110. } else if (versionStr != 0) {
  111. if(isIE && isWin && !isOpera) {
  112. // Given "WIN 2,0,0,11"
  113. tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"]
  114. tempString = tempArray[1]; // "2,0,0,11"
  115. versionArray = tempString.split(","); // ['2', '0', '0', '11']
  116. } else {
  117. versionArray = versionStr.split(".");
  118. }
  119. var versionMajor = versionArray[0];
  120. var versionMinor = versionArray[1];
  121. var versionRevision = versionArray[2];
  122. // is the major.revision >= requested major.revision AND the minor version >= requested minor
  123. if (versionMajor > parseFloat(reqMajorVer)) {
  124. return true;
  125. } else if (versionMajor == parseFloat(reqMajorVer)) {
  126. if (versionMinor > parseFloat(reqMinorVer))
  127. return true;
  128. else if (versionMinor == parseFloat(reqMinorVer)) {
  129. if (versionRevision >= parseFloat(reqRevision))
  130. return true;
  131. }
  132. }
  133. return false;
  134. }
  135. }
  136. function AC_AddExtension(src, ext)
  137. {
  138. if (src.indexOf('?') != -1)
  139. return src.replace(/\?/, ext+'?');
  140. else
  141. return src + ext;
  142. }
  143. function AC_Generateobj(objAttrs, params, embedAttrs)
  144. {
  145. var str = '';
  146. if (isIE && isWin && !isOpera)
  147. {
  148. str += '<object ';
  149. for (var i in objAttrs)
  150. str += i + '="' + objAttrs[i] + '" ';
  151. str += '>';
  152. for (var i in params)
  153. str += '<param name="' + i + '" value="' + params[i] + '" /> ';
  154. str += '</object>';
  155. } else {
  156. str += '<embed ';
  157. for (var i in embedAttrs)
  158. str += i + '="' + embedAttrs[i] + '" ';
  159. str += '> </embed>';
  160. }
  161. document.write(str);
  162. }
  163. function AC_FL_RunContent(){
  164. var ret =
  165. AC_GetArgs
  166. ( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
  167. , "application/x-shockwave-flash"
  168. );
  169. AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
  170. }
  171. function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
  172. var ret = new Object();
  173. ret.embedAttrs = new Object();
  174. ret.params = new Object();
  175. ret.objAttrs = new Object();
  176. for (var i=0; i < args.length; i=i+2){
  177. var currArg = args[i].toLowerCase();
  178. switch (currArg){
  179. case "classid":
  180. break;
  181. case "pluginspage":
  182. ret.embedAttrs[args[i]] = args[i+1];
  183. break;
  184. case "src":
  185. case "movie":
  186. args[i+1] = AC_AddExtension(args[i+1], ext);
  187. ret.embedAttrs["src"] = args[i+1];
  188. ret.params[srcParamName] = args[i+1];
  189. break;
  190. case "onafterupdate":
  191. case "onbeforeupdate":
  192. case "onblur":
  193. case "oncellchange":
  194. case "onclick":
  195. case "ondblClick":
  196. case "ondrag":
  197. case "ondragend":
  198. case "ondragenter":
  199. case "ondragleave":
  200. case "ondragover":
  201. case "ondrop":
  202. case "onfinish":
  203. case "onfocus":
  204. case "onhelp":
  205. case "onmousedown":
  206. case "onmouseup":
  207. case "onmouseover":
  208. case "onmousemove":
  209. case "onmouseout":
  210. case "onkeypress":
  211. case "onkeydown":
  212. case "onkeyup":
  213. case "onload":
  214. case "onlosecapture":
  215. case "onpropertychange":
  216. case "onreadystatechange":
  217. case "onrowsdelete":
  218. case "onrowenter":
  219. case "onrowexit":
  220. case "onrowsinserted":
  221. case "onstart":
  222. case "onscroll":
  223. case "onbeforeeditfocus":
  224. case "onactivate":
  225. case "onbeforedeactivate":
  226. case "ondeactivate":
  227. case "type":
  228. case "codebase":
  229. ret.objAttrs[args[i]] = args[i+1];
  230. break;
  231. case "id":
  232. case "width":
  233. case "height":
  234. case "align":
  235. case "vspace":
  236. case "hspace":
  237. case "class":
  238. case "title":
  239. case "accesskey":
  240. case "name":
  241. case "tabindex":
  242. ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
  243. break;
  244. default:
  245. ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
  246. }
  247. }
  248. ret.objAttrs["classid"] = classid;
  249. if (mimeType) ret.embedAttrs["type"] = mimeType;
  250. return ret;
  251. }