Advertisement
Guest User

Untitled

a guest
Sep 15th, 2016
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.78 KB | None | 0 0
  1. <!DOCTYPE html>
  2.  
  3. <html>
  4. <head>
  5. <title>Battle INF</title>
  6. <meta charset="UTF-8">
  7.  
  8. <!--1000 Seems to work well and 0.6 ensures the site is zoomed all the way out-->
  9. <meta name="viewport" content="width=1000, initial-scale=0.5, maximum-scale=0.5">
  10.  
  11.  
  12.  
  13.  
  14. <script src="http://battleinf.com:4001/shared/js/lib/sockjs.min.js"></script>
  15. <script src="http://battleinf.com:4001/shared/js/lib/sockjsWrapper.js"></script>
  16. <script src="http://battleinf.com:4001/shared/js/static/TimeStatic.js"></script>
  17. <script src="http://battleinf.com:4001/shared/js/lib/hammer.min.js"></script>
  18. <script src="http://battleinf.com:4001/shared/js/lib/velocity.js"></script>
  19.  
  20.  
  21.  
  22.  
  23.  
  24. <script>
  25. var config = {};
  26. var components = {
  27. shared: {
  28. game: {}
  29. }
  30. };
  31. var systemTime = 1473784204035;
  32. var gameState = {
  33. ready:false
  34. ,sessionUserId: 869
  35. ,disconnected:false
  36. ,view:['construction','leftHand']
  37. ,world: {
  38. objects:[]
  39. ,connections:[]
  40. }
  41. ,area: {}
  42. ,connectedUsers: []
  43. ,battleUserStats: {}
  44. }
  45.  
  46. // Get the server name:port
  47. var serverName = window.location.href.split('/')[2];
  48.  
  49. // Connect to the server
  50. function sockConnect() {
  51. sock = new SockJS('http://battleinf.com:4001/sock');
  52. // sock.debug = true;
  53. //sock.debugEvents = [''];
  54. }
  55. sockConnect();
  56.  
  57. // Messages for socket open/close
  58. sock.addDoOnOpen(function() {
  59. console.log('SOCKET OPEN');
  60. var cookieParts = document.cookie.split(';');
  61. var cookies = {};
  62. for (var i in cookieParts) {
  63. var parts = cookieParts[i].split('=');
  64. cookies[parts[0].trim()] = parts[1];
  65. }
  66.  
  67. sock.send('shared.connectSession', {sessionId: (new Date).getTime()});
  68. console.log('connected!');
  69.  
  70. });
  71.  
  72. function checkStatus() {
  73.  
  74.  
  75.  
  76. sock.onevent('checkStatus', function(data) {
  77. if (data.success) {
  78. account.loggedIn = true;
  79. sock.addDoOnOpen(function() {
  80. sock.send('shared.socketLogin', null);
  81. })
  82. }
  83. })
  84.  
  85. sock.send('shared.checkStatus', null);
  86.  
  87. }
  88. function login() {
  89.  
  90. console.log('logged in');
  91.  
  92.  
  93. sock.onevent('justPlay', function(data) {
  94.  
  95. sock.send('account.signup', {
  96. username:data.username
  97. ,email:""
  98. ,password:data.password
  99. ,random:true
  100. });
  101. });
  102. sock.send('account.random', {justPlay:true});
  103. }
  104.  
  105. function mine() {
  106. sock.send('world.selectArea', {areaId:22});
  107. sock.send('userSetTownAction', {action:'mineIron'});
  108. console.log('mining?');
  109. }
  110. sock.addDoOnClose(function() {
  111. console.log('SOCKET CLOSED');
  112. gameState.ready = false;
  113. gameState.disconnected = true;
  114. userActions.update();
  115. });
  116. </script>
  117.  
  118.  
  119. <script>
  120. ScriptAPI.execute();
  121. </script>
  122.  
  123. <script>
  124. var gameTitle = 'Battle INF';
  125. var gameVersion = 'v0.2a';
  126. </script>
  127.  
  128.  
  129. </head>
  130. <body onclick="bodyClick()">
  131. <button onclick="mine()">mine</button>
  132. <button onclick="login()">login</button>
  133. <button onclick="checkStatus()">check status</button>
  134.  
  135. </body>
  136. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement