Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • VoDanh 3 posts 23 karma points
    Aug 11, 2022 @ 12:09
    VoDanh
    0

    How can I see logic of ellipsis pagination in umb-pagination directive ?

    Many thanks!

  • VoDanh 3 posts 23 karma points
    Aug 11, 2022 @ 12:11
    VoDanh
    0
    function pagination(c, m) {
            var current = c,
                last = m,
                delta = 2,
                left = current - delta,
                right = current + delta + 1,
                range = [],
                rangeWithDots = [],
                l;
    
            for (let i = 1; i <= last; i++) {
                if (i == 1 || i == last || i >= left && i < right) {
                    range.push(i);
                }
            }
    
            for (let i of range) {
                if (l) {
                    if (i - l === 2) {
                        rangeWithDots.push(l + 1);
                    } else if (i - l !== 1) {
                        rangeWithDots.push('...');
                    }
                }
                rangeWithDots.push(i);
                l = i;
            }
            return rangeWithDots;
        }
    

    I'm finding the other implement to learning,...

  • VoDanh 3 posts 23 karma points
    Aug 24, 2022 @ 12:39
    VoDanh
    0
    function pagination(c, m) {
            var current = c,
                last = m,
                delta = 2,
                left = current - delta,
                right = current + delta + 1,
                range = [],
                rangeWithDots = [],
                l;
    
            for (let i = 1; i <= last; i++) {
                if (i == 1 || i == last || i >= left && i < right) {
                    range.push(i);
                }
            }
    
            for (let i of range) {
                if (l) {
                    if (i - l === 2) {
                        rangeWithDots.push(l + 1);
                    } else if (i - l !== 1) {
                        rangeWithDots.push('...');
                    }
                }
                rangeWithDots.push(i);
                l = i;
            }
            return rangeWithDots;
        }
    

    I'm finding the other implement to learning,...

    String.prototype.toHHMMSS = function () {
            var sec_num = parseInt(this, 10);
            var hours = Math.floor(sec_num / 3600);
            var minutes = Math.floor((sec_num - (hours * 3600)) / 60);
            var seconds = sec_num - (hours * 3600) - (minutes * 60);
    
            if (hours < 10) {
                hours = "0" + hours;
            }
            if (minutes < 10) {
                minutes = "0" + minutes;
            }
            if (seconds < 10) {
                seconds = "0" + seconds;
            }
            return hours + ":" + minutes + ":" + seconds;
        };
    
        let storeTimeOutKey = "timeOut"
    
        let time = new Date();
        let minutely = 60 * 1000
    
        var cachedTimeOut = localStorage.getItem(storeTimeOutKey)
        if(cachedTimeOut){
            time = JSON.parse(cachedTimeOut)
        }
        else{
            time.setTime(time.getTime() + minutely * 6)
            localStorage.removeItem(storeTimeOutKey)
            localStorage.setItem(storeTimeOutKey, JSON.stringify(time.getTime()))
        }
    
        // var timer = setInterval(Countdown(time / 1000), 1000)
    
        function Countdown(startTime) {
            return () => {
                let curTime = (new Date()).getTime() / 1000;
                let result = (`${startTime - curTime}`).toHHMMSS();
                console.log(result)
    
                let isTimeOut = parseInt(startTime - curTime, 10) == 0
                if(isTimeOut){
                    clearInterval(timer)
                    return;
                }
            }
        }
    
  • Lucas Bisgaard 19 posts 128 karma points c-trib
    Aug 12, 2022 @ 07:02
    Lucas Bisgaard
    0

    Hello VoDanh.

    If you still look for umbraco umb-pagination directive implemtation, then it is located here https://github.com/umbraco/Umbraco-CMS/blob/v10/contrib/src/Umbraco.Web.UI.Client/src/common/directives/components/umbpagination.directive.js.

    Under the Umbraco.Web.UI.Client/src in Github, you can find all logic for the whole backoffice.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies