|
| 1 | +<!DOCTYPE html> |
| 2 | +<html> |
| 3 | +<head> |
| 4 | + <meta charset="utf-8" /> |
| 5 | + <title>CARD GAME</title> |
| 6 | + <link rel="stylesheet" type="text/css" href="JS CLASS - Login System.css"> |
| 7 | + <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.7.2/css/all.css"> |
| 8 | + <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> |
| 9 | + <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js"></script> |
| 10 | + <meta name="viewport" content="width=device-width, initial-scale=1"> |
| 11 | + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"> |
| 12 | + <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script> |
| 13 | + <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script> |
| 14 | + <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script> |
| 15 | +</head> |
| 16 | +<body> |
| 17 | + |
| 18 | + <div id="login_table"> |
| 19 | + <div class="input-group mb-3"> |
| 20 | + <div class="input-group-prepend"> |
| 21 | + <span class="input-group-text"><i class="fas fa-user"></i></span> |
| 22 | + </div> |
| 23 | + <input type="text" class="form-control" id="username" placeholder="Username" aria-label="Username" aria-describedby="basic-addon1"> |
| 24 | + </div> |
| 25 | + <div class="input-group mb-3"> |
| 26 | + <div class="input-group-prepend"> |
| 27 | + <span class="input-group-text"><i class="fas fa-lock-open"></i></span> |
| 28 | + </div> |
| 29 | + <input type="password" class="form-control" id="password" placeholder="Password" aria-label="Username" aria-describedby="basic-addon1"> |
| 30 | + </div> |
| 31 | + <button id="login" class="btn btn-dark btn-lg btn-block">LOGIN</button> |
| 32 | + </div> |
| 33 | + |
| 34 | + <div id="myModal" class="modal"> |
| 35 | + <div class="modal-content"> |
| 36 | + <span class="close">×</span> |
| 37 | + <p class="message"></p> |
| 38 | + </div> |
| 39 | + </div> |
| 40 | + |
| 41 | + |
| 42 | + |
| 43 | +<script> |
| 44 | + |
| 45 | + class Users{ |
| 46 | + constructor(username,password){ |
| 47 | + this.username = username; |
| 48 | + this.password = password; |
| 49 | + } |
| 50 | + control_variable(control_username,control_password){ |
| 51 | + this.control_username = control_username; |
| 52 | + this.control_password = control_password; |
| 53 | + } |
| 54 | + control(){ |
| 55 | + if(this.control_username == this.username && this.control_password == this.password){ |
| 56 | + $(".message").text(`WELCOME ${$('#username').val()}`) |
| 57 | + }else{ |
| 58 | + $(".message").text('You have entered incorrectly.') |
| 59 | + } |
| 60 | + } |
| 61 | + }; |
| 62 | + |
| 63 | + let User_variables = { |
| 64 | + // username : password |
| 65 | + "furkan" : 'gulsen', |
| 66 | + "maria" : "allen", |
| 67 | + "bob" : "quenn", |
| 68 | + 'rick' : 'rick123' |
| 69 | + } |
| 70 | + |
| 71 | + var modal = document.getElementById('myModal'); |
| 72 | + var btn = document.getElementById("myBtn"); |
| 73 | + var span = document.getElementsByClassName("close")[0]; |
| 74 | + |
| 75 | + $("#login").click(function(){ |
| 76 | + let user = new Users($('#username').val(), $('#password').val()); |
| 77 | + var password = User_variables[$('#username').val()] |
| 78 | + user.control_variable($('#username').val(),password); |
| 79 | + user.control(); |
| 80 | + modal.style.display = "block"; |
| 81 | + }); |
| 82 | + |
| 83 | + span.onclick = function() { |
| 84 | + modal.style.display = "none"; |
| 85 | + }; |
| 86 | + |
| 87 | + window.onclick = function(event) { |
| 88 | + if (event.target == modal) { |
| 89 | + modal.style.display = "none"; |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | +</script> |
| 94 | +</body> |
| 95 | +</html> |
0 commit comments