jQuery Help ! දන්න කෙනෙක් Help

Bad Cop

Well-known member
  • Jun 9, 2014
    7,531
    907
    113
    ගම්පහ
    jQuery Help ! දන්න කෙනෙක් Help

    මේකයි සීන් එක.මට jQuery countdown plugin එකක් edit කරගන්න ඕන වෙලා තියෙනවා.:yes: මේකයි script එක. countdown එක වැටෙන්න ඕන 2017-08-30 ඉදලා count වෙන විදිහට.:yes: දන්න කෙනෙක් ඉන්නවනම් හෙල්ප් එකක් දෙන්න:sorry:

    PHP:
    (function($){
    
        $.fn.countDown = function (options) {
    
            config = {};
    
            $.extend(config, options);
    
            diffSecs = this.setCountDown(config);
    
            if (config.onComplete)
            {
                $.data($(this)[0], 'callback', config.onComplete);
            }
            if (config.omitWeeks)
            {
                $.data($(this)[0], 'omitWeeks', config.omitWeeks);
            }
    
            $('#' + $(this).attr('id') + ' .digit').html('<div class="top"></div><div class="bottom"></div>');
            $(this).doCountDown($(this).attr('id'), diffSecs, 500);
    
            return this;
    
        };
    
        $.fn.stopCountDown = function () {
            clearTimeout($.data(this[0], 'timer'));
        };
    
        $.fn.startCountDown = function () {
            this.doCountDown($(this).attr('id'),$.data(this[0], 'diffSecs'), 500);
        };
    
        $.fn.setCountDown = function (options) {
            var targetTime = new Date();
    
            if (options.targetDate)
            {
                targetTime = new Date(options.targetDate.month + '/' + options.targetDate.day + '/' + options.targetDate.year + ' ' + options.targetDate.hour + ':' + options.targetDate.min + ':' + options.targetDate.sec + (options.targetDate.utc ? ' UTC' : ''));
            }
            else if (options.targetOffset)
            {
                targetTime.setFullYear(options.targetOffset.year + targetTime.getFullYear());
                targetTime.setMonth(options.targetOffset.month + targetTime.getMonth());
                targetTime.setDate(options.targetOffset.day + targetTime.getDate());
                targetTime.setHours(options.targetOffset.hour + targetTime.getHours());
                targetTime.setMinutes(options.targetOffset.min + targetTime.getMinutes());
                targetTime.setSeconds(options.targetOffset.sec + targetTime.getSeconds());
            }
    
            var nowTime = new Date();
    
            diffSecs = Math.floor((targetTime.valueOf()-nowTime.valueOf())/1000);
    
            $.data(this[0], 'diffSecs', diffSecs);
    
            return diffSecs;
        };
    
        $.fn.doCountDown = function (id, diffSecs, duration) {
            $this = $('#' + id);
            if (diffSecs <= 0)
            {
                diffSecs = 0;
                if ($.data($this[0], 'timer'))
                {
                    clearTimeout($.data($this[0], 'timer'));
                }
            }
    
            secs = diffSecs % 60;
            mins = Math.floor(diffSecs/60)%60;
            hours = Math.floor(diffSecs/60/60)%24;
            if ($.data($this[0], 'omitWeeks') == true)
            {
                days = Math.floor(diffSecs/60/60/24);
                weeks = Math.floor(diffSecs/60/60/24/7);
            }
            else
            {
                days = Math.floor(diffSecs/60/60/24)%7;
                weeks = Math.floor(diffSecs/60/60/24/7);
            }
    
            $this.dashChangeTo(id, 'seconds_dash', secs, duration ? duration : 800);
            $this.dashChangeTo(id, 'minutes_dash', mins, duration ? duration : 1200);
            $this.dashChangeTo(id, 'hours_dash', hours, duration ? duration : 1200);
            $this.dashChangeTo(id, 'days_dash', days, duration ? duration : 1200);
            $this.dashChangeTo(id, 'weeks_dash', weeks, duration ? duration : 1200);
    
            $.data($this[0], 'diffSecs', diffSecs);
            if (diffSecs > 0)
            {
                e = $this;
                t = setTimeout(function() { e.doCountDown(id, diffSecs-1) } , 1000);
                $.data(e[0], 'timer', t);
            }
            else if (cb = $.data($this[0], 'callback'))
            {
                $.data($this[0], 'callback')();
            }
    
        };
    
        $.fn.dashChangeTo = function(id, dash, n, duration) {
            $this = $('#' + id);
    
            for (var i=($this.find('.' + dash + ' .digit').length-1); i>=0; i--)
            {
                var d = n%10;
                n = (n - d) / 10;
                $this.digitChangeTo('#' + $this.attr('id') + ' .' + dash + ' .digit:eq('+i+')', d, duration);
            }
        };
    
        $.fn.digitChangeTo = function (digit, n, duration) {
            if (!duration)
            {
                duration = 800;
            }
            if ($(digit + ' div.top').html() != n + '')
            {
    
                $(digit + ' div.top').css({'display': 'none'});
                $(digit + ' div.top').html((n ? n : '0')).slideDown(duration);
    
                $(digit + ' div.bottom').animate({'height': ''}, duration, function() {
                    $(digit + ' div.bottom').html($(digit + ' div.top').html());
                    $(digit + ' div.bottom').css({'display': 'block', 'height': ''});
                    $(digit + ' div.top').hide().slideUp(10);
    
    
                });
            }
        };
    
    })(jQuery);
     
    • Like
    Reactions: Profile_01

    Lakshan-Seram

    Well-known member
  • May 31, 2011
    24,738
    12,666
    113
    127.0.0.1:8080/Kandy
    PHP:
    <script language="javascript" type="text/javascript">
        jQuery(document).ready(function() {
            $('#countdown').countDown({
                targetOffset: {
                    'day':         0,
                    'month':     0,
                    'year':     0,
                    'hour':     0,
                    'min':         8,
                    'sec':         0
                },
                // onComplete
                onComplete: function() { /* whatever */  }                    
            });
        });
    </script>
    one dawasata days, months hadanna

    eidt:

    sorry

    PHP:
    targetOffset
    should be
    PHP:
    targetDate
    https://jsfiddle.net/1vufhsxn/3/
     
    Last edited:
    • Like
    Reactions: Bad Cop

    Bad Cop

    Well-known member
  • Jun 9, 2014
    7,531
    907
    113
    ගම්පහ
    PHP:
    <script language="javascript" type="text/javascript">
        jQuery(document).ready(function() {
            $('#countdown').countDown({
                targetOffset: {
                    'day':         0,
                    'month':     0,
                    'year':     0,
                    'hour':     0,
                    'min':         8,
                    'sec':         0
                },
                // onComplete
                onComplete: function() { /* whatever */  }                    
            });
        });
    </script>
    one dawasata days, months hadanna

    eidt:

    sorry

    PHP:
    targetOffset
    should be
    PHP:
    targetDate

    මෙහෙම සින් එකක් මගේ script එකේ නැහැ නේ. මේ වෙන script එකක් නෙද? මට ඕන මම දාපු script එක edit කරගන්න බං;)
     

    Bad Cop

    Well-known member
  • Jun 9, 2014
    7,531
    907
    113
    ගම්පහ
    script eka weda na wage neh..

    anika meke CSS file eka ko?

    https://jsfiddle.net/1vufhsxn/


    වැඩ බං. මම ටෙස්ට් කරා. ඒකේ වැඩ. සයිට් එකට දැන්මාම වැඩ නැහැ. එක countdown වෙන්නේ නැහැ:dull:

    PHP:
    <!-- Watch -->
            <div id="watch">
    
                <!-- Days -->
                <div class="dash days_dash">
                    <div class="digit">0</div>
                    <div class="digit">7</div>
                    <span class="dash_title">Days</span>
                </div>
                <!-- End Days -->
    
                <!-- Hours -->
                <div class="dash hours_dash">
                    <div class="digit">1</div>
                    <div class="digit">2</div>
                    <span class="dash_title">Hours</span>
                </div>
                <!-- End Hours -->
    
                <!-- Minutes -->
                <div class="dash minutes_dash">
                    <div class="digit">0</div>
                    <div class="digit">5</div>
                    <span class="dash_title">Minutes</span>
                </div>
                <!-- End Minutes -->
    
                <!-- Seconds -->
                <div class="dash seconds_dash">
                    <div class="digit">3</div>
                    <div class="digit">9</div>
                    <span class="dash_title">Seconds</span>
                </div>
                <!-- End Seconds -->
    
            </div>
            <!-- End Watch -->
     

    Lakshan-Seram

    Well-known member
  • May 31, 2011
    24,738
    12,666
    113
    127.0.0.1:8080/Kandy
    වැඩ බං. මම ටෙස්ට් කරා. ඒකේ වැඩ. සයිට් එකට දැන්මාම වැඩ නැහැ. එක countdown වෙන්නේ නැහැ:dull:

    PHP:
    <!-- Watch -->
            <div id="watch">
    
                <!-- Days -->
                <div class="dash days_dash">
                    <div class="digit">0</div>
                    <div class="digit">7</div>
                    <span class="dash_title">Days</span>
                </div>
                <!-- End Days -->
    
                <!-- Hours -->
                <div class="dash hours_dash">
                    <div class="digit">1</div>
                    <div class="digit">2</div>
                    <span class="dash_title">Hours</span>
                </div>
                <!-- End Hours -->
    
                <!-- Minutes -->
                <div class="dash minutes_dash">
                    <div class="digit">0</div>
                    <div class="digit">5</div>
                    <span class="dash_title">Minutes</span>
                </div>
                <!-- End Minutes -->
    
                <!-- Seconds -->
                <div class="dash seconds_dash">
                    <div class="digit">3</div>
                    <div class="digit">9</div>
                    <span class="dash_title">Seconds</span>
                </div>
                <!-- End Seconds -->
    
            </div>
            <!-- End Watch -->

    kohenda uba gatte?
    link eka deepan balanna
     

    Lakshan-Seram

    Well-known member
  • May 31, 2011
    24,738
    12,666
    113
    127.0.0.1:8080/Kandy
    පට්ට යකූ.. වැඩේ හරි නෙහ්.. අඩෝ පුලුවන් නම් අර මාම් එවපු ටෙම්ල්පෙට් එකට මේක දාලා එවපන්කෝ:yes::love::love:
    /assets/js/scripts.js

    file eke yatama me tikata wenas karanna
    PHP:
    targetDate: {
                    'day': 30,
                    'month': 8,
                    'year': 2017,
                    'hour': 12,
                    'min': 0,
                    'sec': 0
                }
     

    Bad Cop

    Well-known member
  • Jun 9, 2014
    7,531
    907
    113
    ගම්පහ
    /assets/js/scripts.js

    file eke yatama me tikata wenas karanna
    PHP:
    targetDate: {
                    'day': 30,
                    'month': 8,
                    'year': 2017,
                    'hour': 12,
                    'min': 0,
                    'sec': 0
                }

    එතන වෙනස් කරා බං හරි ගියෙ නැහැ නේ. වෙන කොහෙවත් වෙනස් කරන්න තියෙද:no:
     

    The_Killer

    Well-known member
  • Jan 20, 2014
    11,053
    2,201
    113
    WA, Straya 🇦🇺🦘
    www.elakiri.com
    3edf227419effe5a1bcb589b4be9e1dd.gif