Current File : /home/pacjaorg/public_html/km/components/com_djclassifieds/layouts/auctiontimer.php
<?php
/**
 * @package DJ-Classifieds
 * @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
 * @license http://www.gnu.org/licenses GNU/GPL
 * @author url: http://dj-extensions.com
 * @author email contact@dj-extensions.com
 */
 
defined('_JEXEC') or die;

$app = JFactory::getApplication();

$item = $displayData['item'];
$par = $displayData['par'];

$timer_id = 'djtimer'.$item->id;

?>

<div class="auction_timer">
    <span class="prefix-text"><?php echo JText::_('COM_DJCLASSIFIEDS_AUCTION_TIMER_PREFIX_TEXT'); ?></span>
    <span id="<?php echo $timer_id; ?>" class="djtimer"><span class="djloader"><img src="<?php echo JUri::root().DJClassifiedsTheme::getImgAssetPath('loading.gif'); ?>" alt="..." /></span></span>
</div>
<div class="clear_both"></div>

<script>

    jQuery(function($){        
        if($('#<?php echo $timer_id; ?>').length && !$('.bids_close_info').length){
            var server_time = new Date('<?php echo JFactory::getDate()->format('Y/m/d H:i:s'); ?>').getTime();
            var browser_offset = server_time - new Date().getTime();
            var exp_time = new Date('<?php echo JFactory::getDate($item->date_exp)->format('Y/m/d H:i:s'); ?>').getTime();
            var prev_server_time;
            var now = server_time;

            var x = setInterval(function(){
                server_time = $('#auctions .auction_bids').attr('data-date-now') ? new Date($('#auctions .auction_bids').attr('data-date-now')).getTime() : null;
                if(server_time && server_time != prev_server_time){
                    now = server_time;
                }else if(server_time && server_time == prev_server_time){
                    now += 1000;
                }else{
                    now = new Date().getTime() + browser_offset;
                }
                prev_server_time = server_time;

                exp_time = $('#auctions .auction_bids').attr('data-date-exp') ? new Date($('#auctions .auction_bids').attr('data-date-exp')).getTime() : exp_time;

                var distance = exp_time - now;
                var d = Math.floor(distance / (1000 * 60 * 60 * 24));
                var h = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
                var m = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
                var s = Math.floor((distance % (1000 * 60)) / 1000);

                $('#<?php echo $timer_id; ?>').html((d > 0 ? d + 'd ' : '') + (d > 0 || h > 0 ? h + 'h ' : '' ) + (d > 0 || h > 0 || m > 0 ? m + 'm ' : '') + s + 's ');

                if(distance <= 0){
                    clearInterval(x);
                    $('#<?php echo $timer_id; ?>').closest('.auction_timer').html('<span class="expired-label"><?php echo DJClassifiedsTheme::sanitizeText(JText::_('COM_DJCLASSIFIEDS_AUCTION_TIMER_EXPIRED')); ?></span>');
                }
            }, 1000);
        }
    });
    
</script>

<style>
    #dj-classifieds .auction_timer {
        background-color: #393f48;
        color: #fff;
        padding: 10.5px;
        float: right;
        margin-top: -10px;
        margin-bottom: 10px;
    }
</style>
Site is undergoing maintenance

PACJA Events

Maintenance mode is on

Site will be available soon. Thank you for your patience!