UnityObject2.js 51 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680
  1. /**
  2. * @fileOverview
  3. * Defines UnityObject2
  4. */
  5. //TODO: No need to polute the global space, just transfer this control to a 'static' variable insite unityObject!
  6. /**
  7. * @namespace
  8. */
  9. //var unity = unity || {};
  10. // We store all unityObject instances in a global scope, needed for IE firstFrameCallback and other internal tasks.
  11. //unity.instances = [];
  12. //unity.instanceNumber = 0;
  13. /**
  14. * Object expected by the Java Installer. We can move those to UnityObject2 if we update the java Installer.
  15. */
  16. var unityObject = {
  17. /**
  18. * Callback used bt the Java installer to notify the Install Complete.
  19. * @private
  20. * @param {String} id
  21. * @param {bool} success
  22. * @param {String} errormessage
  23. */
  24. javaInstallDone : function (id, success, errormessage) {
  25. var instanceId = parseInt(id.substring(id.lastIndexOf('_') + 1), 10);
  26. if (!isNaN(instanceId)) {
  27. // javaInstallDoneCallback must not be called directly because it deadlocks google chrome
  28. setTimeout(function () {
  29. UnityObject2.instances[instanceId].javaInstallDoneCallback(id, success, errormessage);
  30. }, 10);
  31. }
  32. }
  33. };
  34. /**
  35. * @class
  36. * @constructor
  37. */
  38. var UnityObject2 = function (config) {
  39. /** @private */
  40. var logHistory = [],
  41. win = window,
  42. doc = document,
  43. nav = navigator,
  44. instanceNumber = null,
  45. //domLoaded = false,
  46. //domLoadEvents = [],
  47. embeddedObjects = [], //Could be removed?
  48. //listeners = [],
  49. //styleSheet = null,
  50. //styleSheetMedia = null,
  51. //autoHideShow = true,
  52. //fullSizeMissing = true,
  53. useSSL = (document.location.protocol == 'https:'), //This will turn off enableUnityAnalytics, since enableUnityAnalytics don't have a https version.
  54. baseDomain = useSSL ? "https://ssl-webplayer.unity3d.com/" : "http://webplayer.unity3d.com/",
  55. triedJavaCookie = "_unity_triedjava",
  56. triedJavaInstall = _getCookie(triedJavaCookie),
  57. triedClickOnceCookie = "_unity_triedclickonce",
  58. triedClickOnce = _getCookie(triedClickOnceCookie),
  59. progressCallback = false,
  60. applets = [],
  61. //addedClickOnce = false,
  62. googleAnalyticsLoaded = false,
  63. googleAnalyticsCallback = null,
  64. latestStatus = null,
  65. lastType = null,
  66. //beginCallback = [],
  67. //preCallback = [],
  68. imagesToWaitFor = [],
  69. //referrer = null,
  70. pluginStatus = null,
  71. pluginStatusHistory = [],
  72. installProcessStarted = false, //not used anymore?
  73. kInstalled = "installed",
  74. kMissing = "missing",
  75. kBroken = "broken",
  76. kUnsupported = "unsupported",
  77. kReady = "ready", //not used anymore?
  78. kStart = "start",
  79. kError = "error",
  80. kFirst = "first",
  81. //kStandard = "standard",
  82. kJava = "java",
  83. kClickOnce = "clickonce", //not used anymore?
  84. wasMissing = false, //identifies if this is a install attempt, or if the plugin was already installed
  85. unityObject = null, //The <embed> or <object> for the webplayer. This can be used for webPlayer communication.
  86. //kApplet = "_applet",
  87. //kBanner = "_banner",
  88. cfg = {
  89. pluginName : "Unity Player",
  90. pluginMimeType : "application/vnd.unity",
  91. baseDownloadUrl : baseDomain + "download_webplayer-3.x/",
  92. fullInstall : false,
  93. autoInstall : false,
  94. enableJava : true,
  95. enableJVMPreloading : false,
  96. enableClickOnce : true,
  97. enableUnityAnalytics : false,
  98. enableGoogleAnalytics : true,
  99. params : {},
  100. attributes : {},
  101. referrer : null,
  102. debugLevel : 0
  103. };
  104. // Merge in the given configuration and override defaults.
  105. cfg = jQuery.extend(true, cfg, config);
  106. if (cfg.referrer === "") {
  107. cfg.referrer = null;
  108. }
  109. //enableUnityAnalytics does not support SSL yet.
  110. if (useSSL) {
  111. cfg.enableUnityAnalytics = false;
  112. }
  113. /**
  114. * Get cookie value
  115. * @private
  116. * @param {String} name The param name
  117. * @return string or false if non-existing.
  118. */
  119. function _getCookie(name) {
  120. var e = new RegExp(escape(name) + "=([^;]+)");
  121. if (e.test(doc.cookie + ";")) {
  122. e.exec(doc.cookie + ";");
  123. return RegExp.$1;
  124. }
  125. return false;
  126. }
  127. /**
  128. * Sets session cookie
  129. * @private
  130. */
  131. function _setSessionCookie(name, value) {
  132. document.cookie = escape(name) + "=" + escape(value) + "; path=/";
  133. }
  134. /**
  135. * Converts unity version to number (used for version comparison)
  136. * @private
  137. */
  138. function _getNumericUnityVersion(version) {
  139. var result = 0,
  140. major,
  141. minor,
  142. fix,
  143. type,
  144. release;
  145. if (version) {
  146. var m = version.toLowerCase().match(/^(\d+)(?:\.(\d+)(?:\.(\d+)([dabfr])?(\d+)?)?)?$/);
  147. if (m && m[1]) {
  148. major = m[1];
  149. minor = m[2] ? m[2] : 0;
  150. fix = m[3] ? m[3] : 0;
  151. type = m[4] ? m[4] : 'r';
  152. release = m[5] ? m[5] : 0;
  153. result |= ((major / 10) % 10) << 28;
  154. result |= (major % 10) << 24;
  155. result |= (minor % 10) << 20;
  156. result |= (fix % 10) << 16;
  157. result |= {d: 2 << 12, a: 4 << 12, b: 6 << 12, f: 8 << 12, r: 8 << 12}[type];
  158. result |= ((release / 100) % 10) << 8;
  159. result |= ((release / 10) % 10) << 4;
  160. result |= (release % 10);
  161. }
  162. }
  163. return result;
  164. }
  165. /**
  166. * Gets plugin and unity versions (non-ie)
  167. * @private
  168. */
  169. function _getPluginVersion(callback, versions) {
  170. var b = doc.getElementsByTagName("body")[0];
  171. var ue = doc.createElement("object");
  172. var i = 0;
  173. if (b && ue) {
  174. ue.setAttribute("type", cfg.pluginMimeType);
  175. ue.style.visibility = "hidden";
  176. b.appendChild(ue);
  177. var count = 0;
  178. (function () {
  179. if (typeof ue.GetPluginVersion === "undefined") {
  180. if (count++ < 10) {
  181. setTimeout(arguments.callee, 10);
  182. } else {
  183. b.removeChild(ue);
  184. callback(null);
  185. }
  186. } else {
  187. var v = {};
  188. if (versions) {
  189. for (i = 0; i < versions.length; ++i) {
  190. v[versions[i]] = ue.GetUnityVersion(versions[i]);
  191. }
  192. }
  193. v.plugin = ue.GetPluginVersion();
  194. b.removeChild(ue);
  195. callback(v);
  196. }
  197. })();
  198. } else {
  199. callback(null);
  200. }
  201. }
  202. /**
  203. * Retrieves windows installer name
  204. * @private
  205. */
  206. function _getWinInstall() {
  207. var url = cfg.fullInstall ? "UnityWebPlayerFull.exe" : "UnityWebPlayer.exe";
  208. if (cfg.referrer !== null) {
  209. url += "?referrer=" + cfg.referrer;
  210. }
  211. return url;
  212. }
  213. /**
  214. * Retrieves mac plugin package name
  215. * @private
  216. */
  217. function _getOSXInstall() {
  218. var url = "UnityPlayer.plugin.zip";
  219. if (cfg.referrer != null) {
  220. url += "?referrer=" + cfg.referrer;
  221. }
  222. return url;
  223. }
  224. /**
  225. * retrieves installer name
  226. * @private
  227. */
  228. function _getInstaller() {
  229. return cfg.baseDownloadUrl + (ua.win ? _getWinInstall() : _getOSXInstall() );
  230. }
  231. /**
  232. * sets plugin status
  233. * @private
  234. */
  235. function _setPluginStatus(status, type, data, url) {
  236. if (status === kMissing){
  237. wasMissing = true;
  238. }
  239. // debug('setPluginStatus() status:', status, 'type:', type, 'data:', data, 'url:', url);
  240. // only report to analytics the first time a status occurs.
  241. if ( jQuery.inArray(status, pluginStatusHistory) === -1 ) {
  242. //Only send analytics for plugins installs. Do not send if plugin is already installed.
  243. if (wasMissing) {
  244. _an.send(status, type, data, url);
  245. }
  246. pluginStatusHistory.push(status);
  247. }
  248. pluginStatus = status;
  249. }
  250. /**
  251. * Contains browser and platform properties
  252. * @private
  253. */
  254. var ua = function () {
  255. var a = nav.userAgent, p = nav.platform;
  256. var chrome = /chrome/i.test(a);
  257. var ua = {
  258. w3 : typeof doc.getElementById != "undefined" && typeof doc.getElementsByTagName != "undefined" && typeof doc.createElement != "undefined",
  259. win : p ? /win/i.test(p) : /win/i.test(a),
  260. mac : p ? /mac/i.test(p) : /mac/i.test(a),
  261. ie : /msie/i.test(a) ? parseFloat(a.replace(/^.*msie ([0-9]+(\.[0-9]+)?).*$/i, "$1")) : false,
  262. ff : /firefox/i.test(a),
  263. op : /opera/i.test(a),
  264. ch : chrome,
  265. ch_v : /chrome/i.test(a) ? parseFloat(a.replace(/^.*chrome\/(\d+(\.\d+)?).*$/i, "$1")) : false,
  266. sf : /safari/i.test(a) && !chrome,
  267. wk : /webkit/i.test(a) ? parseFloat(a.replace(/^.*webkit\/(\d+(\.\d+)?).*$/i, "$1")) : false,
  268. x64 : /win64/i.test(a) && /x64/i.test(a),
  269. moz : /mozilla/i.test(a) ? parseFloat(a.replace(/^.*mozilla\/([0-9]+(\.[0-9]+)?).*$/i, "$1")) : 0,
  270. mobile: /ipad/i.test(p) || /iphone/i.test(p) || /ipod/i.test(p) || /android/i.test(a) || /windows phone/i.test(a)
  271. };
  272. ua.clientBrand = ua.ch ? 'ch' : ua.ff ? 'ff' : ua.sf ? 'sf' : ua.ie ? 'ie' : ua.op ? 'op' : '??';
  273. ua.clientPlatform = ua.win ? 'win' : ua.mac ? 'mac' : '???';
  274. // get base url
  275. var s = doc.getElementsByTagName("script");
  276. for (var i = 0; i < s.length; ++i) {
  277. var m = s[i].src.match(/^(.*)3\.0\/uo\/UnityObject2\.js$/i);
  278. if (m) {
  279. cfg.baseDownloadUrl = m[1];
  280. break;
  281. }
  282. }
  283. /**
  284. * compares two versions
  285. * @private
  286. */
  287. function _compareVersions(v1, v2) {
  288. for (var i = 0; i < Math.max(v1.length, v2.length); ++i) {
  289. var n1 = (i < v1.length) && v1[i] ? new Number(v1[i]) : 0;
  290. var n2 = (i < v2.length) && v2[i] ? new Number(v2[i]) : 0;
  291. if (n1 < n2) return -1;
  292. if (n1 > n2) return 1;
  293. }
  294. return 0;
  295. };
  296. /**
  297. * detect java
  298. */
  299. ua.java = function () {
  300. if (nav.javaEnabled()) {
  301. var wj = (ua.win && ua.ff);
  302. var mj = false;//(ua.mac && (ua.ff || ua.ch || ua.sf));
  303. if (wj || mj) {
  304. if (typeof nav.mimeTypes != "undefined") {
  305. var rv = wj ? [1, 6, 0, 12] : [1, 4, 2, 0];
  306. for (var i = 0; i < nav.mimeTypes.length; ++i) {
  307. if (nav.mimeTypes[i].enabledPlugin) {
  308. var m = nav.mimeTypes[i].type.match(/^application\/x-java-applet;(?:jpi-)?version=(\d+)(?:\.(\d+)(?:\.(\d+)(?:_(\d+))?)?)?$/);
  309. if (m != null) {
  310. if (_compareVersions(rv, m.slice(1)) <= 0) {
  311. return true;
  312. }
  313. }
  314. }
  315. }
  316. }
  317. } else if (ua.win && ua.ie) {
  318. if (typeof ActiveXObject != "undefined") {
  319. /**
  320. * ActiveX Test
  321. */
  322. function _axTest(v) {
  323. try {
  324. return new ActiveXObject("JavaWebStart.isInstalled." + v + ".0") != null;
  325. }
  326. catch (ex) {
  327. return false;
  328. }
  329. }
  330. /**
  331. * ActiveX Test 2
  332. */
  333. function _axTest2(v) {
  334. try {
  335. return new ActiveXObject("JavaPlugin.160_" + v) != null;
  336. } catch (ex) {
  337. return false;
  338. }
  339. }
  340. if (_axTest("1.7.0")) {
  341. return true;
  342. }
  343. if (ua.ie >= 8) {
  344. if (_axTest("1.6.0")) {
  345. // make sure it's 1.6.0.12 or newer. increment 50 to a larger value if 1.6.0.50 is released
  346. for (var i = 12; i <= 50; ++i) {
  347. if (_axTest2(i)) {
  348. if (ua.ie == 9 && ua.moz == 5 && i < 24) {
  349. // when IE9 is not in compatibility mode require at least
  350. // Java 1.6.0.24: http://support.microsoft.com/kb/2506617
  351. continue;
  352. } else {
  353. return true;
  354. }
  355. }
  356. }
  357. return false;
  358. }
  359. } else {
  360. return _axTest("1.6.0") || _axTest("1.5.0") || _axTest("1.4.2");
  361. }
  362. }
  363. }
  364. }
  365. return false;
  366. }();
  367. // detect clickonce
  368. ua.co = function () {
  369. if (ua.win && ua.ie) {
  370. var av = a.match(/(\.NET CLR [0-9.]+)|(\.NET[0-9.]+)/g);
  371. if (av != null) {
  372. var rv = [3, 5, 0];
  373. for (var i = 0; i < av.length; ++i) {
  374. var versionNumbers = av[i].match(/[0-9.]{2,}/g)[0].split(".");
  375. if (_compareVersions(rv, versionNumbers) <= 0) {
  376. return true;
  377. }
  378. }
  379. }
  380. }
  381. return false;
  382. }();
  383. return ua;
  384. }();
  385. /**
  386. * analytics
  387. * @private
  388. */
  389. var _an = function () {
  390. var uid = function () {
  391. var now = new Date();
  392. var utc = Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDay(), now.getUTCHours(), now.getUTCMinutes(), now.getUTCSeconds(), now.getUTCMilliseconds());
  393. return utc.toString(16) + _getRandomInt().toString(16);
  394. }();
  395. var seq = 0;
  396. var _ugaq = window["_gaq"] = ( window["_gaq"] || [] );
  397. _setUpAnalytics();
  398. /**
  399. * generates random integer number
  400. * @private
  401. */
  402. function _getRandomInt() {
  403. return Math.floor(Math.random() * 2147483647);
  404. }
  405. /**
  406. * Checks if there is a need to load analytics, by checking the existance of a _gaq object
  407. */
  408. function _setUpAnalytics() {
  409. var gaUrl = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
  410. var ss = doc.getElementsByTagName("script");
  411. var googleAnalyticsLoaded = false;
  412. for (var i = 0; i < ss.length; ++i) {
  413. if (ss[i].src && ss[i].src.toLowerCase() == gaUrl.toLowerCase()) {
  414. googleAnalyticsLoaded = true;
  415. break;
  416. }
  417. }
  418. if (!googleAnalyticsLoaded) {
  419. var ga = doc.createElement("script");
  420. ga.type = "text/javascript";
  421. ga.async = true;
  422. ga.src = gaUrl;
  423. var s = document.getElementsByTagName("script")[0];
  424. s.parentNode.insertBefore(ga, s);
  425. }
  426. var gaAccount = (cfg.debugLevel === 0) ? 'UA-16068464-16' : 'UA-16068464-17';
  427. _ugaq.push(["unity._setDomainName", "none"]);
  428. _ugaq.push(["unity._setAllowLinker", true]);
  429. _ugaq.push(["unity._setReferrerOverride", ' '+this.location.toString()]);
  430. _ugaq.push(["unity._setAccount", gaAccount]);
  431. // $(GoogleRevisionPlaceholder)
  432. }
  433. /**
  434. * sends analytics data to unity
  435. * @private
  436. */
  437. function _sendUnityAnalytics(event, type, data, callback) {
  438. if (!cfg.enableUnityAnalytics) {
  439. if (callback) {
  440. callback();
  441. }
  442. return;
  443. }
  444. var url = "http://unityanalyticscapture.appspot.com/event?u=" + encodeURIComponent(uid) + "&s=" + encodeURIComponent(seq) + "&e=" + encodeURIComponent(event);
  445. // $(UnityRevisionPlaceholder)
  446. if (cfg.referrer !== null) {
  447. url += "?r=" + cfg.referrer;
  448. }
  449. if (type) {
  450. url += "&t=" + encodeURIComponent(type);
  451. }
  452. if (data) {
  453. url += "&d=" + encodeURIComponent(data);
  454. }
  455. var img = new Image();
  456. if (callback) {
  457. img.onload = img.onerror = callback;
  458. }
  459. img.src = url;
  460. }
  461. /**
  462. * sends analytics data to google
  463. * @private
  464. */
  465. function _sendGoogleAnalytics(event, type, data, callback) {
  466. if (!cfg.enableGoogleAnalytics) {
  467. if (callback) {
  468. callback();
  469. }
  470. return;
  471. }
  472. var url = "/webplayer/install/" + event;
  473. var join = "?";
  474. if (type) {
  475. url += join + "t=" + encodeURIComponent(type);
  476. join = "&";
  477. }
  478. if (data) {
  479. url += join + "d=" + encodeURIComponent(data);
  480. join = "&";
  481. }
  482. if (callback) {
  483. _ugaq.push(function () {
  484. setTimeout(callback,1000);
  485. //this.googleAnalyticsCallback = callback;
  486. });
  487. }
  488. //try to shorten the URL to fit into customVariable
  489. //it will try to replace the early directories to ..
  490. var gameUrl = cfg.src;
  491. if (gameUrl.length > 40) {
  492. gameUrl = gameUrl.replace("http://","");
  493. var paths = gameUrl.split("/");
  494. var gameUrlFirst = paths.shift();
  495. var gameUrlLast = paths.pop();
  496. gameUrl = gameUrlFirst + "/../"+ gameUrlLast;
  497. while(gameUrl.length < 40 && paths.length > 0) {
  498. var nextpath = paths.pop();
  499. if(gameUrl.length + nextpath.length + 5 < 40) {
  500. gameUrlLast = nextpath + "/" + gameUrlLast;
  501. } else {
  502. gameUrlLast = "../" + gameUrlLast;
  503. }
  504. gameUrl = gameUrlFirst + "/../"+ gameUrlLast;
  505. }
  506. }
  507. _ugaq.push(['unity._setCustomVar',
  508. 2, // This custom var is set to slot #1. Required parameter.
  509. 'GameURL', // The name acts as a kind of category for the user activity. Required parameter.
  510. gameUrl, // This value of the custom variable. Required parameter.
  511. 3 // Sets the scope to page-level. Optional parameter.
  512. ]);
  513. _ugaq.push(['unity._setCustomVar',
  514. 1, // This custom var is set to slot #1. Required parameter.
  515. 'UnityObjectVersion', // The name acts as a kind of category for the user activity. Required parameter.
  516. "2", // This value of the custom variable. Required parameter.
  517. 3 // Sets the scope to page-level. Optional parameter.
  518. ]);
  519. if (type) {
  520. _ugaq.push(['unity._setCustomVar',
  521. 3, // This custom var is set to slot #1. Required parameter.
  522. 'installMethod', // The name acts as a kind of category for the user activity. Required parameter.
  523. type, // This value of the custom variable. Required parameter.
  524. 3 // Sets the scope to page-level. Optional parameter.
  525. ]);
  526. }
  527. _ugaq.push(["unity._trackPageview", url]);
  528. }
  529. return {
  530. /**
  531. * sends analytics data. optionally opens url once data has been sent
  532. * @public
  533. */
  534. send : function (event, type, data, url) {
  535. if (cfg.enableUnityAnalytics || cfg.enableGoogleAnalytics) {
  536. debug('Analytics SEND', event, type, data, url);
  537. }
  538. ++seq;
  539. var count = 2;
  540. var callback = function () {
  541. if (0 == --count) {
  542. googleAnalyticsCallback = null;
  543. window.location = url;
  544. }
  545. }
  546. if (data === null || data === undefined) {
  547. data = "";
  548. }
  549. _sendUnityAnalytics(event, type, data, url ? callback : null);
  550. _sendGoogleAnalytics(event, type, data, url ? callback : null);
  551. }
  552. };
  553. }();
  554. /* Java Install - BEGIN */
  555. /**
  556. * @private
  557. */
  558. function _createObjectElement(attributes, params, elementToReplace) {
  559. var i,
  560. at,
  561. pt,
  562. ue,
  563. pe;
  564. if (ua.win && ua.ie) {
  565. at = "";
  566. for (i in attributes) {
  567. at += ' ' + i + '="' + attributes[i] + '"';
  568. }
  569. pt = "";
  570. for (i in params) {
  571. pt += '<param name="' + i + '" value="' + params[i] + '" />';
  572. }
  573. elementToReplace.outerHTML = '<object' + at + '>' + pt + '</object>';
  574. } else {
  575. ue = doc.createElement("object");
  576. for (i in attributes) {
  577. ue.setAttribute(i, attributes[i]);
  578. }
  579. for (i in params) {
  580. pe = doc.createElement("param");
  581. pe.name = i;
  582. pe.value = params[i];
  583. ue.appendChild(pe);
  584. }
  585. elementToReplace.parentNode.replaceChild(ue, elementToReplace);
  586. }
  587. }
  588. /**
  589. * @private
  590. */
  591. function _checkImage(img) {
  592. // img element not in the DOM yet
  593. if (typeof img == "undefined") {
  594. return false;
  595. }
  596. if (!img.complete) {
  597. return false;
  598. }
  599. // some browsers always return true in img.complete, for those
  600. // we can check naturalWidth
  601. if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
  602. return false;
  603. }
  604. // no other way of checking, assuming it is ok
  605. return true;
  606. }
  607. /**
  608. * @private
  609. */
  610. function _preloadJVMWhenReady(id) {
  611. var needToWait = false;
  612. for (var i = 0; i < imagesToWaitFor.length; i++) {
  613. if (!imagesToWaitFor[i]) {
  614. continue;
  615. }
  616. var img = doc.images[imagesToWaitFor[i]];
  617. if (!_checkImage(img)) {
  618. needToWait = true;
  619. }
  620. else {
  621. imagesToWaitFor[i] = null;
  622. }
  623. }
  624. if (needToWait) {
  625. // check again in 100ms
  626. setTimeout(arguments.callee, 100);
  627. }
  628. else {
  629. // preload after a small delay, to make sure
  630. // the images have actually rendered
  631. setTimeout(function () {
  632. _preloadJVM(id);
  633. }, 100);
  634. }
  635. }
  636. /**
  637. * preloads the JVM and the Java Plug-in
  638. * @private
  639. */
  640. function _preloadJVM(id) {
  641. var re = doc.getElementById(id);
  642. if (!re) {
  643. re = doc.createElement("div");
  644. var lastBodyElem = doc.body.lastChild;
  645. doc.body.insertBefore(re, lastBodyElem.nextSibling);
  646. }
  647. var codebase = cfg.baseDownloadUrl + "3.0/jws/";
  648. var a = {
  649. id : id,
  650. type : "application/x-java-applet",
  651. code : "JVMPreloader",
  652. width : 1,
  653. height : 1,
  654. name : "JVM Preloader"
  655. };
  656. var p = {
  657. context : id,
  658. codebase : codebase,
  659. classloader_cache : false,
  660. scriptable : true,
  661. mayscript : true
  662. };
  663. _createObjectElement(a, p, re);
  664. jQuery('#' + id).show();
  665. //setVisibility(id, true);
  666. }
  667. /**
  668. * launches java installer
  669. * @private
  670. */
  671. function _doJavaInstall(id) {
  672. triedJavaInstall = true;
  673. _setSessionCookie(triedJavaCookie, triedJavaInstall);
  674. var re = doc.getElementById(id);
  675. var appletID = id + "_applet_" + instanceNumber;
  676. applets[appletID] = {
  677. attributes : cfg.attributes,
  678. params : cfg.params,
  679. callback : cfg.callback,
  680. broken : cfg.broken
  681. };
  682. var applet = applets[appletID];
  683. var a = {
  684. id : appletID,
  685. type : "application/x-java-applet",
  686. archive : cfg.baseDownloadUrl + "3.0/jws/UnityWebPlayer.jar",
  687. code : "UnityWebPlayer",
  688. width : 1,
  689. height : 1,
  690. name : "Unity Web Player"
  691. };
  692. if (ua.win && ua.ff) {
  693. a["style"] = "visibility: hidden;";
  694. }
  695. var p = {
  696. context : appletID,
  697. jnlp_href : cfg.baseDownloadUrl + "3.0/jws/UnityWebPlayer.jnlp",
  698. classloader_cache : false,
  699. installer : _getInstaller(),
  700. image : baseDomain + "installation/unitylogo.png",
  701. centerimage : true,
  702. boxborder : false,
  703. scriptable : true,
  704. mayscript : true
  705. };
  706. for (var i in applet.params) {
  707. if (i == "src") {
  708. continue;
  709. }
  710. if (applet.params[i] != Object.prototype[i]) {
  711. p[i] = applet.params[i];
  712. if (i.toLowerCase() == "logoimage") {
  713. p["image"] = applet.params[i];
  714. }
  715. else if (i.toLowerCase() == "backgroundcolor") {
  716. p["boxbgcolor"] = "#" + applet.params[i];
  717. }
  718. else if (i.toLowerCase() == "bordercolor") {
  719. // there's no way to specify border color
  720. p["boxborder"] = true;
  721. }
  722. else if (i.toLowerCase() == "textcolor") {
  723. p["boxfgcolor"] = "#" + applet.params[i];
  724. }
  725. }
  726. }
  727. // Create a dummy div element in the unityPlayer div
  728. // so that it can be replaced with the 1x1 px applet.
  729. // The applet will be resized when it has fully loaded,
  730. // see appletStarted().
  731. var divToBeReplacedWithApplet = doc.createElement("div");
  732. re.appendChild(divToBeReplacedWithApplet);
  733. _createObjectElement(a, p, divToBeReplacedWithApplet);
  734. jQuery('#' + id).show();
  735. //setVisibility(appletID, true);
  736. }
  737. /**
  738. * @private
  739. */
  740. function _jvmPreloaded(id) {
  741. // timeout prevents crash on ie
  742. setTimeout(function () {
  743. var re = doc.getElementById(id);
  744. if (re) {
  745. re.parentNode.removeChild(re);
  746. }
  747. }, 0);
  748. }
  749. /**
  750. * @private
  751. */
  752. function _appletStarted(id) {
  753. // set the size of the applet to the one from cloned attributes
  754. var applet = applets[id],
  755. appletElement = doc.getElementById(id),
  756. childNode;
  757. // the applet might have already finished by now
  758. if (!appletElement) {
  759. return;
  760. }
  761. appletElement.width = applet.attributes["width"] || 600;
  762. appletElement.height = applet.attributes["height"] || 450;
  763. // remove all the siblings of the applet
  764. var parentNode = appletElement.parentNode;
  765. var childNodeList = parentNode.childNodes;
  766. for (var i = 0; i < childNodeList.length; i++) {
  767. childNode = childNodeList[i];
  768. // Compare the child node with our applet element only if
  769. // it has the same type. Doing the comparison in other cases just
  770. // jumps out of the loop.
  771. if (childNode.nodeType == 1 && childNode != appletElement) {
  772. parentNode.removeChild(childNode);
  773. }
  774. }
  775. }
  776. // java installation callback
  777. function _javaInstallDoneCallback(id, success, errormessage) {
  778. debug('_javaInstallDoneCallback', id, success, errormessage);
  779. //console.log('javaInstallDoneCallback', id, success, errormessage);
  780. if (!success) {
  781. //var applet = applets[id];
  782. _setPluginStatus(kError, kJava, errormessage);
  783. //createMissingUnity(id, applet.attributes, applet.params, applet.callback, applet.broken, kJava, errormessage);
  784. }
  785. }
  786. /* Java Install - END */
  787. /**
  788. * @private
  789. */
  790. function log() {
  791. logHistory.push(arguments);
  792. if ( cfg.debugLevel > 0 && window.console && window.console.log ) {
  793. console.log(Array.prototype.slice.call(arguments));
  794. //console.log.apply(console, Array.prototype.slice.call(arguments));
  795. }
  796. }
  797. /**
  798. * @private
  799. */
  800. function debug() {
  801. logHistory.push(arguments);
  802. if ( cfg.debugLevel > 1 && window.console && window.console.log ) {
  803. console.log(Array.prototype.slice.call(arguments));
  804. //console.log.apply(console, Array.prototype.slice.call(arguments));
  805. }
  806. }
  807. /**
  808. * appends px to the value if it's a plain number
  809. * @private
  810. */
  811. function _appendPX(value) {
  812. if (/^[-+]?[0-9]+$/.test(value)) {
  813. value += "px";
  814. }
  815. return value;
  816. }
  817. var publicAPI = /** @lends UnityObject2.prototype */ {
  818. /**
  819. * Get Debug Level (0=Disabled)
  820. * @public
  821. * @return {Number} Debug Level
  822. */
  823. getLogHistory: function () {
  824. return logHistory; // JSON.stringify()
  825. },
  826. /**
  827. * Get configuration object
  828. * @public
  829. * @return {Object} cfg
  830. */
  831. getConfig: function () {
  832. return cfg; // JSON.stringify()
  833. },
  834. /**
  835. * @public
  836. * @return {Object} detailed info about OS and Browser.
  837. */
  838. getPlatformInfo: function () {
  839. return ua;
  840. },
  841. /**
  842. * Initialize plugin config and proceed with attempting to start the webplayer.
  843. * @public
  844. */
  845. initPlugin: function (targetEl, src) {
  846. cfg.targetEl = targetEl;
  847. cfg.src = src;
  848. debug('ua:', ua);
  849. //console.debug('initPlugin this:', this);
  850. this.detectUnity(this.handlePluginStatus);
  851. },
  852. /**
  853. * detects unity web player.
  854. * @public
  855. * callback - accepts two parameters.
  856. * first one contains "installed", "missing", "broken" or "unsupported" value.
  857. * second one returns requested unity versions. plugin version is included as well.
  858. * versions - optional array of unity versions to detect.
  859. */
  860. detectUnity: function (callback, versions) {
  861. // console.debug('detectUnity this:', this);
  862. var self = this;
  863. var status = kMissing;
  864. var data;
  865. nav.plugins.refresh();
  866. if (ua.clientBrand === "??" || ua.clientPlatform === "???" || ua.mobile ) {
  867. status = kUnsupported;
  868. } else if (ua.op && ua.mac) { // Opera on MAC is unsupported
  869. status = kUnsupported;
  870. data = "OPERA-MAC";
  871. } else if (
  872. typeof nav.plugins != "undefined"
  873. && nav.plugins[cfg.pluginName]
  874. && typeof nav.mimeTypes != "undefined"
  875. && nav.mimeTypes[cfg.pluginMimeType]
  876. && nav.mimeTypes[cfg.pluginMimeType].enabledPlugin
  877. ) {
  878. status = kInstalled;
  879. // make sure web player is compatible with 64-bit safari
  880. if (ua.sf && /Mac OS X 10_6/.test(nav.appVersion)) {
  881. _getPluginVersion(function (version) {
  882. if (!version || !version.plugin) {
  883. status = kBroken;
  884. data = "OSX10.6-SFx64";
  885. }
  886. _setPluginStatus(status, lastType, data);
  887. callback.call(self, status, version);
  888. }, versions);
  889. return;
  890. } else if (ua.mac && ua.ch) { // older versions have issues on chrome
  891. _getPluginVersion(function (version) {
  892. if (version && (_getNumericUnityVersion(version.plugin) <= _getNumericUnityVersion("2.6.1f3"))) {
  893. status = kBroken;
  894. data = "OSX-CH-U<=2.6.1f3";
  895. }
  896. _setPluginStatus(status, lastType, data);
  897. callback.call(self, status, version);
  898. }, versions);
  899. return;
  900. } else if (versions) {
  901. _getPluginVersion(function (version) {
  902. _setPluginStatus(status, lastType, data);
  903. callback.call(self, status, version);
  904. }, versions);
  905. return;
  906. }
  907. } else if (typeof win.ActiveXObject != "undefined") {
  908. try {
  909. var uo = new ActiveXObject("UnityWebPlayer.UnityWebPlayer.1");
  910. var pv = uo.GetPluginVersion();
  911. if (versions) {
  912. var v = {};
  913. for (var i = 0; i < versions.length; ++i) {
  914. v[versions[i]] = uo.GetUnityVersion(versions[i]);
  915. }
  916. v.plugin = pv;
  917. }
  918. status = kInstalled;
  919. // 2.5.0 auto update has issues on vista and later
  920. if (pv == "2.5.0f5") {
  921. var m = /Windows NT \d+\.\d+/.exec(nav.userAgent);
  922. if (m && m.length > 0) {
  923. var wv = parseFloat(m[0].split(' ')[2]);
  924. if (wv >= 6) {
  925. status = kBroken;
  926. data = "WIN-U2.5.0f5";
  927. }
  928. }
  929. }
  930. } catch (ex) {
  931. if (ua.win && ua.ie && ua.x64) {
  932. status = kUnsupported;
  933. data = "WIN-IEx64";
  934. }
  935. }
  936. }
  937. _setPluginStatus(status, lastType, data);
  938. callback.call(self, status, v);
  939. },
  940. /**
  941. * @public
  942. * @return {Object} with info about Unity WebPlayer plugin status (not installed, loading, running etc..)
  943. */
  944. handlePluginStatus: function (status, versions) {
  945. // Store targetEl in the closure, to be able to get it back if setTimeout calls again.
  946. var targetEl = cfg.targetEl;
  947. var $targetEl = jQuery(targetEl);
  948. switch(status) {
  949. case kInstalled:
  950. // @todo add support for alternate custom handlers.
  951. this.notifyProgress($targetEl);
  952. this.embedPlugin($targetEl, cfg.callback);
  953. break;
  954. case kMissing:
  955. this.notifyProgress($targetEl);
  956. //this.installPlugin($targetEl);
  957. var self = this;
  958. var delayTime = (cfg.debugLevel === 0) ? 1000 : 8000;
  959. // Do a delay and re-check for plugin
  960. setTimeout(function () {
  961. cfg.targetEl = targetEl;
  962. self.detectUnity(self.handlePluginStatus);
  963. }, delayTime);
  964. break;
  965. case kBroken:
  966. // Browser needs to restart after install
  967. this.notifyProgress($targetEl);
  968. break;
  969. case kUnsupported:
  970. this.notifyProgress($targetEl);
  971. break;
  972. }
  973. },
  974. /**
  975. * @public
  976. * @return {Object} with detailed plugin info, version number and other info that can be retrieved from the plugin.
  977. */
  978. /*getPluginInfo: function () {
  979. },*/
  980. /**
  981. * @public
  982. */
  983. getPluginURL: function () {
  984. var url = "http://unity3d.com/webplayer/";
  985. if (ua.win) {
  986. url = cfg.baseDownloadUrl + _getWinInstall();
  987. } else if (nav.platform == "MacIntel") {
  988. url = cfg.baseDownloadUrl + (cfg.fullInstall ? "webplayer-i386.dmg" : "webplayer-mini.dmg");
  989. if (cfg.referrer !== null) {
  990. url += "?referrer=" + cfg.referrer;
  991. }
  992. } else if (nav.platform == "MacPPC") {
  993. url = cfg.baseDownloadUrl + (cfg.fullInstall ? "webplayer-ppc.dmg" : "webplayer-mini.dmg");
  994. if (cfg.referrer !== null) {
  995. url += "?referrer=" + cfg.referrer;
  996. }
  997. }
  998. return url;
  999. },
  1000. /**
  1001. * @public
  1002. */
  1003. getClickOnceURL: function () {
  1004. return cfg.baseDownloadUrl + "3.0/co/UnityWebPlayer.application?installer=" + encodeURIComponent(cfg.baseDownloadUrl + _getWinInstall());
  1005. },
  1006. /**
  1007. * Embed the plugin into the DOM.
  1008. * @public
  1009. */
  1010. embedPlugin: function (targetEl, callback) {
  1011. targetEl = jQuery(targetEl).empty();
  1012. var src = cfg.src; //targetEl.data('src'),
  1013. var width = cfg.width || "100%"; //TODO: extract those hardcoded values
  1014. var height = cfg.height || "100%";
  1015. var self = this;
  1016. if (ua.win && ua.ie) {
  1017. // ie, dom and object element do not mix & match
  1018. var at = "";
  1019. for (var i in cfg.attributes) {
  1020. if (cfg.attributes[i] != Object.prototype[i]) {
  1021. if (i.toLowerCase() == "styleclass") {
  1022. at += ' class="' + cfg.attributes[i] + '"';
  1023. }
  1024. else if (i.toLowerCase() != "classid") {
  1025. at += ' ' + i + '="' + cfg.attributes[i] + '"';
  1026. }
  1027. }
  1028. }
  1029. var pt = "";
  1030. // we manually add SRC here, because its now defined on the target element.
  1031. pt += '<param name="src" value="' + src + '" />';
  1032. pt += '<param name="firstFrameCallback" value="UnityObject2.instances[' + instanceNumber + '].firstFrameCallback();" />';
  1033. for (var i in cfg.params) {
  1034. if (cfg.params[i] != Object.prototype[i]) {
  1035. if (i.toLowerCase() != "classid") {
  1036. pt += '<param name="' + i + '" value="' + cfg.params[i] + '" />';
  1037. }
  1038. }
  1039. }
  1040. //var tmpHtml = '<div id="' + targetEl.attr('id') + '" style="width: ' + _appendPX(width) + '; height: ' + _appendPX(height) + ';"><object classid="clsid:444785F1-DE89-4295-863A-D46C3A781394" style="display: block; width: 100%; height: 100%;"' + at + '>' + pt + '</object></div>';
  1041. var tmpHtml = '<object classid="clsid:444785F1-DE89-4295-863A-D46C3A781394" style="display: block; width: ' + _appendPX(width) + '; height: ' + _appendPX(height) + ';"' + at + '>' + pt + '</object>';
  1042. var $object = jQuery(tmpHtml);
  1043. targetEl.append( $object );
  1044. embeddedObjects.push( targetEl.attr('id') );
  1045. unityObject = $object[0];
  1046. } else {
  1047. // Create and append embed element into DOM.
  1048. var $embed = jQuery('<embed/>')
  1049. .attr({
  1050. src: src,
  1051. type: cfg.pluginMimeType,
  1052. width: width,
  1053. height: height,
  1054. firstFrameCallback: 'UnityObject2.instances[' + instanceNumber + '].firstFrameCallback();'
  1055. })
  1056. .attr(cfg.attributes)
  1057. .attr(cfg.params)
  1058. .css({
  1059. display: 'block',
  1060. width: _appendPX(width),
  1061. height: _appendPX(height)
  1062. })
  1063. .appendTo( targetEl );
  1064. unityObject = $embed[0];
  1065. }
  1066. //Auto focus the new object/embed, so players dont have to click it before using it.
  1067. //setTimeout is here to workaround a chrome bug.
  1068. //we should not invoke focus on safari on mac. it causes some Input bugs.
  1069. if (!ua.sf || !ua.mac) {
  1070. setTimeout(function() {
  1071. unityObject.focus();
  1072. }, 100);
  1073. }
  1074. if (callback) {
  1075. callback();
  1076. }
  1077. },
  1078. /**
  1079. * Determine which installation method to use on the current platform, and return an array with their identifiers (i.e. 'ClickOnceIE', 'JavaInstall', 'Manual')
  1080. * Take into account which previous methods might have been attempted (and failed) and skip to next best method.
  1081. * @public
  1082. * @return {String}
  1083. */
  1084. getBestInstallMethod: function () {
  1085. // Always fall back to good old manual (download) install.
  1086. var method = 'Manual';
  1087. // Is Java available and not yet attempted?
  1088. if (cfg.enableJava && ua.java && triedJavaInstall === false) {
  1089. method = 'JavaInstall';
  1090. }
  1091. // Is ClickOnce available and not yet attempted?
  1092. else if (cfg.enableClickOnce && ua.co && triedClickOnce === false) {
  1093. method = 'ClickOnceIE';
  1094. }
  1095. return method;
  1096. },
  1097. /**
  1098. * Tries to install the plugin using the specified method.
  1099. * If no method is passed, it will try to use this.getBestInstallMethod()
  1100. * @public
  1101. * @param {String} method The desired install method
  1102. */
  1103. installPlugin: function(method) {
  1104. if (method == null || method == undefined) {
  1105. method = this.getBestInstallMethod();
  1106. }
  1107. var urlToOpen = null;
  1108. switch(method) {
  1109. case "JavaInstall":
  1110. this.doJavaInstall(cfg.targetEl.id);
  1111. break;
  1112. case "ClickOnceIE":
  1113. //urlToOpen = this.getClickOnceURL();
  1114. //window.location = urlToOpen;
  1115. var $iframe = jQuery("<iframe src='" + this.getClickOnceURL() + "' style='display:none;' />");
  1116. jQuery(cfg.targetEl).append($iframe);
  1117. break;
  1118. default:
  1119. case "Manual":
  1120. //doc.location = this.getPluginURL();
  1121. //urlToOpen = this.getPluginURL();
  1122. var $iframe = jQuery("<iframe src='" + this.getPluginURL() + "' style='display:none;' />");
  1123. jQuery(cfg.targetEl).append($iframe);
  1124. break;
  1125. }
  1126. lastType = method;
  1127. _an.send(kStart, method, null, null);
  1128. },
  1129. /**
  1130. * Trigger event using jQuery(document).trigger()
  1131. * @public
  1132. */
  1133. //TODO: verify its use.
  1134. trigger: function (event, params) {
  1135. if (params) {
  1136. debug('trigger("' + event + '")', params);
  1137. } else {
  1138. debug('trigger("' + event + '")');
  1139. }
  1140. jQuery(document).trigger(event, params);
  1141. },
  1142. /**
  1143. * Notify observers about onProgress event
  1144. * @public
  1145. */
  1146. notifyProgress: function (targetEl) {
  1147. //debug('*** notifyProgress ***')
  1148. if (typeof progressCallback !== "undefined" && typeof progressCallback === "function") {
  1149. var payload = {
  1150. ua: ua,
  1151. pluginStatus: pluginStatus,
  1152. bestMethod: null,
  1153. lastType: lastType,
  1154. targetEl: cfg.targetEl,
  1155. unityObj: this
  1156. };
  1157. if (pluginStatus === kMissing) {
  1158. payload.bestMethod = this.getBestInstallMethod();
  1159. }
  1160. if (latestStatus !== pluginStatus) { //Execute only on state change
  1161. latestStatus = pluginStatus;
  1162. progressCallback(payload);
  1163. }
  1164. }
  1165. },
  1166. /**
  1167. * Subscribe to onProgress notification
  1168. * @public
  1169. */
  1170. observeProgress: function (callback) {
  1171. progressCallback = callback;
  1172. },
  1173. /**
  1174. * Callback made by the WebPlayer plugin when the first frame is rendered.
  1175. * @public
  1176. */
  1177. firstFrameCallback : function () {
  1178. debug('*** firstFrameCallback (' + instanceNumber + ') ***');
  1179. pluginStatus = kFirst;
  1180. this.notifyProgress();
  1181. /*
  1182. // What?
  1183. if (status == kFirst) {
  1184. if (pluginStatus == null) {
  1185. return;
  1186. }
  1187. }
  1188. */
  1189. //Webplayer was already installed.
  1190. //Should only log firstframes if it happened after a install.
  1191. if (wasMissing === true) {
  1192. _an.send(pluginStatus, lastType);
  1193. }
  1194. //setRunStatus(kFirst, lastType);
  1195. },
  1196. /**
  1197. * Get a string from a session cookie or SessionStorage
  1198. * @public
  1199. * @return {String}
  1200. */
  1201. /*getSessionString: function (key) {
  1202. },*/
  1203. /**
  1204. * Set a string via a session cookie or SessionStorage
  1205. * @public
  1206. */
  1207. /* setSessionString: function (key, value) {
  1208. },*/
  1209. /**
  1210. * Get a string from a persistent cookie
  1211. * @public
  1212. * @return {String}
  1213. */
  1214. /*getCookie: function (key) {
  1215. },*/
  1216. /**
  1217. * Set a string to a persistent cookie
  1218. * @public
  1219. */
  1220. /*setCookie: function (key, value, expiryDate) {
  1221. },*/
  1222. /**
  1223. * Exposed private function
  1224. * @public
  1225. */
  1226. setPluginStatus: function (status, type, data, url) {
  1227. _setPluginStatus(status, type, data, url);
  1228. },
  1229. /**
  1230. * Exposed private function
  1231. * @public
  1232. */
  1233. doJavaInstall : function (id) {
  1234. _doJavaInstall(id);
  1235. },
  1236. /**
  1237. * Exposed private function
  1238. * @public
  1239. */
  1240. jvmPreloaded : function (id) {
  1241. _jvmPreloaded(id);
  1242. },
  1243. /**
  1244. * Exposed private function
  1245. * @public
  1246. */
  1247. appletStarted : function (id) {
  1248. _appletStarted(id);
  1249. },
  1250. /**
  1251. * Exposed private function
  1252. * @public
  1253. */
  1254. javaInstallDoneCallback : function (id, success, errormessage) {
  1255. _javaInstallDoneCallback(id, success, errormessage);
  1256. },
  1257. getUnity: function() {
  1258. return unityObject;
  1259. }
  1260. }
  1261. // Internal store of each instance.
  1262. instanceNumber = UnityObject2.instances.length;
  1263. UnityObject2.instances.push(publicAPI);
  1264. return publicAPI;
  1265. };
  1266. /**
  1267. * @static
  1268. **/
  1269. UnityObject2.instances = [];