Godlike - HTML

Make count "up" in countdown plugin

Sometimes you need to show countdown for the past event, but with Godlike it is not possible. To make it working, you need to add js extension.

Create a file assets/js/godlike-countdown-extend.js and insert this code inside it:

Godlike.initPluginCountdown = function () {
    if(typeof $.fn.countdown === 'undefined' || typeof moment === 'undefined' || typeof moment.tz === 'undefined') {
        return;
    }
    const self = this;
    $('.nk-countdown').each(function () {
        let tz = $(this).attr('data-timezone');
        let end = $(this).attr('data-end');
            end = moment.tz(end, tz).toDate();
        $(this).countdown(end, {
            elapse: true
        }).on('update.countdown', function(event) {
            $(this).html(
                event.strftime(self.options.templates.countdown)
            );
        });
    });
};

Then, you need to add this extension after main godlike script in HTML files:

<!-- GODLIKE -->
<script src="assets/js/godlike.min.js"></script>
<script src="assets/js/godlike-countdown-extend.js"></script>
<script src="assets/js/godlike-init.js"></script>
<!-- END: Scripts -->

If you make it properly, you will be able to insert this countdown on the page and it will work:

<div class="nk-countdown" data-end="2016-11-26 08:20" data-timezone="EST"></div>