@savvasha commit from BitBucket

This commit is contained in:
Brian Miyaji
2018-08-24 00:47:45 +10:00
parent 84782414d2
commit 7f03ca39b9
9 changed files with 58 additions and 42 deletions

View File

@@ -457,10 +457,31 @@ jQuery(document).ready(function($){
// Dashboard countdown
$("#sportspress_dashboard_status .sp_status_list li.countdown").each(function() {
var $this = $(this), finalDate = $(this).data('countdown');
$this.countdown(finalDate, function(event) {
$this.find('strong').html(event.strftime("%D "+localized_strings.days+" %H:%M:%S"));
});
var $this = $(this);
// Get countdown time
var countDownDate = new Date($(this).data('countdown')).getTime();
// Iterate every second
var x = setInterval(function() {
// Get todays date and time
var now = new Date();
// Convert curent date and time to UTC
var tzDifference = now.getTimezoneOffset();
var nowutc = new Date(now.getTime() + tzDifference * 60 * 1000);
// Find the distance between now and the count down date
var distance = countDownDate - nowutc;
// Time calculations for days, hours, minutes and seconds
var days = Math.floor(distance / (1000 * 60 * 60 * 24));
var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
var seconds = Math.floor((distance % (1000 * 60)) / 1000);
// Output the result
$this.find('strong').html(days+" "+localized_strings.days+" "+('0' + hours).slice(-2)+":"+('0' + minutes).slice(-2)+":"+('0' + seconds).slice(-2));
}, 1000);
});
// Event format affects data