index.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5. <title>Unity Web Player | %UNITY_WEB_NAME%</title>
  6. %UNITY_UNITYOBJECT_DEPENDENCIES%
  7. <script type="text/javascript">
  8. <!--
  9. var unityObjectUrl = "%UNITY_UNITYOBJECT_URL%";
  10. if (document.location.protocol == 'https:')
  11. unityObjectUrl = unityObjectUrl.replace("http://", "https://ssl-");
  12. document.write('<script type="text\/javascript" src="' + unityObjectUrl + '"><\/script>');
  13. //from http://stackoverflow.com/questions/979975/how-to-get-the-value-from-url-parameter
  14. var QueryString = function () {
  15. // This function is anonymous, is executed immediately and
  16. // the return value is assigned to QueryString!
  17. var query_string = {};
  18. var query = window.location.search.substring(1);
  19. var vars = query.split("&");
  20. for (var i=0;i<vars.length;i++) {
  21. var pair = vars[i].split("=");
  22. // If first entry with this name
  23. if (typeof query_string[pair[0]] === "undefined") {
  24. query_string[pair[0]] = pair[1];
  25. // If second entry with this name
  26. } else if (typeof query_string[pair[0]] === "string") {
  27. var arr = [ query_string[pair[0]], pair[1] ];
  28. query_string[pair[0]] = arr;
  29. // If third or later entry with this name
  30. } else {
  31. query_string[pair[0]].push(pair[1]);
  32. }
  33. }
  34. return query_string;
  35. } ();
  36. function CheckResolution()
  37. {
  38. if (QueryString["width"] != undefined)
  39. {
  40. console.log("Resolution is "+QueryString["width"]+"x"+QueryString["height"]);
  41. var contentElement = document.getElementById("content");
  42. contentElement.style.width=QueryString["width"]+"px";
  43. var unityPlayerElement = document.getElementById("unityPlayer");
  44. unityPlayerElement.style.width=QueryString["width"]+"px";
  45. unityPlayerElement.style.height=QueryString["height"]+"px";
  46. }
  47. };
  48. function PlaybackForRecordedResolution(recordedScreenWidth, recordedScreenHeight)
  49. {
  50. //if we don't have a url parameter already set
  51. if (QueryString["width"] == undefined)
  52. {
  53. var newUrl = window.location.href;
  54. newUrl += newUrl.indexOf("?") == -1 ? "?" : "&";
  55. newUrl += "width="+recordedScreenWidth;
  56. newUrl += "&height="+recordedScreenHeight;
  57. window.location.assign(newUrl);
  58. }
  59. }
  60. -->
  61. </script>
  62. <script type="text/javascript">
  63. <!--
  64. jQuery(function() {
  65. var config = {
  66. width: QueryString["width"] != undefined? QueryString["width"] : %UNITY_WIDTH%,
  67. height: QueryString["height"] != undefined? QueryString["height"] : %UNITY_HEIGHT%,
  68. params: %UNITY_PLAYER_PARAMS%
  69. };
  70. var u = new UnityObject2(config);
  71. var $missingScreen = jQuery("#unityPlayer").find(".missing");
  72. var $brokenScreen = jQuery("#unityPlayer").find(".broken");
  73. $missingScreen.hide();
  74. $brokenScreen.hide();
  75. u.observeProgress(function (progress) {
  76. switch(progress.pluginStatus) {
  77. case "broken":
  78. $brokenScreen.find("a").click(function (e) {
  79. e.stopPropagation();
  80. e.preventDefault();
  81. u.installPlugin();
  82. return false;
  83. });
  84. $brokenScreen.show();
  85. break;
  86. case "missing":
  87. $missingScreen.find("a").click(function (e) {
  88. e.stopPropagation();
  89. e.preventDefault();
  90. u.installPlugin();
  91. return false;
  92. });
  93. $missingScreen.show();
  94. break;
  95. case "installed":
  96. $missingScreen.remove();
  97. break;
  98. case "first":
  99. break;
  100. }
  101. });
  102. u.initPlugin(jQuery("#unityPlayer")[0], "%UNITY_WEB_PATH%"+window.location.search+"&version=1.06");
  103. });
  104. -->
  105. </script>
  106. <script src="http://connect.facebook.net/en_US/all.js"></script>
  107. <script type="text/javascript">
  108. //Fired when the facebook sdk has loaded
  109. window.fbAsyncInit = function()
  110. {
  111. console.log("facebook plugin started");
  112. };
  113. //Load the Facebook JS SDK
  114. (function(d, s, id){
  115. var js, fjs = d.getElementsByTagName(s)[0];
  116. if (d.getElementById(id)) {return;}
  117. js = d.createElement(s); js.id = id;
  118. js.src = "//connect.facebook.net/en_US/all.js";
  119. fjs.parentNode.insertBefore(js, fjs);
  120. }(document, 'script', 'facebook-jssdk'));
  121. function FaceBookInit()
  122. {
  123. var appid = "528376777241923";
  124. FB.init(
  125. {
  126. appId : appid,
  127. status : true, // check login status
  128. cookie : true, // enable cookies to allow the server to access the session
  129. oauth : true, // enable OAuth 2.0
  130. xfbml : false // dont parse XFBML
  131. });
  132. console.log("facebook started");
  133. }
  134. function Login(actionHash, parameters)
  135. {
  136. if(parameters)
  137. {
  138. console.log("logging with basic permissions");
  139. FB.login(function(response)
  140. {
  141. var result = actionHash + JSON.stringify(response);
  142. getUnity().SendMessage("FacebookWebManager", "OnComplete",result);
  143. GetSessionValidity(null);
  144. }, {scope: parameters});
  145. }
  146. else
  147. {
  148. console.log("logging with extended permissions");
  149. FB.getLoginStatus(function(loginStatusResponse)
  150. {
  151. if(!loginStatusResponse.authResponse) //Not logged in, log him in
  152. {
  153. console.log("logging in....");
  154. FB.login(function(response)
  155. {
  156. var result = actionHash + JSON.stringify(response);
  157. getUnity().SendMessage("FacebookWebManager", "OnComplete", result);
  158. });
  159. }
  160. else
  161. {
  162. console.log("already logged in....");
  163. var result = actionHash + JSON.stringify(loginStatusResponse);
  164. getUnity().SendMessage("FacebookWebManager", "OnComplete", result);
  165. }
  166. GetSessionValidity(null);
  167. });
  168. }
  169. }
  170. function Logout(actionHash)
  171. {
  172. FB.logout(function(response) {
  173. var result = actionHash + JSON.stringify(response);
  174. getUnity().SendMessage("FacebookWebManager", "OnComplete", result);
  175. GetSessionValidity();
  176. });
  177. }
  178. function getUnity()
  179. {
  180. if (typeof unityObject != "undefined")
  181. {
  182. return unityObject.getObjectById("unityPlayer");
  183. }
  184. return null;
  185. }
  186. function LogMessage(message)
  187. {
  188. console.log(message);
  189. }
  190. if (typeof unityObject != "undefined")
  191. {
  192. unityObject.embedUnity("unityPlayer", "WebPlayer.unity3d", 1024, 1024);
  193. }
  194. function OpenDialog(actionHash, parameters )
  195. {
  196. GetSessionValidity(null);
  197. var params = JSON.parse(parameters);
  198. FB.ui(
  199. params
  200. ,
  201. function(response) {
  202. var result = actionHash + JSON.stringify(response);
  203. getUnity().SendMessage("FacebookWebManager", "OnComplete", result);
  204. }
  205. );
  206. }
  207. function GetSessionValidity(callback)
  208. {
  209. FB.getLoginStatus(function(loginStatusResponse)
  210. {
  211. if (typeof callback === "function")
  212. {
  213. callback(!loginStatusResponse.authResponse);
  214. }
  215. getUnity().SendMessage("FacebookWebManager", "UpdateSessionValidity", (!loginStatusResponse.authResponse)?"false":"true" );
  216. });
  217. }
  218. function GraphRequest(actionHash,graphPath,httpMethod, parameters )
  219. {
  220. GetSessionValidity(function(result)
  221. {
  222. Console.log("Graph Request");
  223. if(result)
  224. {
  225. console.log(parameters);
  226. var params = JSON.parse(parameters);
  227. FB.api(
  228. graphPath,
  229. httpMethod,
  230. params,
  231. function(response) {
  232. var result = actionHash + JSON.stringify(response);
  233. getUnity().SendMessage("FacebookWebManager", "OnComplete", result);
  234. });
  235. }
  236. });
  237. }
  238. </script>
  239. <style type="text/css">
  240. <!--
  241. body {
  242. font-family: Helvetica, Verdana, Arial, sans-serif;
  243. background-color: white;
  244. color: black;
  245. text-align: center;
  246. }
  247. a:link, a:visited {
  248. color: #000;
  249. }
  250. a:active, a:hover {
  251. color: #666;
  252. }
  253. p.header {
  254. font-size: small;
  255. }
  256. p.header span {
  257. font-weight: bold;
  258. }
  259. p.footer {
  260. font-size: x-small;
  261. }
  262. div#content {
  263. margin: auto;
  264. width: %UNITY_WIDTH%px;
  265. }
  266. div.broken,
  267. div.missing {
  268. margin: auto;
  269. position: relative;
  270. top: 50%;
  271. width: 193px;
  272. }
  273. div.broken a,
  274. div.missing a {
  275. height: 63px;
  276. position: relative;
  277. top: -31px;
  278. }
  279. div.broken img,
  280. div.missing img {
  281. border-width: 0px;
  282. }
  283. div.broken {
  284. display: none;
  285. }
  286. div#unityPlayer {
  287. cursor: default;
  288. height: %UNITY_HEIGHT%px;
  289. width: %UNITY_WIDTH%px;
  290. }
  291. -->
  292. </style>
  293. </head>
  294. <body onload="CheckResolution()">
  295. <p class="header"><span>Unity Web Player | </span>%UNITY_WEB_NAME%</p>%UNITY_BETA_WARNING%
  296. <div id="fb-root"></div>
  297. <div id="content">
  298. <div id="unityPlayer">
  299. <div class="missing">
  300. <a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now!">
  301. <img alt="Unity Web Player. Install now!" src="http://webplayer.unity3d.com/installation/getunity.png" width="193" height="63" />
  302. </a>
  303. </div>
  304. <div class="broken">
  305. <a href="http://unity3d.com/webplayer/" title="Unity Web Player. Install now! Restart your browser after install.">
  306. <img alt="Unity Web Player. Install now! Restart your browser after install." src="http://webplayer.unity3d.com/installation/getunityrestart.png" width="193" height="63" />
  307. </a>
  308. </div>
  309. </div>
  310. </div>
  311. <p class="footer">&laquo; created with <a href="http://unity3d.com/unity/" title="Go to unity3d.com">Unity</a> &raquo;</p>
  312. </body>
  313. </html>