B-Drive Posted March 14, 2020 Share Posted March 14, 2020 Site URL: https://www.brianspoem.com Hello! I currently have a script running in the sidebar that counts the number of poems. It works, but the only problem is that I have to increment it manually. I asked a programmer friend if he could help me with a script that would count the number of poems from a starting date so that I would not have to manually edit the script each day. Below is the code he sent me. Unfortunately, I can't get this script to run and he is not able to help me. This script is very much like the script currently running, so I'm not sure what the problem is. Any insight or suggestions are greatly appreciated. 🙂 Brian ===================SCRIPT BELOW=================== <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script> <script> var a = 0; $(window).scroll(function() {  var oTop = $('#counter').offset().top - window.innerHeight;  if (a == 0 && $(window).scrollTop() > oTop) {    $('.counter-value').each(function() {      var $this = $(this),        startDate = getDaysSinceStartDate($this.attr('data-startdate'));      $({        countNum: $this.text()      }).animate({          countNum: startDate        },        {          duration: 2000,          easing: 'swing',          step: function() {            $this.text(Math.floor(this.countNum));          },          complete: function() {            $this.text(this.countNum);          }        });    });    a = 1;  } function getDaysSinceStartDate(startDate) {   var today = new Date().getTime() / 1000;   startDate = Date.parse(startDate) / 1000;   return Math.floor((today - startDate) / 60 / 60 / 24); }); </script> <div id="counter"> <div class="sqs-col sqs-col-4 counter-value" data-startdate="07/22/2016" data-desc="Poems Published">0</div> </div> Link to comment
Recommended Posts
Archived
This topic is now archived and is closed to further replies.