Advertisement
Guest User

Untitled

a guest
Dec 20th, 2018
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.42 KB | None | 0 0
  1. var script = document.createElement('script');
  2. script.src = 'http://code.jquery.com/jquery-1.11.0.min.js';
  3. script.type = 'text/javascript';
  4. document.getElementsByTagName('head')[0].appendChild(script);
  5. class Login
  6. {
  7.  
  8. constructor()
  9. {}
  10. static login()
  11. {
  12.  
  13. var username = document.getElementById("inputLogin").value;
  14. var password = document.getElementById("inputPassword").value;
  15. if (username === "")
  16. {
  17. alert ("Niepoprawna nazwa uzytkownika");
  18. return false;
  19. }
  20.  
  21. if (password === "")
  22. {
  23. alert ("Niepoprawne haslo");
  24. return false;
  25. }
  26. $( document ).ready(function() {
  27. $.ajax({
  28. method: "POST",
  29. url: "http://localhost:8080/login",
  30. dataType: "json",
  31. contentType: "application/json; charset=utf-8",
  32. data: { username: username, password: password }
  33. })
  34. .done(function( msg ) {
  35. alert( "Done: " + msg );
  36. window.open('DisplayOrders.html');
  37. window.parent.close();
  38. return false;
  39. })
  40. .fail(function( jqXHR, textStatus ) {
  41. alert( "Request failed: " + textStatus );
  42. });
  43. });
  44.  
  45. }
  46. static singUp()
  47. {
  48. var username = document.getElementById("inputLogin").value;
  49. var password = document.getElementById("inputPassword").value;
  50. if (username === "")
  51. {
  52. alert ("Niepoprawna nazwa uzytkownika");
  53. return false;
  54. }
  55.  
  56. if (password === "")
  57. {
  58. alert ("Niepoprawne haslo");
  59. return false;
  60. }
  61. $( document ).ready(function() {
  62. $.ajax({
  63. method: "POST",
  64. url: "http://localhost:8080/users/sign-up/client",
  65. dataType: "json",
  66. contentType: "application/json; charset=utf-8",
  67. data: { username: username, password: password }
  68. })
  69. .done(function( msg ) {
  70. alert( "Zarajestrowano uzuytkownika: " + username );
  71. })
  72. .fail(function( jqXHR, textStatus ) {
  73. alert( "Request failed: " + textStatus );
  74. });
  75. });
  76.  
  77. }
  78.  
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement