$(document).ready(function(){
  var backgroundPage = chrome.extension.getBackgroundPage();

  $('#pair-me-icon').on('click', function(e){
    e.preventDefault();
    $.ajax({
      url: "http://localhost:9393/session",
      type: "post",
      data: $('#pair_login').serialize(),
      dataType: 'json'
    })
    .done(function(data){
      backgroundPage.currentView = '.duration-form';
      backgroundPage.user1 = data['user1'];
      backgroundPage.user2 = data['user2'];
      $('.sign-in').hide();
      $('.duration-form').show();
    })
    .fail(function(data){
      $('.auth-error').html("<p style='color:white;font-size:1em'><b>Authentication Failed Please Try Again</b></p>");
    });
  });

  $('button.start-pairing').on('click', function(){
    if($('input.duration').val() !== "" ){
      backgroundPage.setTimeInterval(parseInt($('input.duration').val()));
      backgroundPage.startPairing();
    } else {
      alert("Please Enter A Real Number");
    }
    backgroundPage.currentView='.running-session';
    setPopupView();
  });

  $('.pause-pairing').on('click', function(){
    if(backgroundPage.pause()){
      $('#pause-button').hide();
      $('#resume-button').show();
    }else{
      $('#resume-button').hide();
      $('#pause-button').show();
    }

  });

  $('.exit-pairing').on('click', function(){
    backgroundPage.endPairingSession();
  });
  backgroundPage.getPopup();
  backgroundPage.updateTimerCountdown();

  function setPopupView(){
    var currentView = backgroundPage.currentView;
    if(currentView){
      $('.sign-in').hide();
      $('.duration-form').hide();
      $('.running-session').hide();
      $(currentView).show();
    }
  }

  setPopupView();
});
$(document).ready(function(){
  var backgroundPage = chrome.extension.getBackgroundPage();

  $('#pair-me-icon').on('click', function(e){
    e.preventDefault();
    $.ajax({
      url: "http://localhost:9393/session",
      type: "post",
      data: $('#pair_login').serialize(),
      dataType: 'json'
    })
    .done(function(data){
      backgroundPage.currentView = '.duration-form';
      backgroundPage.user1 = data['user1'];
      backgroundPage.user2 = data['user2'];
      $('.sign-in').hide();
      $('.duration-form').show();
      $('input').val('')
      $('countdown').val('0');
    })
    .fail(function(data){
      $('.auth-error').html("Authentication Failed Please Try Again");
      setTimeOut(function(){$('.auth-error').empty();},5000);
    });
  });

  $('.start-pairing').on('click', function(){
    var time_duration = $('input.duration').val();
    if(time_duration !== "" && !isNaN(parseInt(time_duration))){
      backgroundPage.setTimeInterval(parseInt(time_duration));
      backgroundPage.startPairing();
      backgroundPage.currentView='.running-session';
      setPopupView();
    } else {
      $('.interval-error').append("The Number You Entered Is Not Valid");
      setTimeout(function(){$('.interval-error').empty();},5000);
    }
  });

  $('.pause-pairing').on('click', function(){
    if(backgroundPage.pause()){
      $('#pause-button').hide();
      $('#resume-button').show();
    }else{
      $('#resume-button').hide();
      $('#pause-button').show();
    }

  });

  $('.exit-pairing').on('click', function(){
    backgroundPage.endPairingSession();
  });
  backgroundPage.getPopup();
  backgroundPage.updateTimerCountdown();

  function setPopupView(){
    var currentView = backgroundPage.currentView;
    if(currentView){
      $('.sign-in').hide();
      $('.duration-form').hide();
      $('.running-session').hide();
      $(currentView).show();
    }
  }

  setPopupView();
});
Add Checks/Error Messaging to Interval Selector