title: Javascript - delayed button with cookie checker
body: <p>i am trying to do something that it's still out of my league. I have used before script on website to show Button after 1 minute from video time. So when Video player comes to 01:00 the button is shown and after that it saves that to cookie so the next time you visit page it's shown right away and you don't have to wait another 1 minute so button can be shown.</p>
  
  <p>But now i am trying to connect this timer to the website time, not the video time, and i am pretty lost.</p>
  
  <p>Function calling in Index page:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  var minuten = 0;
  var sekunden = 5;
  
  //==========================
  cartt(minuten, sekunden);   
  &lt;/script&gt;
  </code></pre>
  
  <p>This is the original code of the video time:</p>
  
  <pre><code> $("#video").fitVids(); 
   var video = new Vimeo.Player($('#video iframe'));
   function cart(minuten, sekunden) {
  
      var button = $('.cart');
      var seconds = (minuten * 60) + sekunden;
      var url = window.location.pathname;
      url = url.split("/");
      var seite = url[url.length -1];
      var cookie_string = "cartbutton_" + seite + "=show";
      var cookieIsSet = function() { return document.cookie.indexOf(cookie_string) != -1; };
  
      if(!cookieIsSet()) {
          button.hide();
  
          video.on('timeupdate', function(data) {
              if (data.seconds &gt;= seconds &amp;&amp; !cookieIsSet()) {
                  button.show();
                  document.cookie = cookie_string + "; max-age=259200";
              }
          });
      }
  
  }
  </code></pre>
  
  <p>And this is how i am trying to get website time:</p>
  
  <pre><code>window.onload=function(){
        var start=Date.now();
  
  }
  function cartt(minuten, sekunden) {
  
      var button = $('.cartt');
      var seconds = (minuten * 60) + sekunden;
      document.write(seconds);
      var url = window.location.pathname;
      url = url.split("/");
      var seite = url[url.length -1];
      var cookie_string = "cartbutton_" + seite + "=show";
      var cookieIsSet = function() { 
          return document.cookie.indexOf(cookie_string) != -1; 
  
          };
  
  
  
      if(!cookieIsSet()) {
  
       start.on(function(data) {
              if (data.seconds &gt;= seconds &amp;&amp; !cookieIsSet()) {
                  button.show();
                  document.cookie = cookie_string + "; max-age=259200";
              }
          });
  
          button.hide();
  
  
      }
  
  }
  </code></pre>