Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>login.overlay3-complete</title>
- <style>
- .textfield {
- background: white;
- border: 1px solid grey;
- border-radius: 5px;
- font-family: 'Lato', sans-serif black;
- height: 30px;
- width: 100%;
- }
- .textfield3 {
- background: white;
- border: 1px solid grey;
- border-radius: 5px;
- font-family: 'Lato', sans-serif black;
- height: 30px;
- margin-bottom: 20px;
- width: 100%;
- }
- .textfield-email {
- background: white;
- border: 1px solid grey;
- border-radius: 5px;
- font-family: 'Lato', sans-serif black;
- height: 30px;
- width: 90%;
- }
- #overlay-button {
- background: #3c683c;
- border: 1px solid black;
- border-radius: 5px;
- float: left;
- font-family: 'Lato', sans-serif black;
- height: 35px;
- margin-top: 20px;
- margin-left: 20px;
- text-align: center;
- width: 70px;
- }
- #logout-button {
- background: #a60008;
- border: 1px solid black;
- border-radius: 5px;
- display: none;
- font-family: 'Lato', sans-serif black;
- height: 35px;
- margin-top: 20px;
- margin-left: 20px;
- text-align: center;
- width: 100px;
- }
- #login-button2 {
- background: #3c683c;
- border: 1px solid black;
- border-radius: 5px;
- float: left;
- font-family: 'Lato', sans-serif black;
- height: 35px;
- margin-top: 20px;
- margin-left: 20px;
- text-align: center;
- width: 100px;
- }
- #login-button {
- background: #e1e1e1;
- border: 1px solid grey;
- border-radius: 5px;
- float: left;
- font-family: 'Lato', sans-serif black;
- height: 35px;
- margin-right: 40px;
- margin-top: 20px;
- text-align: center;
- width: 30%;
- min-width: 80px;
- max-width: 200px;
- }
- #register-button {
- background: #e1e1e1;
- border: 1px solid grey;
- border-radius: 5px;
- font-family: 'Lato', sans-serif black;
- height: 35px;
- margin-top: 20px;
- text-align: center;
- width: 50%;
- min-width: 136px;
- max-width: 300px;
- }
- .acc-settings {
- background: #3c683c;
- border: 1px solid black;
- border-radius: 5px;
- font-family: 'Lato', sans-serif black;
- height: 35px;
- margin-top: 20px;
- margin-left: 20px;
- text-align: center;
- }
- .btn-myAccount {
- width: 130px;
- }
- #btnMyAccount {
- display: none;
- }
- .btn-changePassword {
- width: 200px;
- }
- #my-account {
- background: #3c683c;
- border: 1px solid black;
- border-radius: 5px;
- display: none;
- font-family: 'Lato', sans-serif black;
- height: 35px;
- margin-left: 20px;
- text-align: center;
- width: 130px;
- }
- #username {
- float: left;
- }
- #password {
- float: left;
- }
- #password-text {
- margin-top: 50px;
- }
- .login-div {
- border: 2px solid #a5a5a5;
- border-radius: 5px;
- -webkit-box-shadow: 10px 4px 10px 0 #CCCCCC;
- height: 230px;
- width: 60%;
- }
- .field-div {
- border: 0;
- height: 186px;
- margin: 20px;
- width: auto;
- }
- .login-div2 {
- background: white;
- border: 2px solid black;
- border-radius: 5px;
- -webkit-box-shadow: 10px 4px 10px 0 black;
- height: 305px;
- width: 60%;
- min-width: 300px;
- z-index: 6;
- }
- .field-div2 {
- border: 0;
- height: 261px;
- margin: 20px;
- width: auto;
- }
- #email-text {
- margin-top: 50px;
- }
- #login-overlay {
- background-color: rgba(0,0,0,0.5);
- display: none;
- height: 100%;
- position: fixed;
- width: 100%;
- z-index: 5;
- }
- .overlay-all {
- margin-left: auto;
- margin-right: auto;
- margin-top: 100px;
- }
- .current-user {
- background-color: #CCCCCC;
- border: 1px solid black;
- border-radius: 5px;
- color: black;
- font-size: 18px;
- height: 35px;
- margin-top: 20px;
- margin-left: 20px;
- margin-right: auto;
- min-width: 300px;
- padding-left: 10px;
- padding-right: 10px;
- }
- #alert-message {
- animation: slideDown 2s forwards;
- background: #e1e1e1;
- border-bottom: 1px solid #a5a5a5;
- color: black;
- display: none;
- height: auto;
- min-height: 40px;
- text-align: center;
- width: 100%;
- z-index: 6;
- }
- #alert-info {
- background: #000078;
- border: 1px solid black;
- border-radius: 5px;
- color: #fff;
- float: left;
- font-family: 'Lato', sans-serif black;
- font-size: 18px;
- height: 35px;
- margin-top: 20px;
- margin-left: 50px;
- text-align: center;
- width: 40px;
- }
- .tfield {
- background-color: #CCCCCC;
- border: 1px solid black;
- border-radius: 5px;
- color: black;
- font-size: 18px;
- height: 35px;
- margin-top: 20px;
- margin-left: 20px;
- margin-right: auto;
- min-width: 300px;
- padding-left: 10px;
- padding-right: 10px;
- }
- #myAccount-div {
- background: white;
- border: 0;
- display: none;
- font-family: 'Lato', sans-serif black;
- height: 300px;
- margin-top: 30px;
- margin-left: 20px;
- min-width: 376px;
- width: 50%;
- }
- #changePW-div {
- display: none;
- height: 300px;
- margin-left: 20px;
- width: 95%;
- }
- </style>
- </head>
- <body>
- <button id="login-button2">Login</button>
- <button id="logout-button">Logout</button>
- <button class="btn-myAccount acc-settings" id="btnMyAccount">My Account</button>
- <div class="current-user">
- <p id="current-user">current user: guest</p>
- </div>
- <div id="myAccount-div">
- <label for="myAccount-username">Username</label>
- <input type="text" id="myAccount-username" class="textfield" readonly>
- <label for="myAccount-password">Password</label>
- <input type="password" id="myAccount-password" class="textfield" readonly>
- <label for="myAccount-email">E-mail</label>
- <input type="text" id="myAccount-email" class="textfield" readonly>
- <button class="acc-settings btn-changePassword" id="change-password">Change Password</button>
- </div>
- <div id="login-overlay">
- <div id="alert-message">
- <p class="alert-message"></p>
- </div>
- <button id="overlay-button">❮</button>
- <button id="alert-info">i</button>
- <div class="overlay-all">
- <div class="login-div2">
- <div class="field-div2">
- <div class="field-text">
- <label for="username">Username</label>
- <input type="text" name = "username" id="username" class="textfield3" maxlength="16" required>
- <label for="password">Password</label>
- <input type="password" id="password" class="textfield3" maxlength="16" required>
- <label for="email">Email</label>
- <input type="text" id="email" class="textfield" maxlength="32" required>
- <button id="login-button">Login</button>
- <button id="register-button">Register</button>
- </div>
- </div>
- </div>
- </div>
- </div>
- <div id="changePW-div">
- <label for="pwchange">Old Password</label>
- <input type="password" id="pwchange" class="textfield" maxlength="16" required>
- <label for="pwField1">New Password</label>
- <input type="password" id="pwField1" class="textfield" maxlength="16" required>
- <label for="pwField2">Confirm New Password</label>
- <input type="password" id="pwField2" class="textfield" maxlength="16" required>
- <p id="pwChangeMessage"><p>
- <button class="acc-settings changePassword" id="changePassword">Change Password</button>
- </div>
- <script>
- var username; var password; var email; var regUsername = null; var regPassword = null; var regEmail = "email1@test.de";
- var toggleInfo = false; var toggleMyAccount = false; var toggleChangePW = false;
- var alertMessage = document.getElementById('alert-message');
- var loginButton2 = document.getElementById('login-button2');
- var logoutButton = document.getElementById('logout-button');
- var loginOverlay = document.getElementById('login-overlay');
- var currentUser = document.getElementById('current-user');
- var myAccountUsername = document.getElementById('myAccount-username');
- var myAccountPassword = document.getElementById('myAccount-password');
- var myAccountEmail = document.getElementById('myAccount-email');
- var btnMyAccount = document.getElementById('btnMyAccount');
- var myAccountDiv = document.getElementById('myAccount-div');
- var oldPassword = document.getElementById('pwchange');
- var newPassword = document.getElementById('pwField1');
- var newPasswordConfirm = document.getElementById('pwField2');
- var pwChangeMessage = document.getElementById('pwChangeMessage');
- var changePWDiv = document.getElementById('changePW-div');
- document.getElementById('login-button').addEventListener("click", login);
- document.getElementById('register-button').addEventListener("click", register);
- document.getElementById('login-button2').addEventListener("click", overlayOpen);
- document.getElementById('overlay-button').addEventListener("click", overlayClose);
- document.getElementById('logout-button').addEventListener("click", logout);
- document.getElementById('alert-info').addEventListener("click", info);
- document.getElementById('btnMyAccount').addEventListener("click", myAccount);
- document.getElementById('change-password').addEventListener("click", changePasswordBtn);
- document.getElementById('changePassword').addEventListener("click", changePassword);
- function register(){
- regUsername = document.getElementById('username').value;
- regPassword = document.getElementById('password').value;
- regEmail = document.getElementById('email').value;
- if(regUsername !== null && regUsername !== "" && password !== null && password !== "" && email !== null && email !== ""){
- alerts("#000", "#008700", "Your account " + username + " has been created");
- } else {
- regUsername = null; regPassword = null; regEmail = null;
- alerts("#000", "#878700", "Warning! You have to fill all the fields with details");
- }
- }
- function login(){
- username = document.getElementById('username').value;
- password = document.getElementById('password').value;
- if(username !== null && username !== "" && password !== null && password !== "" && username === "username1" && password === "password1" || username === regUsername && password === regPassword){
- loginButton2.style.display = "none";
- logoutButton.style.display = "block";
- currentUser.innerHTML = "current user: " + username;
- btnMyAccount.style.display = "block";
- alerts("#000", "#008700", "You successfully loged in to your account " + username);
- } else {
- alerts("#000", "#870c00", "Error! You entered a wrong username or password");
- }
- }
- function info(){
- if(toggleInfo === false){
- toggleInfo = true;
- alerts("#c3c3c3", "#000087", "Info! You can log in if you already have an account or click register to create a new account after writing your details in the corresponding fields");
- } else {
- alertMessage.style.display = "none";
- toggleInfo = false;
- }
- }
- function logout(){
- document.getElementById('username').value = null;
- document.getElementById('password').value = null;
- document.getElementById('email').value = null;
- logoutButton.style.display = "none";
- loginButton2.style.display = "block";
- currentUser.innerHTML = "current user guest";
- btnMyAccount.style.display = "none";
- myAccountDiv.style.display = "none";
- toggleMyAccount = false;
- changePWDiv.style.display = "none";
- toggleChangePW = false;
- pwChangeMessage.style.display = "block";
- pwChangeMessage.innerHTML = null;
- alerts("#000", "#878700", "You have been loged out!");
- }
- function alerts(color, bgColor, text){
- alertMessage.style.color = color;
- alertMessage.style.backgroundColor = bgColor;
- alertMessage.innerHTML = text;
- alertMessage.style.display = "block";
- }
- function overlayOpen(){ loginOverlay.style.display = "block"; }
- function overlayClose(){ loginOverlay.style.display = "none"; }
- function myAccount(){
- if(toggleMyAccount === false){
- myAccountDiv.style.display = "block";
- myAccountUsername.value = username;
- myAccountPassword.value = "null";
- myAccountEmail.value = regEmail;
- changePWDiv.style.display = "none";
- if(username === "username1"){regEmail = "email@test.de";}
- toggleMyAccount = true;
- toggleChangePW = false;
- } else {
- myAccountDiv.style.display = "none";
- changePWDiv.style.display = "none";
- toggleMyAccount = false;
- }
- pwChangeMessage.style.display = "block";
- pwChangeMessage.innerHTML = null;
- }
- function changePasswordBtn() {
- if(toggleChangePW === false) {
- changePWDiv.style.display = "block";
- myAccountDiv.style.display = "none";
- toggleChangePW = true;
- toggleMyAccount = false;
- } else {
- changePWDiv.style.display = "none";
- myAccountDiv.style.display = "block";
- toggleChangePW = false;
- }
- }
- function changePassword(){
- pwChangeMessage.style.display = "block"; pwChangeMessage.innerHTML = null;
- if(oldPassword.value === password && newPassword.value === newPasswordConfirm.value && oldPassword.value !== null && newPassword.value !== null){
- pwChangeMessage.style.color = "#008700";
- pwChangeMessage.innerHTML = "Password changed!";
- password = newPassword.value;
- regPassword = newPassword.value;
- oldPassword.value = null; newPassword.value = null; newPasswordConfirm.value = null;
- } else if (oldPassword.value === password && newPassword.value !== newPasswordConfirm.value){
- pwChangeMessage.style.color = "#870c00";
- pwChangeMessage.innerHTML = "Please confirm your new password!";
- } else if (oldPassword.value !== password && newPassword.value === newPasswordConfirm.value){
- pwChangeMessage.style.color = "#870c00";
- pwChangeMessage.innerHTML = "Wrong password entered!";
- } else {
- pwChangeMessage.style.color = "#870c00";
- pwChangeMessage.innerHTML = "Wrong password entered!";
- }
- }
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement