title: Pass window.SessionTimeout script to js file
body: <p>I´m doing an MVC app. And this is in my _Layout.cshtml </p>
  
  <p>I need to move it to a a js file</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  window.SessionTimeout = (function() {
      var _timeLeft, _popupTimer, _countDownTimer;
  
      var stopTimers = function() {
          window.clearTimeout(_popupTimer);
          window.clearTimeout(_countDownTimer);
      };
  
      var updateCountDown = function() {
          var min = Math.floor(_timeLeft / 60);
          var sec = _timeLeft % 60;
          if(sec &lt; 10)
              sec = "0" + sec;
  
          document.getElementById("CountDownHolder").innerHTML = min + ":" + sec;
  
          if(_timeLeft &gt; 0) {
              _timeLeft--;
              _countDownTimer = window.setTimeout(updateCountDown, 1000);
          } else  {
              document.location = "Home/TimeOutPage";
          }            
      };
  
      var showPopup = function() {
          _timeLeft = 60;
          updateCountDown();
          ClientTimeoutPopup.Show();
      };
  
      var schedulePopup = function() {
          stopTimers();
          _popupTimer = window.setTimeout(showPopup, @PopupShowDelay);
      };
  
      var sendKeepAlive = function() {
          stopTimers();
          ClientTimeoutPopup.Hide();
          SessionTimeout.schedulePopup();
      };
  
      return {
          schedulePopup: schedulePopup,
          sendKeepAlive: sendKeepAlive
      };
  
  })();    
  </code></pre>
  
  <p></p>
  
  <p>I try to copy only the code between the script tag but it doesn't work. I know the problem is with the function signature </p>
  
  <p><strong>window.SessionTimeout = (function() { ...</strong></p>
  
  <p>but i don´t know hot to use <strong>window.SessionTimeout</strong> in a js file.</p>
  
  <p>The @PopupShowDelay is define in my view like this:</p>
  
  <pre><code>       @functions { 
          public int PopupShowDelay
          {
              get { return 60000 * (Session.Timeout - 1); }
          }
      }
  </code></pre>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Ok, i found the error.
  The problem is the variable</p>
  
  <pre><code>@PopupShowDelay
  </code></pre>
  
  <p>I defined that at the <em>view</em> and was trying to read the <em>.js</em> file.</p>
  
  <p>So, i'm going tho check this:
  <a href="https://stackoverflow.com/questions/2190801/passing-parameters-to-javascript-files">Passing parameters to JavaScript files</a></p>
  
  <p>Thankls!!</p>