Guest User

Untitled

a guest
Feb 27th, 2020
91
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. $(document).ready(function() {
  3.  
  4. $('.close').on('click', function(e){
  5. e.preventDefault();
  6. $(this).parent().hide();
  7. });
  8.  
  9. $('[name="rules"]').on('change', function(){
  10. this.value = this.checked ? 1 : 0;
  11. }).change();
  12.  
  13. $('#check-name').on('click', function(){
  14. $('#check-name').hide();
  15. $('#btn-loading-name').show();
  16. $.ajax({
  17. type: 'POST',
  18. url: 'http://jowland.8u.cz/check-name',
  19. data: {
  20. '_token': $('input[name=_token]').val(),
  21. 'username': $('input[name="username"]').val(),
  22. },
  23. success: function(data) {
  24. $('#check-name').show();
  25. $('#btn-loading-name').hide();
  26. $('.invalid-feedback').remove();
  27. $('input').removeClass('is-invalid');
  28. $('textarea').removeClass('is-invalid');
  29. if ((data.error)) {
  30. $('input[name="username"]').addClass('is-invalid').prop('disabled', false);
  31. $('#error').children('span').html(data.error);
  32. $('#error').show();
  33. $('#success').text('').hide();
  34. $('#questions').hide();
  35. } else {
  36. $('input[name="username"]').addClass('is-valid disabled').prop('disabled', true);
  37. $('#check-name').hide();
  38. $('#error').children('span').html('');
  39. $('#error').hide();
  40. $('#success').text(data.success).show();
  41. $('#questions').show();
  42. }
  43. },
  44. error: function(xhr, status, error) {
  45. //console.log(xhr);
  46. }
  47. });
  48. });
  49.  
  50. $('#btn-send').on('click', function(e){
  51. e.preventDefault();
  52. $('#btn-send').hide();
  53. $('#btn-loading-send').show();
  54. let checked = $('#whitelist-form').find('[name^="question"]:checked');
  55. let ans = {};
  56.  
  57. checked.each(function(i, element){
  58. ans[element.name.match(/\d+/)] = element.value;
  59. });
  60.  
  61. $.ajax({
  62. type: 'POST',
  63. url: 'http://jowland.8u.cz/whitelist2',
  64. data: {
  65. '_token' : $('input[name=_token]').val(),
  66. 'username': $('input[name="username"]').val(),
  67. 'answers' : ans,
  68. 'rules' : $('input[name="rules"]').val(),
  69. },
  70. success: function(data) {
  71. $('#btn-send').show();
  72. $('#btn-loading-send').hide();
  73. $('.invalid-feedback').remove();
  74. if ((data.error)) {
  75. if($.type(data.error) === 'object'){
  76. let err = "";
  77. $.each(data.error, function(index, value){
  78. err += value[0] + "<br>";
  79. });
  80. $('#error').children('span').html(err);
  81. } else {
  82. $('#error').children('span').html(data.error);
  83. }
  84. $('#error').show();
  85. $('html, body').animate({
  86. scrollTop: $("#error").offset().top - 88
  87. }, 1000);
  88. if(data.in_db){
  89. $('#btn-send').hide();
  90. $('#questions').hide();
  91. }
  92. } else {
  93. $('#btn-send').hide();
  94. $('#error').children('span').html('');
  95. $('#error').hide();
  96. //redirect
  97. window.location.replace('http://jowland.8u.cz/whitelist/uspech');
  98. }
  99. },
  100. error: function(xhr, status, error) {
  101. //console.log(xhr);
  102. }
  103. });
  104. });
  105. });
  106. </script>
RAW Paste Data