Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var script = document.createElement('script');
- script.src = 'http://code.jquery.com/jquery-1.11.0.min.js';
- script.type = 'text/javascript';
- document.getElementsByTagName('head')[0].appendChild(script);
- class Login
- {
- constructor()
- {}
- static login()
- {
- var username = document.getElementById("inputLogin").value;
- var password = document.getElementById("inputPassword").value;
- if (username === "")
- {
- alert ("Niepoprawna nazwa uzytkownika");
- return false;
- }
- if (password === "")
- {
- alert ("Niepoprawne haslo");
- return false;
- }
- $( document ).ready(function() {
- $.ajax({
- method: "POST",
- url: "http://localhost:8080/login",
- dataType: "json",
- contentType: "application/json; charset=utf-8",
- data: { username: username, password: password }
- })
- .done(function( msg ) {
- alert( "Done: " + msg );
- window.open('DisplayOrders.html');
- window.parent.close();
- return false;
- })
- .fail(function( jqXHR, textStatus ) {
- alert( "Request failed: " + textStatus );
- });
- });
- }
- static singUp()
- {
- var username = document.getElementById("inputLogin").value;
- var password = document.getElementById("inputPassword").value;
- if (username === "")
- {
- alert ("Niepoprawna nazwa uzytkownika");
- return false;
- }
- if (password === "")
- {
- alert ("Niepoprawne haslo");
- return false;
- }
- $( document ).ready(function() {
- $.ajax({
- method: "POST",
- url: "http://localhost:8080/users/sign-up/client",
- dataType: "json",
- contentType: "application/json; charset=utf-8",
- data: { username: username, password: password }
- })
- .done(function( msg ) {
- alert( "Zarajestrowano uzuytkownika: " + username );
- })
- .fail(function( jqXHR, textStatus ) {
- alert( "Request failed: " + textStatus );
- });
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement