Advertisement
Guest User

Untitled

a guest
Jun 18th, 2017
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. <script>
  2.  
  3. var gogoGadget = function() {
  4. jQuery(function($) {
  5. $(".wrapper").i18n();
  6.  
  7. var GLOBALDATA = {};
  8. var originaldata = {
  9. siteid: "mctrades.org",
  10. postback: "https:\/\/mctrades.org\/mc-association\/confirm?stage=3\x26username=Jayson",
  11. key: "SmF5c29uxd\/ArWdsYKN6zZ6s0MAFRtkNO44=",
  12. mcuser: "Jayson"
  13. };
  14. var FIRST_SKIN_CHANGE_CHECK = 5000;
  15. var BETWEEN_SKIN_CHANGE_CHECK = 2000;
  16.  
  17. var checkSkinReady = function() {
  18. $.ajax({
  19. type: 'POST',
  20. url: '/api/user/authenticate',
  21. data: {
  22. uuid: GLOBALDATA.uuid,
  23. password: GLOBALDATA.password,
  24. data: originaldata
  25. },
  26. global: false,
  27. dataType: 'json'
  28. }).done(function(data) {
  29. if (!data.correct) {
  30. setTimeout(checkSkinReady, BETWEEN_SKIN_CHANGE_CHECK);
  31. return;
  32. }
  33.  
  34. performRedirect(data);
  35. }).fail(function() {
  36. setTimeout(checkSkinReady, BETWEEN_SKIN_CHANGE_CHECK);
  37. });
  38. };
  39.  
  40. var performRedirect = function(data) {
  41. if (data.postback && data.postbackdata) {
  42. var f = $('#postbackform');
  43. f.attr('action', data.postback);
  44. $('#postbackdata').attr('value', data.postbackdata);
  45. $('.please-wait').removeClass('hide');
  46. f.submit();
  47. }
  48. }
  49.  
  50. $(document).ajaxSend(function() {
  51. $('.section').addClass('hide');
  52. $('.please-wait').removeClass('hide');
  53. }).ajaxComplete(function() {
  54. $('.please-wait').addClass('hide');
  55. }).ajaxError(function(_, _, o) {
  56.  
  57. if (o.url.indexOf('static/locales/') === 0) return;
  58.  
  59. $('.section').addClass('hide');
  60. $('.an-error-occurred').removeClass('hide');
  61. });
  62.  
  63. $('.intro form').submit(function() {
  64. if ($('#mcusername').val().length == 0) return false;
  65.  
  66. $.ajax({
  67. type: 'POST',
  68. url: '/api/user/check',
  69. data: {
  70. mcusername: $('#mcusername').val()
  71. },
  72. dataType: 'json'
  73. }).done(function(data) {
  74. if (data.error) {
  75. $('.intro').removeClass('hide');
  76. $('.intro .no-such-user').removeClass('hide');
  77. $('.intro input').focus();
  78. return;
  79. }
  80.  
  81. GLOBALDATA.uuid = data.uuid;
  82. GLOBALDATA.username = data.username;
  83. if (!data.exists) {
  84. $('.pick-a-pass').removeClass('hide');
  85. $('.pick-a-pass input').focus();
  86. } else {
  87. $('.enter-pass').removeClass('hide');
  88. $('.enter-pass input').focus();
  89. }
  90. });
  91. return false;
  92. });
  93.  
  94. $('.pick-a-pass form').submit(function() {
  95. if ($('#new-password').val() == '') {
  96.  
  97.  
  98. return false;
  99. }
  100.  
  101. $.ajax({
  102. type: 'POST',
  103. url: '/api/user/create',
  104. data: {
  105. uuid: GLOBALDATA.uuid,
  106. password: $('#new-password').val()
  107. },
  108. dataType: 'json'
  109. }).done(function(data) {
  110. var skinUri = 'http://' + window.location.host + '/media/skin/' + data.filename + '.png';
  111. $('.change-skin a').attr('href', 'https://minecraft.net/profile/skin/remote?url=' + encodeURIComponent(skinUri));
  112.  
  113. $('.change-skin').removeClass('hide');
  114.  
  115. GLOBALDATA.password = $('#new-password').val();
  116.  
  117. setTimeout(checkSkinReady, FIRST_SKIN_CHANGE_CHECK);
  118. });
  119. return false;
  120. });
  121.  
  122. $('.enter-pass form').submit(function() {
  123. $.ajax({
  124. type: 'POST',
  125. url: '/api/user/authenticate',
  126. data: {
  127. uuid: GLOBALDATA.uuid,
  128. password: $('#password').val(),
  129. data: originaldata
  130. },
  131. dataType: 'json'
  132. }).done(function(data) {
  133. if (!data.correct) {
  134. $('.enter-pass').removeClass('hide');
  135. $('.enter-pass .password-incorrect').removeClass('hide');
  136. return;
  137. }
  138.  
  139. performRedirect(data);
  140. });
  141. return false;
  142. });
  143.  
  144. $('.enter-pass .forgotten').click(function() {
  145. $('.enter-pass').addClass('hide');
  146. $('.pick-a-pass').removeClass('hide');
  147. });
  148. });
  149. };
  150.  
  151. i18n.init({
  152. resGetPath: 'static/locales/__lng__/__ns__.json'
  153. }, gogoGadget);
  154. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement