Advertisement
Guest User

script

a guest
Apr 6th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.04 KB | None | 0 0
  1. function ava_custom_script_fix(){
  2. ?>
  3. <style>.av-countdown-timer{opacity: 0!important;}</style>
  4. <script>
  5.  
  6. var cday;
  7. var timeInSecs;
  8. var ticker;
  9.  
  10. function getSeconds() {
  11. var now = new Date();
  12. var dy = 3;
  13. var countdowntime = new Date(now.getFullYear(),now.getMonth(),now.getDate(),0,0,0);
  14.  
  15. var nowtime= now.getTime();
  16. var atime = countdowntime.getTime();
  17. var diff = parseInt((atime – nowtime)/1000);
  18. if (diff > 0) {
  19. cday = dy – now.getDay()
  20. } else {
  21. cday = dy – now.getDay() -1
  22. }
  23. if (cday < 0) {
  24. cday += 7;
  25. }
  26. if (diff <= 0) {
  27. diff += (86400 * 7)
  28. }
  29. startTimer (diff);
  30. }
  31.  
  32. function startTimer(secs) {
  33. timeInSecs = parseInt(secs);
  34. ticker = setInterval("tick()",1000);
  35. tick();
  36. }
  37.  
  38. function tick() {
  39. var secs = timeInSecs;
  40. if (secs>0) {
  41. timeInSecs–;
  42. } else {
  43. clearInterval(ticker);
  44. getSeconds();
  45. }
  46.  
  47. var days = Math.floor(secs/86400);
  48. secs %= 86400;
  49.  
  50. var hours= Math.floor(secs/3600);
  51. secs %= 3600;
  52.  
  53. var mins = Math.floor(secs/60);
  54. secs %= 60;
  55.  
  56. var p_day = ""
  57. var p_hr = ""
  58. var p_min = ""
  59. var p_sec = ""
  60.  
  61. if (cday != 1) { p_day = "s" }
  62. if (hours != 1) { p_hr = "s" }
  63. if (mins != 1) { p_min = "s" }
  64. if (secs != 1) { p_sec = "s" }
  65.  
  66. //var result = cday + ' day' + p_day + ' ';
  67. //result += hours + ' hour' + p_hr + ' ' + mins + ' minute' + p_min + ' ' + secs + ' second' + p_sec;
  68. // document.getElementById("countdown").innerHTML = result;
  69. jQuery('.av-countdown-days .av-countdown-time').html(cday);
  70. jQuery('.av-countdown-hours .av-countdown-time').html(hours);
  71. jQuery('.av-countdown-minutes .av-countdown-time').html(mins);
  72. jQuery('.av-countdown-seconds .av-countdown-time').html(secs);
  73. jQuery('.av-countdown-timer').css('opacity', '1!important');
  74. jQuery('.av-countdown-timer').attr('style','opacity:1!important');
  75.  
  76. }
  77.  
  78. // LOAD DIFFERENT IMAGES AS BACKGROUND FOR COUNTER
  79. jQuery(document).ready(function() {
  80. jQuery('.av-countdown-days .av-countdown-time').html('');
  81.  
  82. getSeconds();
  83. //jQuery('.av-countdown-timer').css('display', 'block');
  84. });
  85. </script>
  86. <?php
  87. }
  88. add_action('wp_footer', 'ava_custom_script_fix');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement