AC_RunActiveContent.js 7.8 KB

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