<!DOCTYPE html>

<html lang="en">

<head>
<meta charset="UTF-8" />
<title>RStudio Sign In</title>
<link rel="shortcut icon" href="images/favicon.ico" />

<link rel="stylesheet" href="rstudio.css" type="text/css"/>
<link rel="stylesheet" href="signin.css" type="text/css"/>

<script type="text/javascript" src="js/signin.js"></script>

<style>

#errorpanel {
  display: #errorDisplay#;
}

#returnlink {
  display: #errorDisplay#;
}

</style>

</head>

<body>
<header role="banner" id="banner">
  <div id="logo">
    #!logoHtml#
  </div>
  <div id="licensed-to">
    <span id="license-prefix">#licensePrefix#</span>
    <span id="licensee">#licensee#</span>
  </div>
</header>

<main>
  <div id="errorpanel">
    <p role="alert">Error: #errorMessage#</p>
  </div>

  <form name='login_form' action='#action#'
        method='POST' enctype='application/x-www-form-urlencoded'>

    <table id="border" role="presentation" align="center">
      <tr>
        <td>
          <h1 class="caption">Sign in as #username#</h1>
        </td>
      </tr>
      <tr>
        <td align="center">
          <span id="countdown" role="timer"></span>
          <input type="hidden" name="#csrf_token_meta#" value="#csrf_token#" />
          <input type='hidden' name='appUri' value='#appUri#'/>
        </td>
      </tr>
      <tr>
        <td align="center">
          <a id="returnlink" href="#signInUrl#">Return to sign in page</a>
        </td>
      </tr>
    </table>
  </form>
  <div class="signin-spinner-holder">
    <div aria-live="polite" class="visuallyhidden" id="progress-message"></div>
    <div role="progressbar" aria-labelledby="progress-message" id="spinner" class="signin-hidden signin-spinner">
       <div></div><div></div><div></div><div></div>
       <div></div><div></div><div></div><div></div>
       <div></div><div></div><div></div><div></div>
    </div>
  </div>

  <div id="login-html">
  #!loginPageHtml#
  </div>
</main>

<script>
   var delay = #redirectDelay#;
   var seconds = delay + 1;
   var error = "#errorMessage#";
   
   function countdown() {
      if (error !== '') {
         return;
      }
      var countdown = document.getElementById("countdown");
      if (--seconds <= 0) {
         countdown.innerHTML = "Redirecting...";
         document.getElementById('spinner').classList.remove('signin-hidden');
         document.getElementById('progress-message').innerText = "Signing in";
         document.forms["login_form"].submit();
      } else {
         if (delay > 0) {
            countdown.innerHTML = "Redirecting in " + seconds + " seconds...";
         }
         window.setTimeout("countdown()", 1000);
      }
   }

   countdown();
</script>
</body>

</html>
