Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ava_custom_script_fix(){
- ?>
- <style>.av-countdown-timer{opacity: 0!important;}</style>
- <script>
- var cday;
- var timeInSecs;
- var ticker;
- function getSeconds() {
- var now = new Date();
- var dy = 3;
- var countdowntime = new Date(now.getFullYear(),now.getMonth(),now.getDate(),0,0,0);
- var nowtime= now.getTime();
- var atime = countdowntime.getTime();
- var diff = parseInt((atime – nowtime)/1000);
- if (diff > 0) {
- cday = dy – now.getDay()
- } else {
- cday = dy – now.getDay() -1
- }
- if (cday < 0) {
- cday += 7;
- }
- if (diff <= 0) {
- diff += (86400 * 7)
- }
- startTimer (diff);
- }
- function startTimer(secs) {
- timeInSecs = parseInt(secs);
- ticker = setInterval("tick()",1000);
- tick();
- }
- function tick() {
- var secs = timeInSecs;
- if (secs>0) {
- timeInSecs–;
- } else {
- clearInterval(ticker);
- getSeconds();
- }
- var days = Math.floor(secs/86400);
- secs %= 86400;
- var hours= Math.floor(secs/3600);
- secs %= 3600;
- var mins = Math.floor(secs/60);
- secs %= 60;
- var p_day = ""
- var p_hr = ""
- var p_min = ""
- var p_sec = ""
- if (cday != 1) { p_day = "s" }
- if (hours != 1) { p_hr = "s" }
- if (mins != 1) { p_min = "s" }
- if (secs != 1) { p_sec = "s" }
- //var result = cday + ' day' + p_day + ' ';
- //result += hours + ' hour' + p_hr + ' ' + mins + ' minute' + p_min + ' ' + secs + ' second' + p_sec;
- // document.getElementById("countdown").innerHTML = result;
- jQuery('.av-countdown-days .av-countdown-time').html(cday);
- jQuery('.av-countdown-hours .av-countdown-time').html(hours);
- jQuery('.av-countdown-minutes .av-countdown-time').html(mins);
- jQuery('.av-countdown-seconds .av-countdown-time').html(secs);
- jQuery('.av-countdown-timer').css('opacity', '1!important');
- jQuery('.av-countdown-timer').attr('style','opacity:1!important');
- }
- // LOAD DIFFERENT IMAGES AS BACKGROUND FOR COUNTER
- jQuery(document).ready(function() {
- jQuery('.av-countdown-days .av-countdown-time').html('');
- getSeconds();
- //jQuery('.av-countdown-timer').css('display', 'block');
- });
- </script>
- <?php
- }
- add_action('wp_footer', 'ava_custom_script_fix');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement